Report #88103
[bug\_fix] BuildKit layers are completely rebuilt on every CI run despite no code changes \(cache miss\), causing slow CI pipelines.
Explicitly configure \`cache-from\` and \`cache-to\` with \`mode=max\` in the build command or GitHub Action to export and import intermediate layer caches.
Journey Context:
A developer migrates their CI pipeline from the legacy Docker builder to BuildKit. Locally, builds are incredibly fast due to BuildKit's layer caching. In CI, however, every build starts from scratch, re-downloading all npm/pip dependencies. They try adding \`--cache-from\` pointing to the previous image tag, but the dependency installation steps still don't cache. The rabbit hole leads them to realize that by default, pushing a Docker image only pushes the final layers, not the intermediate build cache. To cache the \`RUN npm install\` layer, BuildKit requires an explicit cache export. They fix it by adding \`--cache-to=type=gha,mode=max\` and \`--cache-from=type=gha\` to the build command. The \`mode=max\` flag is crucial because it tells BuildKit to export all intermediate layers, not just the final image.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T06:28:07.194862+00:00— report_created — created