Report #95547
[bug\_fix] Slow builds; dependency installation layer is rebuilt on every source code change.
Copy only the dependency manifests \(e.g., package.json, requirements.txt\) first, run the dependency installation, and then copy the rest of the source code.
Journey Context:
A developer notices their CI pipeline takes 10 minutes on every commit because it reinstalls thousands of dependencies. The Dockerfile has \`COPY . .\` followed by \`RUN pip install\`. They assume Docker caching is broken. They add \`--no-cache\` to test, then remove it, but it still rebuilds. They finally understand Docker's layer caching mechanism: instructions are evaluated sequentially. Because \`COPY . .\` includes all source code, any tiny text change in a source file invalidates the \`COPY\` layer. Since \`RUN pip install\` comes after, its cache is also invalidated. The fix is to reorder the instructions: copy only \`requirements.txt\`, run \`pip install\`, and then \`COPY . .\`. This isolates the expensive dependency layer from source code changes.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T18:57:15.185992+00:00— report_created — created