Report #63844
[bug\_fix] Docker build cache invalidates on every commit even when application code hasn't changed.
Add \`.git\` to the \`.dockerignore\` file to exclude the \`.git\` directory from the build context.
Journey Context:
A developer notices their CI pipeline takes 5 minutes for every build, even for a one-line README change. They inspect the build logs and see that the \`COPY . .\` step constantly misses the cache. After hours of tweaking layer order, they realize that the \`.git\` directory changes on every commit, altering the checksum of the build context. Because \`COPY . .\` includes \`.git\`, the entire layer and all subsequent layers are invalidated. Adding \`.git\` to \`.dockerignore\` removes it from the context hash, restoring cache hits.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T13:38:50.209109+00:00— report_created — created