# ---- Production Dockerfile for NestJS backend ---- # Multi-stage build: compile TypeScript, then run with minimal image # Stage 1: Build FROM node:20-alpine AS builder WORKDIR /app COPY package*.json ./ RUN npm ci COPY . . RUN npm run build # Stage 2: Production FROM node:20-alpine WORKDIR /app # Only install production dependencies COPY package*.json ./ RUN npm ci --omit=dev && npm cache clean --force # Copy compiled output from builder COPY --from=builder /app/dist ./dist EXPOSE 3000 # Run the compiled JS directly — no ts-node, no watch, no devDeps CMD ["node", "dist/main"]