# Multi-stage build for production FROM node:20-alpine AS builder WORKDIR /app # Install OpenSSL for Prisma RUN apk add --no-cache openssl # Copy package files COPY package*.json ./ COPY prisma ./prisma/ # Install dependencies RUN npm ci # Generate Prisma client (dummy DATABASE_URL for build time only) RUN DATABASE_URL="postgresql://user:pass@localhost:5432/db" npx prisma generate # Copy source code COPY . . # Build the application RUN npm run build # Production stage - use Debian slim for OpenSSL compatibility FROM node:20-slim AS production WORKDIR /app # Install OpenSSL and wget for health checks RUN apt-get update && apt-get install -y --no-install-recommends \ openssl \ wget \ && rm -rf /var/lib/apt/lists/* # Copy package files and install production dependencies COPY package*.json ./ RUN npm ci --only=production # Copy Prisma files and generate client (dummy DATABASE_URL for build time only) COPY prisma ./prisma/ RUN DATABASE_URL="postgresql://user:pass@localhost:5432/db" npx prisma generate # Copy built application COPY --from=builder /app/dist ./dist # Expose port EXPOSE 3000 # Start the application CMD ["node", "dist/src/main.js"]