Skip to content

Enable cache for pre-stage in multi-stage docker build

Balasankar 'Balu' C requested to merge cache-with-multi-stage-builds into master

Since we are using multi-stage docker builds, the final image has no intermediate layes - just the layers from base image and one COPY layer. This defeats the purpose of caching that we implemented in !81 (merged).

This MR implements a workaround for having cache. It includes

  1. Creating builder images from the first stage of our multi-stage builds. These are old, bulky images that we used to ship to the customers before multi-stage builds.
  2. Use these builder images as cache for subsequent builds. This way, intermediate layers are available for builds.

The pros are:

  1. Builds take way less amount of time to complete.
  2. Users still get the slim version, nothing changes there.

The cons are:

  1. We end up using more space in our registry.

Original idea from: https://github.com/moby/moby/issues/34715#issue-254897142

Edited by Balasankar 'Balu' C

Merge request reports