Report #53834
[bug\_fix] Package installation layer \(e.g., npm install, pip install\) is never cached and re-runs on every build, drastically increasing build times
Copy only the dependency manifest files \(e.g., package.json, requirements.txt\) and run the installation before copying the rest of the application source code.
Journey Context:
A developer notices Docker builds take over 5 minutes every time. They check the build output and see that the RUN npm install step never shows CACHED. They examine the Dockerfile and see COPY . . immediately followed by RUN npm install. Because any change to any source file invalidates the COPY . . layer, all subsequent layers, including the expensive installation step, must be rebuilt. By splitting the copy—first copying only package.json and package-lock.json, running npm install, and then copying the rest of the code—the dependency layer remains cached as long as the lockfile doesn't change.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T20:51:28.042196+00:00— report_created — created