# Backend Dockerfile (Coolify Optimized) FROM node:20-alpine AS builder WORKDIR /app # Copy package files COPY package*.json ./ # Install dependencies RUN npm ci # Copy source code COPY . . # Build TypeScript RUN npm run build # Production stage FROM node:20-alpine WORKDIR /app # Install wget for healthcheck RUN apk add --no-cache wget # Copy package files and install production deps only COPY package*.json ./ RUN npm ci --only=production # Copy built code COPY --from=builder /app/dist ./dist # Create non-root user for security RUN addgroup -g 1001 -S nodejs && \ adduser -S nodejs -u 1001 USER nodejs EXPOSE 3001 HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \ CMD wget -q --spider http://localhost:3001/health || exit 1 CMD ["node", "dist/index.js"]