# ============================================================================= # MPC Party 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 ./prisma/ # Install dependencies RUN npm ci # Generate Prisma client RUN npx prisma generate # Copy source code COPY src ./src # Build TypeScript RUN npm run build # Production stage FROM node:20-alpine WORKDIR /app # Install OpenSSL for Prisma (Alpine 3.22 uses OpenSSL 3) RUN apk add --no-cache openssl # Install production dependencies only COPY package*.json ./ RUN npm ci --only=production # Copy Prisma schema and generate client COPY prisma ./prisma/ RUN npx prisma generate # Copy built files COPY --from=builder /app/dist ./dist # Create non-root user RUN addgroup -g 1001 -S nodejs && \ adduser -S nestjs -u 1001 # Create temp directory for TSS RUN mkdir -p /tmp/tss && chown -R nestjs:nodejs /tmp/tss # Switch to non-root user USER nestjs # Expose port EXPOSE 3006 # Health check HEALTHCHECK --interval=30s --timeout=3s --start-period=40s --retries=3 \ CMD node -e "require('http').get('http://localhost:3006/api/v1/health', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})" # Start service CMD ["node", "dist/main.js"]