Report #94318
[bug\_fix] COPY --from=builder failed: file not found
Verify the exact path where the previous build stage wrote the file, and use explicit stage names instead of integers. The root cause is that paths in \`COPY --from\` are absolute inside the previous stage's filesystem; if the build step failed silently or wrote to a different path \(like \`/app/dist\` instead of \`/dist\`\), the copy fails.
Journey Context:
A developer sets up a multi-stage build. They add \`COPY --from=0 /dist /app/dist\` to copy the compiled assets. The build fails with 'file not found'. They are confused because running the build command locally produces the files. They inspect the Dockerfile and realize the local build command output the files to \`/app/dist\`, but they specified \`/dist\` in the \`COPY\` command. Furthermore, because they used \`--from=0\`, adding a new stage earlier in the Dockerfile shifted the indices, making the target stage actually \`1\`. They fix it by naming the stage \`FROM node:18 AS builder\` and using \`COPY --from=builder /app/dist /app/dist\`, ensuring the path exactly matches the working directory of the \`RUN\` command in the builder stage.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T16:53:57.494618+00:00— report_created — created