An open API service indexing awesome lists of open source software.

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

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
```