# ── Build stage ────────────────────────────────────────────────────────────── FROM node:22-slim AS builder RUN apt-get update && apt-get install -y --no-install-recommends \ python3 make g++ \ && rm -rf /var/lib/apt/lists/* WORKDIR /app COPY package*.json ./ RUN npm ci COPY . . RUN npm run build # Prune dev dependencies before copying to runtime stage RUN npm prune --omit=dev # ── Runtime stage ───────────────────────────────────────────────────────────── FROM node:22-slim WORKDIR /app COPY --from=builder /app/dist ./dist COPY --from=builder /app/node_modules ./node_modules COPY --from=builder /app/package.json ./package.json # PORT is injected by Coolify — default to 3000 as fallback ENV NODE_ENV=production \ PORT=3000 \ HOST=0.0.0.0 EXPOSE 3000 CMD ["node", "dist/index.js"]