You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docker: bake Maven dependencies into an image layer instead of a cache mount
The dependency-resolution steps wrote the local Maven repository to a BuildKit cache mount (`--mount=type=cache,target=/tmp/m2_repo`). A cache mount is builder-local scratch space that is deliberately excluded from image layers, so it was never captured by layer caching. On a fresh builder the mount was always empty and every build re-downloaded the full dependency tree (~3,600 artifacts, ~7 minutes), while the actual offline compile took only ~24 seconds.
Drop the cache mount from the three dependency steps and the offline install so the populated `/tmp/m2_repo` lands in the build stage's image layer. That layer depends only on the pom.xml files (via the poms stage), so it stays cached until a POM changes: source-only changes now reuse the downloaded dependencies instead of fetching them again.
Effect on produced images: none. The Maven repository lives only in the intermediate build stage; the runtime stage still copies out just distribution-base and entrypoint.sh, so the final image is byte-for-byte equivalent. The build stage's cached layer grows by the size of the Maven repository, which is the intended trade for skipping the downloads.
0 commit comments