# Multi-stage Dockerfile for building Nuxt monorepo from source
# Stage 1: builder
FROM node:22-bullseye-slim AS builder
ENV NPM_CONFIG_FUNDING=false
ENV PNPM_HOME=/pnpm
ENV PATH="$PNPM_HOME:$PATH"
# Install build tooling
RUN apt-get update -y \
&& apt-get install -y --no-install-recommends \
build-essential \
python3 \
git \
curl \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Install a specific pnpm version required by the project
RUN npm i -g pnpm@10.32.1
WORKDIR /workspace
# Copy lockfiles and workspace config first to leverage caching
COPY package.json pnpm-lock.yaml* pnpm-workspace.yaml* ./
# Install root dependencies (if a lockfile exists)
RUN if [ -f pnpm-lock.yaml ]; then pnpm install; else echo "no lockfile found"; fi
# Copy the rest of the repository and install workspace dependencies
COPY . .
RUN pnpm install
# Build the project (as per repository build workflow)
RUN pnpm build
# Stage 2: runtime
FROM node:22-bullseye-slim
WORKDIR /app
ENV NODE_ENV=production
# Minimal runtime dependencies
RUN apt-get update -y \
&& apt-get install -y --no-install-recommends ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Copy built artifacts from the builder
COPY --from=builder /workspace/packages/nuxt/dist /app/dist
COPY --from=builder /workspace/packages/nuxt/bin/nuxt.mjs /app/nuxt.mjs
# Expose HTTP port
EXPOSE 3000
# Start the Nuxt app by executing the built index module
CMD ["node", "/app/dist/index.mjs"]
# Ignore transient and build artifacts node_modules **/node_modules **/dist **/build .nuxt **/.nuxt .vite coverage .env *.log Dockerfile .dockerignore
# Ignore transient and build artifacts node_modules **/node_modules **/dist **/build .nuxt **/.nuxt .vite coverage .env *.log Dockerfile .dockerignore
Summary (concise)
- Failing step: [builder 6/9] RUN if [ -f pnpm-lock.yaml ]; then pnpm install; else echo "no lockfile found"; fi
- Exact error message and exit code:
- ENOENT: no such file or directory, open '/workspace/patches/changelogen.patch'
- pnpm: ENOENT: no such file or directory, open '/workspace/patches/changelogen.patch'
- Exit code: 254
- Evidence snippet from log:
- " ENOENT ENOENT: no such file or directory, open '/workspace/patches/changelogen.patch'"
- "pnpm: ENOENT: no such file or directory, open '/workspace/patches/changelogen.patch'"
- Missing packages/files mentioned:
- Missing file: /workspace/patches/changelogen.patch (read by pnpm during patch/hash processing)
- Version mismatch / notes:
- PNPM step runs after npm/pnpm setup; log contains: "New major version of npm available! 10.9.4 -> 11.12.0" (npm version mismatch notice)
- Base image used: node:22-bullseye-slim; later apt/pkgs install complete, but the error stems from a missing patch file rather than a dependency version conflict.# Multi-stage Dockerfile for building Nuxt monorepo from source
# Stage 1: builder
FROM node:22-bullseye-slim AS builder
ENV NPM_CONFIG_FUNDING=false
ENV PNPM_HOME=/pnpm
ENV PATH="$PNPM_HOME:$PATH"
# Install build tooling
RUN apt-get update -y \
&& apt-get install -y --no-install-recommends \
build-essential \
python3 \
git \
curl \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Install a specific pnpm version required by the project
RUN npm i -g pnpm@10.32.1
WORKDIR /workspace
# Ensure patches directory exists to satisfy pnpm's patch application when building
RUN mkdir -p /workspace/patches && echo '# placeholder patch' > /workspace/patches/changelogen.patch
# Copy lockfiles and workspace config first to leverage caching
COPY package.json pnpm-lock.yaml* pnpm-workspace.yaml* ./
# Install root dependencies (if a lockfile exists)
RUN if [ -f pnpm-lock.yaml ]; then pnpm install; else echo "no lockfile found"; fi
# Copy the rest of the repository and install workspace dependencies
COPY . .
RUN pnpm install
# Build the project (as per repository build workflow)
RUN pnpm build
# Stage 2: runtime
FROM node:22-bullseye-slim
WORKDIR /app
ENV NODE_ENV=production
# Minimal runtime dependencies
RUN apt-get update -y \
&& apt-get install -y --no-install-recommends ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Copy built artifacts from the builder
COPY --from=builder /workspace/packages/nuxt/dist /app/dist
COPY --from=builder /workspace/packages/nuxt/bin/nuxt.mjs /app/nuxt.mjs
# Expose HTTP port
EXPOSE 3000
# Start the Nuxt app by executing the built index module
CMD ["node", "/app/dist/index.mjs"]
Failing step - [builder 7/10] RUN if [ -f pnpm-lock.yaml ]; then pnpm install; else echo "no lockfile found"; fi Exact error message and exit code - 3.794 ERR_PNPM_WORKSPACE_PKG_NOT_FOUND In : "@nuxt/kit@workspace:*" is in the dependencies but no package named "@nuxt/kit" is present in the workspace - This error happened while installing a direct dependency of /workspace - Packages found in the workspace: - ... (progress lines) - ERROR: failed to build: failed to solve: process "/bin/sh -c if [ -f pnpm-lock.yaml ]; then pnpm install; else echo \"no lockfile found\"; fi" did not complete successfully: exit code: 1 Missing packages or files mentioned - Missing workspace package: @nuxt/kit (referenced as @nuxt/kit@workspace:* is in dependencies but no package named "@nuxt/kit" is present in the workspace) Version information - Base image used: node:22-bullseye-slim - PNPM version used: 10.32.1 (global install via npm i -g pnpm@10.32.1) - No explicit version mismatch information reported in the error excerpt Notes - The error occurs during workspace dependency installation (pnpm install) due to a workspace reference to @nuxt/kit that is not defined in the workspace.
# Multi-stage Dockerfile for building Nuxt monorepo from source
# Stage 1: builder
FROM node:22-bullseye-slim AS builder
ENV NPM_CONFIG_FUNDING=false
ENV PNPM_HOME=/pnpm
ENV PATH="$PNPM_HOME/bin:$PATH"
# Install build tooling
RUN apt-get update -y \
&& apt-get install -y --no-install-recommends \
build-essential \
python3 \
git \
curl \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Install a specific pnpm version required by the project
RUN npm i -g pnpm@10.32.1
WORKDIR /workspace
# Copy repository content
COPY . .
# Install workspace dependencies (pnpm will resolve local packages in the workspace)
RUN pnpm install
# Build the project (as per repository build workflow)
RUN pnpm build
# Stage 2: runtime
FROM node:22-bullseye-slim AS runtime
WORKDIR /app
ENV NODE_ENV=production
# Minimal runtime dependencies
RUN apt-get update -y \
&& apt-get install -y --no-install-recommends ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Copy built artifacts from the builder
COPY --from=builder /workspace/packages/nuxt/dist /app/dist
COPY --from=builder /workspace/packages/nuxt/bin/nuxt.mjs /app/nuxt.mjs
# Expose HTTP port
EXPOSE 3000
# Start the Nuxt app by executing the built index module
CMD ["node", "/app/dist/index.mjs"]
Concerns: The runtime copies dist and nuxt.mjs but starts with dist/index.mjs; verify Nuxt build output matches index.mjs (could be version-specific)., No non-root user specified for production security; consider adding a non-root user. Smoke [PASS]: test -f /app/dist/index.mjs Smoke [PASS]: test -f /app/nuxt.mjs Smoke [PASS]: node -v