This project demonstrates how to write a multi-stage Dockerfile for a multi-module Maven project, so that Maven dependencies are cached in the early Docker layers of a builder stage and also how to use a layered JAR to create cache layers in the final Docker image.
In this project the user-app
module depends on a common
module.
DOCKER_BUILDKIT='1' docker build \
-t pgpb/user-app:local \
-f docker/user-app.dockerfile . \
&& docker run -it pgpb/user-app:local
docker build \
-t pgpb/user-app:local \
-f docker/user-app.dockerfile . \
&& docker run -it pgpb/user-app:local
- Creating Docker images with Spring Boot. Shows how to use a layered JAR to cache layers in the final stage of the multi-stage Dockerfile. However, it does not cover how to cache layers for the first stage.
- Multi-stage Dockerfile