# Multi-stage build for smaller final image FROM node:18-alpine AS builder # Set working directory WORKDIR /app # Copy package files COPY package*.json ./ # Install all dependencies (including dev dependencies for build) RUN npm install # Copy source code COPY . . # Build TypeScript RUN npm run build # Production stage FROM node:18-alpine AS production # Install wget for health checks RUN apk add --no-cache wget # Set working directory WORKDIR /app # Copy package files COPY package*.json ./ # Install only production dependencies RUN npm install --omit=dev # Copy built files from builder stage COPY --from=builder /app/dist ./dist # Create logs directory RUN mkdir -p /app/logs # Expose the application port EXPOSE 3000 # Set environment to production ENV NODE_ENV=production # Start the application CMD ["node", "dist/index.js"]