Dockerfile 914 B

1234567891011121314151617181920212223242526272829303132
  1. # ========= ÉTAPE 1 : COMPILATION ANGULAR SSR =========
  2. FROM node:14-alpine AS builder
  3. WORKDIR /app
  4. # Copier les dépendances Angular et installer
  5. COPY angular-client/package*.json ./angular-client/
  6. RUN cd angular-client && npm install
  7. # Copier le code source et compiler l'application
  8. COPY angular-client ./angular-client
  9. RUN cd angular-client && npm run build:ssr
  10. # ========= ÉTAPE 2 : IMAGE FINALE =========
  11. FROM node:14-alpine
  12. WORKDIR /app
  13. # Installer les outils de compilation
  14. RUN apk add --no-cache make gcc g++ python3
  15. # Copier le backend Express
  16. COPY express-server .
  17. # Copier les fichiers compilés d'Angular SSR (depuis le stage builder)
  18. COPY --from=builder /app/angular-client/dist ./dist
  19. # Installer les dépendances avec nettoyage des outils
  20. RUN npm install --omit=dev && \
  21. apk del make gcc g++ python3
  22. # Exposition du port et commande de démarrage
  23. EXPOSE 4000
  24. CMD ["node", "index.js"]