This commit is contained in:
53
Dockerfile
53
Dockerfile
@@ -1,26 +1,41 @@
|
||||
FROM nginx:latest as build
|
||||
# ==============================
|
||||
# 1️⃣ Build Angular (Node)
|
||||
# ==============================
|
||||
FROM node:18-alpine AS build
|
||||
|
||||
## Replace the default nginx index page with our Angular app
|
||||
COPY ./.htaccess /usr/share/nginx/html
|
||||
WORKDIR /app
|
||||
|
||||
COPY dist/infocad-back-office /usr/share/nginx/html
|
||||
# Copier uniquement les fichiers nécessaires pour optimiser le cache
|
||||
COPY package*.json ./
|
||||
|
||||
COPY ./nginx.conf /etc/nginx/nginx.conf
|
||||
# Installer les dépendances
|
||||
# RUN npm install
|
||||
RUN npm ci --legacy-peer-deps
|
||||
|
||||
# Copier le reste du projet
|
||||
COPY . .
|
||||
|
||||
# Build Angular (production)
|
||||
# RUN npm run build -- --configuration production
|
||||
RUN node --max_old_space_size=4096 ./node_modules/@angular/cli/bin/ng build --configuration production
|
||||
|
||||
|
||||
# ==============================
|
||||
# 2️⃣ Serveur Nginx
|
||||
# ==============================
|
||||
FROM nginx:latest
|
||||
|
||||
# Supprimer config par défaut
|
||||
RUN rm -rf /usr/share/nginx/html/*
|
||||
|
||||
COPY --from=build /app/dist/infocad-back-office/ /usr/share/nginx/html
|
||||
|
||||
COPY --from=build /app/nginx.conf /etc/nginx/conf.d/default.conf
|
||||
|
||||
COPY --from=build /app/.htaccess /usr/share/nginx/html
|
||||
|
||||
RUN chmod -R 777 /usr/share/nginx/html
|
||||
|
||||
CMD ["/bin/bash", "-c", \
|
||||
"echo API_URL=[$API_URL], && \
|
||||
sed -i s#MY_APP_API_URL#$API_URL#g /usr/share/nginx/html/main.*.js && \
|
||||
nginx -g 'daemon off;'"]
|
||||
EXPOSE 80
|
||||
|
||||
#from my MAC
|
||||
#docker build --platform linux/amd64 -t front-fiscad . ou docker build -t front-fiscad .
|
||||
#docker save -o ./front-fiscad.tar front-fiscad
|
||||
|
||||
#docker load -i front-fiscad.tar
|
||||
#docker run -d -p 8081:80 -e API_URL=http://localhost:9090/ front-fiscad
|
||||
#docker ps
|
||||
#docker stop CONTAINER_ID ==> docker ps (pour trouver le CONTAINER_ID)
|
||||
#docker images -a
|
||||
#docker rmi IMAGE_ID (supprimer une image) ==> docker ps (pour trouver le IMAGE_ID)
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
Reference in New Issue
Block a user