Repository navigation
feat(build): keep Dockerfile cache mounts between ARC image builds - #359
Merged
Merged
Conversation
JesperTerkelsen
marked this pull request as ready for review
September 29, 2026 10:40
JesperTerkelsen
requested review from
prasad-manu
and removed request for
a team
September 29, 2026 10:40
prasad-manu
approved these changes
Sep 29, 2026
ARC builders start empty and the ECR registry cache doesn't carry RUN --mount=type=cache contents, so every Kotlin image build on ARC re-downloaded all Gradle dependencies from Maven Central. Restore and save the cache mounts with actions/cache and buildkit-cache-dance, which discovers them from the Dockerfile. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Matches the PR workflows: S3 when the caller passes the GH_ACTION_* secrets (now accepted by component-build and deploy-kotlin(-v2)), the GitHub cache otherwise. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
JesperTerkelsen
force-pushed
the
feat/arc-docker-cache-mounts
branch
from
September 29, 2026 10:44
d4f2f97 to
12f35a5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
On ARC (
use-arc-runners: true),component-build.ymlnow keeps the Dockerfile'sRUN --mount=type=cachecontents between image builds:runs-on/cache(S3,monta-github-ci-cache), oractions/cacheas a fallback, restores them into a workspace directory;reproducible-containers/buildkit-cache-dance(pinned to v3.4.0) injects them into the buildx builder, then extracts them after the build so they can be saved.The action finds the mounts by parsing the Dockerfile given in
docker-file-name, so nothing is hardcoded.Why?
All 44 Kotlin service Dockerfiles run Gradle inside the image build:
RUN --mount=type=cache,target=/root/.gradle ... ./gradlew --no-daemon clean buildLayersOn Blacksmith, the builder's disk persists between runs, so
/root/.gradlestays warm. On ARC:cache-to ... mode=max) doesn't carry cache mounts;COPY . /home/srcbefore the GradleRUNmeans any code change invalidates that layer anyway.So every ARC deploy would re-download all Gradle dependencies. They'd also come straight from Maven Central: the runner's CodeArtifact init script and its AWS identity don't reach Gradle inside
docker build. That's slower, and it's exactly the traffic behind the Maven Central 429s on ARC. This is a prerequisite for making ARC the default runner.The cache key is the Dockerfile path plus a hash of the Gradle build files, with a prefix restore-key, so a dependency bump still starts from the previous cache.
Storage: S3 via
runs-on/cache, like the PR workflowsGH_ACTION_ACCESS_KEY_ID/GH_ACTION_SECRET_ACCESS_KEY, whichcomponent-buildanddeploy-kotlin(-v2)now accept as optional secrets. Otherwise the GitHub cache is used, as in feat(kotlin): make ARC the default runner for the Kotlin workflows #360.runs-on/cacheaction (the same pin as the Sonar cache insonar-cloud.yml), notruns-on/cache/restore+save. cache-dance only extracts the mounts from the builder in its post step. Post steps run after every normal step, so a separatesavestep would save an empty directory, while the combined action's own post-step save runs after the extraction.AWS_SESSION_TOKEN: "". The job has already exported the target account'secr-put-imagesession into the environment, and that token would otherwise pair with the bucket keys.QA
Carried by https://github.com/monta-app/service-openadr/pull/262. Its staging deploy points at this branch and passes the S3 secrets. Results to follow: a cold run, then a warm run to show the cache hit.
Gaps
🤖 Generated with Claude Code