rwadurian/backend/services/reward-service/Dockerfile

51 lines
1.0 KiB
Docker

# Build stage
FROM node:20-alpine AS builder
WORKDIR /app
# Copy package files
COPY package*.json ./
COPY prisma ./prisma/
# Install dependencies
RUN npm ci
# Copy source code
COPY . .
# Generate Prisma client (dummy DATABASE_URL for build time only)
RUN DATABASE_URL="postgresql://user:pass@localhost:5432/db" npx prisma generate
# Build the application
RUN npm run build
# Production stage
FROM node:20-alpine AS production
WORKDIR /app
# Install OpenSSL 1.1 compatibility for Prisma
RUN apk add --no-cache openssl1.1-compat
# Copy package files and install production dependencies
COPY package*.json ./
RUN npm ci --only=production
# Copy Prisma files
COPY prisma ./prisma/
# Generate Prisma client for production (dummy DATABASE_URL for build time only)
RUN DATABASE_URL="postgresql://user:pass@localhost:5432/db" npx prisma generate
# Copy built application from builder stage
COPY --from=builder /app/dist ./dist
# Set environment
ENV NODE_ENV=production
ENV PORT=3005
EXPOSE 3005
# Run the application
CMD ["node", "dist/src/main.js"]