# ---------- Base build stage ---------- FROM node:20-alpine AS builder # Enable pnpm RUN corepack enable WORKDIR /app # Copy dependency manifests COPY package.json pnpm-lock.yaml ./ # Install dependencies with frozen lockfile for reproducible builds RUN pnpm install --frozen-lockfile # Copy the rest of the app COPY . . # Build the Next.js app RUN pnpm run build # ---------- Production runtime stage ---------- FROM node:20-alpine AS runner WORKDIR /app ENV NODE_ENV=production ENV NEXT_TELEMETRY_DISABLED=1 ENV PORT=3005 # Copy only necessary files from builder COPY --from=builder /app/package.json ./ COPY --from=builder /app/pnpm-lock.yaml ./ COPY --from=builder /app/node_modules ./node_modules COPY --from=builder /app/.next ./.next COPY --from=builder /app/public ./public # Optional: drop build-time dependencies like devDeps # (pnpm install --prod is not needed because builder already prunes) EXPOSE 3005 # Start the production server CMD ["pnpm", "start"]