Skip to main content
Make deploying via Git faster by structuring your Dockerfile to maximize efficiency by leveraging the Docker build cache:

Gems installed via Bundler

In order for the Docker build cache to cache gems installed via Bundler:
  1. Add the Gemfile and Gemfile.lock files to the image.
  2. Run bundle install, before adding the rest of the repo (via ADD .).
Here’s an example of how that might look in a Dockerfile:

Packages installed via NPM

In order for the Docker build cache to cache packages installed via npm:
  1. Add the package.json file to the image.
  2. Run npm install, before adding the rest of the repo (via ADD .).
Here’s an example of how that might look in a Dockerfile:

Packages installed via PIP

In order for the Docker build cache to cache packages installed via pip:
  1. Add the requirements.txt file to the image.
  2. Run pip install, before adding the rest of the repo (via ADD .).
Here’s an example of how that might look in a Dockerfile: