Report #6775
[bug\_fix] COPY failed: stat /app/dist: file does not exist \(when copying from a previous build stage\)
Ensure the path in \`COPY --from=builder /app/dist ...\` matches the actual absolute path where the artifact was created in the builder stage, accounting for WORKDIR.
Journey Context:
A developer sets up a multi-stage build. Stage 1 \(builder\) has \`WORKDIR /app\`, \`COPY . .\`, and \`RUN npm run build\` which outputs to a \`dist\` folder. Stage 2 has \`COPY --from=builder /dist /usr/share/nginx/html\`. The build fails, unable to find \`/dist\`. They try \`COPY --from=builder ./dist ...\` \(which is invalid syntax for COPY --from\), then try various relative paths, but it still fails. The rabbit hole is forgetting that \`COPY --from\` requires \*absolute\* paths from the root of the source stage's filesystem, not relative paths. Because \`WORKDIR /app\` was set in the builder stage, the \`npm run build\` command ran inside \`/app\`, creating \`/app/dist\`. The developer mistakenly thought \`COPY --from\` would respect the \`WORKDIR\` of the source stage or allow relative paths. Using the correct absolute path \`/app/dist\` resolves it because \`COPY --from\` resolves the source path strictly from the root \`/\` of the specified stage.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T00:52:29.082828+00:00— report_created — created