|
@@ -1,32 +1,35 @@
|
|
|
-# ========= ÉTAPE 1 : COMPILATION ANGULAR SSR =========
|
|
|
|
|
|
|
+# ==========================
|
|
|
|
|
+# 1. BUILD ANGULAR SSR
|
|
|
|
|
+# ==========================
|
|
|
FROM node:14-alpine AS builder
|
|
FROM node:14-alpine AS builder
|
|
|
WORKDIR /app
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
-# Copier les dépendances Angular et installer
|
|
|
|
|
|
|
+# Installer les dépendances Angular
|
|
|
COPY angular-client/package*.json ./angular-client/
|
|
COPY angular-client/package*.json ./angular-client/
|
|
|
RUN cd angular-client && npm install
|
|
RUN cd angular-client && npm install
|
|
|
|
|
|
|
|
-# Copier le code source et compiler l'application
|
|
|
|
|
|
|
+# Copier le code source Angular et builder l'app SSR
|
|
|
COPY angular-client ./angular-client
|
|
COPY angular-client ./angular-client
|
|
|
RUN cd angular-client && npm run build:ssr
|
|
RUN cd angular-client && npm run build:ssr
|
|
|
|
|
|
|
|
-# ========= ÉTAPE 2 : IMAGE FINALE =========
|
|
|
|
|
|
|
+# ==========================
|
|
|
|
|
+# 2. IMAGE DE PRODUCTION SSR
|
|
|
|
|
+# ==========================
|
|
|
FROM node:14-alpine
|
|
FROM node:14-alpine
|
|
|
WORKDIR /app
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
-# Installer les outils de compilation
|
|
|
|
|
-RUN apk add --no-cache make gcc g++ python3
|
|
|
|
|
|
|
+# Installer les outils de build nécessaires aux modules natifs si besoin
|
|
|
|
|
+#RUN apk add --no-cache make gcc g++ python3
|
|
|
|
|
|
|
|
-# Copier le backend Express
|
|
|
|
|
-COPY express-server .
|
|
|
|
|
-
|
|
|
|
|
-# Copier les fichiers compilés d'Angular SSR (depuis le stage builder)
|
|
|
|
|
|
|
+# Copier uniquement les fichiers nécessaires du serveur SSR généré par Angular Universal
|
|
|
|
|
+COPY angular-client/package*.json ./
|
|
|
COPY --from=builder /app/angular-client/dist ./dist
|
|
COPY --from=builder /app/angular-client/dist ./dist
|
|
|
|
|
|
|
|
-# Installer les dépendances avec nettoyage des outils
|
|
|
|
|
-RUN npm install --omit=dev && \
|
|
|
|
|
- apk del make gcc g++ python3
|
|
|
|
|
|
|
+# Installer les dépendances de production
|
|
|
|
|
+RUN npm install --omit=dev
|
|
|
|
|
+
|
|
|
|
|
+# Nettoyer les outils de build pour alléger l'image
|
|
|
|
|
+#RUN apk del make gcc g++ python3
|
|
|
|
|
|
|
|
-# Exposition du port et commande de démarrage
|
|
|
|
|
EXPOSE 4000
|
|
EXPOSE 4000
|
|
|
-CMD ["node", "index.js"]
|
|
|
|
|
|
|
+CMD ["node", "dist/server/main.js"]
|