# ============================================================================= # MiChangarrito - WhatsApp Service Dockerfile # ============================================================================= # Multi-stage build for NestJS WhatsApp integration # Puerto: 3143 # ============================================================================= # Build stage FROM node:20-alpine AS builder WORKDIR /app # Copy package files COPY package*.json ./ # Install dependencies RUN npm ci # Copy source code COPY . . # Build application RUN npm run build # Production stage FROM node:20-alpine AS production # Labels LABEL maintainer="ISEM" LABEL description="MiChangarrito WhatsApp Service" LABEL version="1.0.0" WORKDIR /app # Copy package files COPY package*.json ./ # Install only production dependencies RUN npm ci --only=production && npm cache clean --force # Copy built application COPY --from=builder /app/dist ./dist # Create non-root user RUN addgroup -g 1001 -S nodejs && \ adduser -S nestjs -u 1001 -G nodejs && \ chown -R nestjs:nodejs /app USER nestjs # Environment ENV NODE_ENV=production ENV PORT=3143 # Expose port EXPOSE 3143 # Health check HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \ CMD wget --no-verbose --tries=1 --spider http://localhost:3143/health || exit 1 # Start application CMD ["node", "dist/main"] # Development stage FROM node:20-alpine AS development WORKDIR /app # Copy package files COPY package*.json ./ # Install all dependencies RUN npm ci # Copy source code COPY . . # Environment ENV NODE_ENV=development ENV PORT=3143 # Expose port EXPOSE 3143 # Start in development mode CMD ["npm", "run", "start:dev"]