fix(gha): workaround cache-to and cache-from scope #480
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.
This commit introduces a workaround for the GitHub Actions cache backend when using the docker
cache-fromandcache-toflags with BuildKit.The current version of
int128/docker-build-cache-config-actionincorrectly usesref=instead ofscope=for theghacache backend, which leads to shared caches across branches and builds, resulting in frequent invalidations and inefficient caching.Until the upstream PR is merged and released:
int128/docker-build-cache-config-action#1213
...this commit replace
ref=byscope=to ensure proper cache isolation and reliable cache behavior in CI.This workaround will be removed once the upstream fix is available in a stable release.
For information
In our current CI setup, we rely on Docker layer caching to speed up multi-stage builds across different branches and commits. However, we noticed that intermediate layers were almost never reused, even when there were no code changes between builds.
This led to full rebuilds of our Docker images on every commit, with build times averaging 2–3 minutes.
After investigation, we identified the root cause:
the action int128/docker-build-cache-config-action uses ref= instead of scope= when configuring cache-from and cache-to for the gha backend. According to Docker’s documentation, omitting scope= causes cache collisions across builds and branches, making caching unreliable.