This commit is contained in:
25
.gitea/workflows/docker.yml
Normal file
25
.gitea/workflows/docker.yml
Normal file
@@ -0,0 +1,25 @@
|
||||
name: Angular Docker CI/CD
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
build-and-deploy:
|
||||
runs-on: self-hosted
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Build Docker image
|
||||
run: docker build -t front-fiscad .
|
||||
|
||||
- name: Stop old container
|
||||
run: |
|
||||
docker stop front-fiscad || true
|
||||
docker rmi front-fiscad || true
|
||||
|
||||
- name: Run new container
|
||||
run: |
|
||||
docker run -d -p 8383:80 --name front-fiscad front-fiscad
|
||||
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;"]
|
||||
26
DockerfileWeb
Normal file
26
DockerfileWeb
Normal file
@@ -0,0 +1,26 @@
|
||||
FROM nginx:latest as build
|
||||
|
||||
## Replace the default nginx index page with our Angular app
|
||||
COPY ./.htaccess /usr/share/nginx/html
|
||||
|
||||
COPY dist/infocad-back-office /usr/share/nginx/html
|
||||
|
||||
COPY ./nginx.conf /etc/nginx/nginx.conf
|
||||
|
||||
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;'"]
|
||||
|
||||
#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)
|
||||
@@ -4,7 +4,7 @@
|
||||
"scripts": {
|
||||
"ng": "ng",
|
||||
"start": "ng serve",
|
||||
"build": "ng build",
|
||||
"build": "ng build --configuration production",
|
||||
"watch": "ng build --watch --configuration development",
|
||||
"test": "ng test"
|
||||
},
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
export const environment = {
|
||||
expirationTime: 5000,
|
||||
production: true,
|
||||
backend: 'MY_APP_API_URL',
|
||||
//backend: 'MY_APP_API_URL',
|
||||
backend: 'https://backend.fiscad-test.novatic.org/api',
|
||||
databaseName: 'db_fiscad'
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user