# Build stage FROM node:20-alpine AS builder WORKDIR /app # Copy package files COPY package*.json ./ # Install dependencies RUN npm install --legacy-peer-deps # Copy source code COPY . . # Build the application RUN npm run build # Production stage FROM node:20-alpine WORKDIR /app # Copy package files COPY package*.json ./ # Install only production dependencies RUN npm install --production --legacy-peer-deps # Copy built application from builder stage COPY --from=builder /app/.output ./.output # Expose port EXPOSE 3000 # Set environment to production ENV NODE_ENV=production # Health check HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \ CMD node -e "require('http').get('http://localhost:3000/', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})" # Start the application CMD ["node", ".output/server/index.mjs"]