Docker Layer Caching for multi-stage docker build
G
Graham
We use CircleCI to build and deploy Docker images for our production services. For a production service running from a Docker image, it's crucial to use a multi-stage build to avoid shipping large images into production. For example, a standard Rust development image may be as large as 1.5gb without even considering application code. With a multi-stage Docker image, we can build the Rust binary on the development image and then copy the binary into a smaller base image more suited to production environments.
Since we're building these images in CircleCI to support our CI/CD workflows, it'd be a huge help to have docker layer caching support multi-stage builds in a way that's consistent with Docker for Desktop. For example, we shouldn't need to redownload and rebuild third-party dependencies just because we're using a multi-stage Dockerfile.