Skip to content

Conversation

@NikitaCOEUR
Copy link
Contributor

This commit introduces a workaround for the GitHub Actions cache backend when using the docker cache-from and cache-to flags with BuildKit.

The current version of int128/docker-build-cache-config-action incorrectly uses ref= instead of scope= for the gha cache 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= by scope= 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.

This commit introduces a workaround for the GitHub Actions cache backend
when using the docker `cache-from` and `cache-to` flags with BuildKit.

The current version of `int128/docker-build-cache-config-action` incorrectly uses
`ref=` instead of `scope=` for the `gha` cache 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=` by `scope=` 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.
@NikitaCOEUR
Copy link
Contributor Author

@neilime Do you have time to review this PR

@neilime neilime merged commit 3ae7f2f into hoverkraft-tech:main Sep 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants