Skip to content
This repository has been archived by the owner on Apr 6, 2024. It is now read-only.

Commit

Permalink
Merge pull request #41 from louis-antoine-etsmtl/serveur-frontend
Browse files Browse the repository at this point in the history
Setup docker et pipeline
  • Loading branch information
samyw10 authored Mar 25, 2024
2 parents fd1305e + a553ce4 commit 6b95303
Show file tree
Hide file tree
Showing 6 changed files with 814 additions and 29 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/deploy-frontend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Deploy Frontend

on:
push:
branches:
- serveur-frontend

jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push Docker image for Frontend
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_REPO }}:latest

36 changes: 36 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Étape de build
FROM node:18 AS build

# Définir le répertoire de travail dans le conteneur
WORKDIR /app

# Copier les fichiers 'package.json' et 'package-lock.json' (ou 'yarn.lock')
COPY package*.json ./

# Installer les dépendances du projet
RUN npm install

# Copier le reste des fichiers du projet dans le conteneur
COPY . .

# Créer le fichier .env avec les variables d'environnement nécessaires
RUN echo "VITE_BACKEND_URL=http://10.196.10.69:4400/\nVITE_AZURE_BACKEND_URL=http://10.196.10.69:4400" > .env

# Exécuter le script de build du projet
RUN npm run build

# Étape de serveur NGINX pour servir l'application
FROM nginx:stable-alpine as serve

# Copier les fichiers statiques depuis l'étape de build
COPY --from=build /app/dist /usr/share/nginx/html

# Copier la configuration Nginx personnalisée dans le conteneur
COPY ./nginx/default.conf /etc/nginx/conf.d/default.conf

# Exposer le port 80
EXPOSE 80

# Lancer NGINX
CMD ["nginx", "-g", "daemon off;"]

3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# To run this project
# To run this project
# test demo

First install with: `npm install`

Expand Down
10 changes: 10 additions & 0 deletions nginx/default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
server {
listen 80;

location / {
root /usr/share/nginx/html;
index index.html;
try_files $uri $uri/ /index.html;
}
}

Loading

0 comments on commit 6b95303

Please sign in to comment.