# ============================================================================= # Admin Service Dockerfile # ============================================================================= # Build stage FROM node:20-alpine AS builder WORKDIR /app # Copy package files COPY package*.json ./ COPY tsconfig*.json ./ COPY nest-cli.json ./ # Copy Prisma schema if exists COPY prisma ./prisma/ 2>/dev/null || true # Install dependencies RUN npm ci # Generate Prisma client if schema exists RUN if [ -f "prisma/schema.prisma" ]; then npx prisma generate; fi # Copy source code COPY src ./src # Build TypeScript RUN npm run build # Production stage FROM node:20-alpine WORKDIR /app # Install production dependencies only COPY package*.json ./ RUN npm ci --only=production # Copy Prisma schema and generate client if exists COPY prisma ./prisma/ 2>/dev/null || true RUN if [ -f "prisma/schema.prisma" ]; then npx prisma generate; fi # Copy built files COPY --from=builder /app/dist ./dist # Create non-root user RUN addgroup -g 1001 -S nodejs && \ adduser -S nestjs -u 1001 # Switch to non-root user USER nestjs # Expose port EXPOSE 3010 # Health check HEALTHCHECK --interval=30s --timeout=3s --start-period=40s --retries=3 \ CMD wget -q --spider http://localhost:3010/health || exit 1 # Start service CMD ["node", "dist/main.js"]