Dockerfile 1018 B

1234567891011121314151617181920212223242526272829303132333435
  1. # ==========================
  2. # 1. BUILD ANGULAR SSR
  3. # ==========================
  4. FROM node:14-alpine AS builder
  5. WORKDIR /app
  6. # Installer les dépendances Angular
  7. COPY angular-client/package*.json ./angular-client/
  8. RUN cd angular-client && npm install
  9. # Copier le code source Angular et builder l'app SSR
  10. COPY angular-client ./angular-client
  11. RUN cd angular-client && npm run build:ssr
  12. # ==========================
  13. # 2. IMAGE DE PRODUCTION SSR
  14. # ==========================
  15. FROM node:14-alpine
  16. WORKDIR /app
  17. # Installer les outils de build nécessaires aux modules natifs si besoin
  18. #RUN apk add --no-cache make gcc g++ python3
  19. # Copier uniquement les fichiers nécessaires du serveur SSR généré par Angular Universal
  20. COPY angular-client/package*.json ./
  21. COPY --from=builder /app/angular-client/dist ./dist
  22. # Installer les dépendances de production
  23. RUN npm install --omit=dev
  24. # Nettoyer les outils de build pour alléger l'image
  25. #RUN apk del make gcc g++ python3
  26. EXPOSE 4000
  27. CMD ["node", "dist/server/main.js"]