FROM node:14-bullseye-slim AS builder WORKDIR /workspace # Install build tools RUN apt-get update \ && apt-get install -y --no-install-recommends python3 make g++ ca-certificates \ && rm -rf /var/lib/apt/lists/* # Install pnpm matching the repository workflow RUN npm i -g pnpm@7.9.5 # Copy the repository into the image COPY . . # Build the wujie-core package (library) WORKDIR /workspace/packages/wujie-core RUN npm i RUN npm run lib # Stage 2: runtime server to serve built artifacts FROM node:14-bullseye-slim WORKDIR /app # Copy built library from builder stage COPY --from=builder /workspace/packages/wujie-core/lib /dist # Install a tiny static server to serve dist RUN npm i -g http-server EXPOSE 8080 CMD ["http-server", "/dist", "-p", "8080"]
FROM node:14-bullseye-slim AS builder WORKDIR /workspace RUN apt-get update \ && apt-get install -y --no-install-recommends python3 make g++ ca-certificates \ && rm -rf /var/lib/apt/lists/* RUN npm i -g pnpm@7.9.5 COPY . . RUN pnpm install --frozen-lockfile # Build the wujie-core library RUN pnpm --filter wujie-core run lib # Stage 2: runtime server to serve built artifacts FROM node:14-bullseye-slim WORKDIR /app # Copy built library from builder stage COPY --from=builder /workspace/packages/wujie-core/lib /dist # Install a tiny static server to serve dist RUN npm i -g http-server EXPOSE 8080 CMD ["http-server", "/dist", "-p", "8080"]
- Error: ERROR: failed to calculate checksum of ref mqpnlh3la2bzegxdamkvycc7g::k9kw9jjw514e0zorzvrjesdsp: "/workspace/packages/wujie-core/lib": not found - Exit code: not shown in the provided log - Failing step: - stage-1 [3/4] COPY --from=builder /workspace/packages/wujie-core/lib /dist - Context: This copy from the builder stage to stage-1 is attempting to move the built library directory into the final image, but the source path does not exist - Missing files: - Source path not found: /workspace/packages/wujie-core/lib - Environment details: - Base image: node:14-bullseye-slim - PNPM update available: Update available! 7.9.5 → 10.32.1 (version recommendation, not an error) - No projects matched the filters in "/workspace" for the builder step [builder 7/7], explaining why /workspace/packages/wujie-core/lib wasn’t produced - Root cause: - The builder step [builder 7/7] attempted to run pnpm with a filter but found no matching projects, so the lib build for wujie-core did not occur. Consequently, /workspace/packages/wujie-core/lib does not exist, causing the COPY to fail with a not-found error - Quick fix suggestions: - Ensure the wujie-core project matches the filter used in pnpm --filter wujie-core run lib, or modify the command to target the correct workspace - Confirm that the build step actually produces /workspace/packages/wujie-core/lib before the copy (adjust build scripts or workspace config if needed) - Optionally adjust the Dockerfile to copy only existing artifacts or to fail earlier with a clearer message if the build step didn’t produce the expected output
FROM node:14-bullseye-slim AS builder WORKDIR /workspace # Install build tools RUN apt-get update \ && apt-get install -y --no-install-recommends python3 make g++ ca-certificates \ && rm -rf /var/lib/apt/lists/* # Install pnpm matching the repository workflow RUN npm i -g pnpm@7.9.5 # Copy the repository into the image COPY . . # Install dependencies for the whole workspace RUN pnpm install --frozen-lockfile # Build the wujie-core library WORKDIR /workspace/packages/wujie-core RUN pnpm i RUN pnpm run lib # Stage 2: runtime server to serve built artifacts FROM node:14-bullseye-slim WORKDIR /app # Copy built library from builder stage COPY --from=builder /workspace/packages/wujie-core/lib /dist # Install a tiny static server to serve dist RUN npm i -g http-server EXPOSE 8080 CMD ["http-server", "/dist", "-p", "8080"]
Concerns: Base image node:14-bullseye-slim is somewhat old; consider upgrading to a supported LTS (e.g., node:18 or node:20)., COPY . . in the builder stage may inadvertently include sensitive files; ensure a proper .dockerignore to exclude secrets, large artifacts, and local environment configs., pnpm is run at the repository root and again in a subpackage; could be optimized for caching/build time, and verify that the workspace configuration aligns with the monorepo setup. Smoke [PASS]: test -d /dist Smoke [PASS]: ls -la /dist | head -n 1