Dockerfile52 lines · 1278 chars # 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"]