From 679d6141c6f93a2e143d72a334bb75fcb86b407f Mon Sep 17 00:00:00 2001 From: gamvo74 Date: Wed, 25 Feb 2026 01:22:26 -0500 Subject: [PATCH] Fix API Dockerfile build stage --- apps/api/Dockerfile | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/apps/api/Dockerfile b/apps/api/Dockerfile index 8653b92..e6e845b 100644 --- a/apps/api/Dockerfile +++ b/apps/api/Dockerfile @@ -1,19 +1,36 @@ -FROM node:18-alpine +# Stage 1: Build +FROM node:22-alpine AS builder WORKDIR /app # Copy package files COPY package*.json ./ -# Install dependencies -RUN npm ci --only=production +# Install ALL dependencies including devDeps for build +RUN npm ci -# Copy application code +# Copy source code COPY . . -# Build if needed -RUN npm run build --if-present +# Generate Prisma client +RUN npx prisma generate + +# Build the NestJS application +RUN npm run build + +# Stage 2: Production +FROM node:22-alpine AS runner + +WORKDIR /app + +ENV NODE_ENV=production + +# Copy only production files +COPY --from=builder /app/package*.json ./ +COPY --from=builder /app/node_modules ./node_modules +COPY --from=builder /app/dist ./dist +COPY --from=builder /app/prisma ./prisma EXPOSE 3000 -CMD ["npm", "start"] +CMD ["node", "dist/main"]