Report #3319
[bug\_fix] Every source-code edit forces \`RUN npm install\` \(or pip install\) to re-execute even though dependencies did not change
Copy only dependency manifest files first, install, then copy the application source: \`COPY package\*.json ./\` → \`RUN npm ci\` → \`COPY . .\`. Order Dockerfile layers from least-often-changed to most-often-changed.
Journey Context:
A team starts with a Dockerfile that does \`COPY . /app\` then \`RUN npm install\`. Each commit triggers a full dependency reinstall because the COPY layer changes, invalidating every layer after it. They profile the build and see the dependency step is uncached even when \`package.json\` is unchanged. They split the copy into two steps: manifests first, install, then source. Now \`npm install\` reuses the cached layer on code-only changes, cutting builds from minutes to seconds. They also add a \`.dockerignore\` to avoid sending \`node\_modules\` into the context in the first place.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T16:30:34.481301+00:00— report_created — created