https://github.com/moeki0/docker-best-practices
Docker best practices for good caching
https://github.com/moeki0/docker-best-practices
best-practices docker docker-compose nodejs rails
Last synced: 2 months ago
JSON representation
Docker best practices for good caching
- Host: GitHub
- URL: https://github.com/moeki0/docker-best-practices
- Owner: moeki0
- Created: 2022-10-23T12:52:10.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-10-24T04:04:21.000Z (over 3 years ago)
- Last Synced: 2025-11-30T03:50:22.643Z (7 months ago)
- Topics: best-practices, docker, docker-compose, nodejs, rails
- Language: Ruby
- Homepage:
- Size: 39.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Docker Best Practices
```
brew install colima
```
```
bin/prepare
```
```
bin/inspect Dockerfile.[variant]
```
```
bin/clean
```
### Variants
#### 👎 `Dockerfile.single-stage`
- `yarn install` and `bundle install` run in **serial**
- If any of the sources are changed, the installation is performed always.
```bash
=> [app 7/10] COPY . .
=> [app 8/10] RUN bundle install
=> [app 9/10] RUN yarn install
=> [app 10/10] RUN RAILS_ENV=production bundle exec rails assets:precompile
```
#### 👎 `Dockerfile.separate-builder`
- `yarn install` and `bundle install` run in **serial**
- If `Gemfile.lock` is changed, `yarn install` is performed always.
```bash
=> [builder 6/15] COPY Gemfile Gemfile.lock ./
=> [builder 7/15] RUN bundle install
=> [builder 8/15] COPY package.json yarn.lock ./
=> [builder 9/15] RUN yarn install
```
#### 👍 `Dockerfile.separate-processes`
- `yarn install` and `bundle install` run in **parallel**
- If `package.json` is changed, `bundle install` will not be executed.
```bash
=> [yarn 3/4] COPY package.json yarn.lock ./
=> [yarn 4/4] RUN yarn install
=> CACHED [bundler 1/4] WORKDIR /tmp
=> CACHED [bundler 2/4] RUN gem install bundler
=> CACHED [bundler 3/4] COPY Gemfile Gemfile.lock ./
=> CACHED [bundler 4/4] RUN bundle install
```