Report #765
[bug\_fix] Every code change invalidates the dependency-install layer and triggers a full reinstall because \`COPY . /app\` runs before \`RUN pip install -r requirements.txt\`.
Reorder the Dockerfile to copy only dependency manifests first, install dependencies, then copy the rest of the source. For example: \`COPY requirements.txt .\` → \`RUN pip install -r requirements.txt\` → \`COPY . /app\`.
Journey Context:
A team notices that every \`git push\` rebuilds all Python dependencies even when only a comment in the application code changed. Their Dockerfile had \`COPY . /app\` followed by \`RUN pip install -r requirements.txt\`. Because the \`COPY .\` layer includes every source file, any edit invalidated every subsequent layer, including the expensive pip install. They split the copy into two steps: first the stable \`requirements.txt\`, then the install, then the mutable source. Subsequent builds reuse the dependency layer and only rebuild the final source layer.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-13T12:55:16.349626+00:00— report_created — created