# --- Frontend build --- FROM node:24-alpine AS frontend-builder RUN apk add --no-cache git WORKDIR /app COPY frontend/package.json frontend/package-lock.json ./ RUN npm ci COPY frontend . RUN npm run build # --- Backend build (TypeScript -> dist; bcrypt compiles natively) --- FROM node:24-alpine AS backend-builder RUN apk add --no-cache python3 make g++ WORKDIR /app COPY backend/package.json backend/package-lock.json ./ RUN npm ci COPY backend . RUN npm run build && npm prune --omit=dev # --- Runtime (compiled, production deps only) --- FROM node:24-alpine WORKDIR /app ENV NODE_ENV=production COPY --from=backend-builder /app/node_modules ./node_modules COPY --from=backend-builder /app/dist ./dist COPY --from=backend-builder /app/package.json ./package.json COPY --from=frontend-builder /app/dist ./public # Runs migrations and seeders (compiled) before starting the server. CMD ["npm", "run", "start:production"]