Report #15596
[bug\_fix] Docker build cache invalidated on every run despite no code changes
Add .git to the .dockerignore file to prevent Git metadata \(timestamps, permissions\) from changing the context checksum and invalidating the COPY . . cache.
Journey Context:
A developer notices their CI pipeline takes 10 minutes to build on every commit, even if they only changed a markdown file. They examine the build logs and see that the 'COPY . .' step never uses the cache. They dive into BuildKit's internal cache mechanics, checking hashes and layer IDs. They discover that because the CI runner does a fresh git clone for every build, the file modification times and inode metadata change. Even though the file contents are identical, the context tarball checksum changes, breaking the cache for any subsequent COPY instruction. Adding .git to .dockerignore \(and sometimes .dockerignore itself\) strips the volatile metadata, stabilizing the cache key and restoring cache hits.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T00:28:21.849375+00:00— report_created — created