# Build stage: install dependencies and build the monorepo from source FROM node:20-bullseye-slim AS build WORKDIR /workspace # Install PNPM (the repository uses PNPM workspaces/scripts) RUN corepack enable && npm i -g pnpm@9.2.0 # Copy the entire repository and install/build COPY . . RUN pnpm install RUN pnpm build # Runtime stage: include built artifacts FROM node:20-slim AS runtime WORKDIR /workspace # Copy the built artifacts from the build stage COPY --from=build /workspace /workspace # Default to a shell so users can inspect or run commands CMD ["bash"]
- Failing command/step: - Build step: [build 3/6] RUN corepack enable && npm i -g pnpm@9.2.0 - Dockerfile:7 - Exact error message and exit code: - "npm error code EEXIST" - "npm error path /usr/local/bin/pnpm" - "npm error EEXIST: file already exists" - "npm error File exists: /usr/local/bin/pnpm" - "npm error Remove the existing file and try again, or run npm with --force to overwrite files recklessly." - "A complete log of this run can be found in: /root/.npm/_logs/2026-03-24T10_38_55_135Z-debug-0.log" - Exit code: 1 - The summary line: "ERROR: failed to solve: process \"/bin/sh -c corepack enable && npm i -g pnpm@9.2.0\" did not complete successfully: exit code: 1" - Missing packages or files mentioned: - Conflict installing pnpm: /usr/local/bin/pnpm already exists (File exists: /usr/local/bin/pnpm). No missing package, just a pre-existing file causing EEXIST. - Version mismatch / related notes: - "New major version of npm available! 10.8.2 -> 11.12.0" (npm notice) - Changelog/update hint: "To update run: npm install -g npm@11.12.0" - Additional context: - The error suggests removing the existing /usr/local/bin/pnpm or forcing the install (npm i -g pnpm@9.2.0 --force) to proceed.
# Build stage: install dependencies and build the monorepo from source FROM node:20-bullseye-slim AS build WORKDIR /workspace # Use Corepack to manage the specified PNPM version RUN corepack enable && corepack prepare pnpm@9.2.0 --activate # Copy the repository and install/build COPY . . RUN pnpm install RUN pnpm build # Runtime stage: include built artifacts FROM node:20-slim AS runtime WORKDIR /workspace # Copy the built artifacts from the build stage COPY --from=build /workspace /workspace # Default to a shell so users can inspect or run commands CMD ["bash"]
Concerns: The runtime image uses CMD ["bash"] by default; this is not a real startup command and may not be suitable for production use without overriding the entrypoint to actually run the app., COPY --from=build /workspace /workspace copies the entire workspace (including dev dependencies/build artifacts) into the runtime image, which can bloat the image. Consider copying only the built output (e.g., /workspace/dist or /workspace/build) and runtime dependencies. Smoke [PASS]: node -v Smoke [PASS]: ls -la /workspace | head -n 20 Smoke [PASS]: if [ -d /workspace/dist ]; then echo 'dist exists'; elif [ -d /workspace/build ]; then echo 'build exists'; else echo 'no common build/output dir'; fi