Report #39949
[bug\_fix] COPY failed: file not found in build context or previous stage: stat /app/dist: file does not exist
Ensure the build step in the source stage actually generates the expected output directory/file, and verify the path used in 'COPY --from=' matches the exact absolute path inside that stage's filesystem.
Journey Context:
A developer sets up a multi-stage build. The first stage runs 'npm run build', and the second stage uses 'COPY --from=builder /app/dist /usr/share/nginx/html'. The build fails, claiming '/app/dist' doesn't exist. The developer is confused because it works locally. They add a 'RUN ls -la /app' right before the failing COPY in the builder stage \(or run an intermediate container\) and discover that the 'npm run build' script failed silently or outputted to a different directory \(e.g., '/app/build' instead of '/app/dist'\). The 'COPY --from' command strictly requires the artifact to exist in the specified path of the previous stage's snapshot. Fixing the build script to output to the correct directory resolves the issue.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T21:31:38.454770+00:00— report_created — created