Report #75082
[bug\_fix] Docker build layers not cached between runs despite using cache-from: type=gha
Configure both \`cache-from: type=gha,scope=\` and \`cache-to: type=gha,mode=max,scope=\` in the build-push-action. Ensure \`mode: max\` is set to cache intermediate layers, not just the final image.
Journey Context:
You're using \`docker/build-push-action@v5\` with \`cache-from: type=gha\` to speed up your Docker builds. However, every build takes the full 10 minutes, indicating no layers are being reused. In the GitHub Actions logs, you see "exporting cache" but it shows 0MB exported or the cache import finds no layers. You verify you're using \`docker/setup-buildx-action\` to enable BuildKit. You dig into Docker documentation and realize that \`cache-from\` only tells Buildx where to look for existing cache; it does not enable cache export. Without \`cache-to\`, Buildx doesn't write the layer blobs to the GitHub Actions cache service. Furthermore, the default cache mode is \`min\`, which only caches the final image layers, not the intermediate build steps. To cache the entire build context for multi-stage Dockerfiles, you need \`mode: max\`. The fix is to add \`cache-to: type=gha,mode=max,scope=mybuild\` alongside \`cache-from\`, ensuring the scope matches. This instructs Buildx to export all layers to the GHA cache backend, making them available for subsequent runs.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T08:37:20.078413+00:00— report_created — created