feat: add multi-stage Dockerfile for production NestJS deployment

This commit is contained in:
Hamza-Ayed
2026-07-18 18:29:16 +03:00
parent a90b31c3ad
commit 12d576a5bc
+36
View File
@@ -0,0 +1,36 @@
FROM node:22-alpine AS builder
WORKDIR /app
# Copy package files
COPY package*.json ./
# Install dependencies
RUN npm install
# Copy source code
COPY . .
# Build the NestJS application
RUN npm run build
# ---
FROM node:22-alpine AS runtime
WORKDIR /app
ENV NODE_ENV=production
# Copy package files for production install
COPY package*.json ./
# Install only production dependencies
RUN npm install --omit=dev
# Copy compiled code from builder
COPY --from=builder /app/dist ./dist
EXPOSE 4020
CMD ["node", "dist/main.js"]