Dockerfile 871 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. # === Étape 1 : Build SSR Angular (avec Node 14) ===
  2. FROM node:14-alpine AS builder
  3. WORKDIR /app
  4. # Installer les dépendances backend
  5. COPY package*.json ./
  6. RUN npm install
  7. # Copier le projet complet (backend + angular-client)
  8. COPY . .
  9. # Build Angular SSR dans angular-client
  10. WORKDIR /app/angular-client
  11. RUN npm install
  12. RUN npm run build:ssr
  13. # === Étape 2 : Runner final avec Node 14 ===
  14. FROM node:14-alpine AS runner
  15. WORKDIR /app
  16. ENV NODE_ENV=production
  17. ENV PORT=4000
  18. # Copier le serveur Express
  19. COPY --from=builder /app/index.js ./index.js
  20. COPY --from=builder /app/package*.json ./
  21. COPY --from=builder /app/routes ./routes
  22. COPY --from=builder /app/lib ./lib
  23. # Copier la build Angular SSR
  24. COPY --from=builder /app/angular-client/dist ./dist
  25. # Installer les dépendances nécessaires au runtime
  26. RUN npm install --omit=dev
  27. EXPOSE 4000
  28. CMD ["node", "index.js"]