# Build stage
FROM node:20-slim AS builder
WORKDIR /app
# Copy package files
COPY package*.json ./
# Install dependencies
RUN npm ci
# Copy source code
COPY . .
# Build TypeScript code
RUN npm run build
# Production stage
FROM node:20-slim
WORKDIR /app
# Copy package files
COPY package*.json ./
# Install production dependencies only
RUN npm ci --production
# Copy built files from builder stage
COPY --from=builder /app/dist ./dist
# Set environment variables
ENV NODE_ENV=production
ENV PORT=3000
# Expose the port the app runs on
EXPOSE 3000
# Start the application
CMD ["node", "dist/server.js"]