Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
dist
.git
Dockerfile
.dockerignore
34 changes: 34 additions & 0 deletions .github/workflows/deploy-front.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Deploy Frontend to Staging or Prod

on:
push:
branches:
# - staging
# - main
# - devops/ci # FOR TESTS
- no_branch
# pull_request:
# branches:
# - staging
# - main

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}

- name: Build and Push Docker Image for Frontend
run: |
docker build -t ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_APP }}:${{ github.sha }} -f ./Dockerfile .
docker push ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_APP }}:${{ github.sha }}
docker tag ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_APP }}:${{ github.sha }} ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_APP }}:latest
docker push ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_APP }}:latest
37 changes: 37 additions & 0 deletions .github/workflows/test-frontend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Test Frontend

on:
push:
branches:
- develop
- staging
- main
- devops/ci # FOR TESTS
pull_request:
branches:
- develop
- staging
- main

jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x]

Comment on lines +22 to +23
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
node-version: [16.x]
node-version: [18.x, 20.x]

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}

- name: Install dependencies
run: npm install

- name: Run lint
run: npm run lint
23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Étape 1 : Construction avec Vite
FROM node:22.8.0-alpine AS build

WORKDIR /usr/src/app

COPY package*.json ./
RUN npm install

COPY . .

RUN npm run build

# Utiliser nginx pour servir le contenu en production
FROM nginx:alpine
COPY --from=build /usr/src/app/build /usr/share/nginx/html

# Copier la configuration par défaut de Nginx
COPY nginx.conf /etc/nginx/nginx.conf

EXPOSE 80

# Démarrage de Nginx en mode "daemon off"
CMD ["nginx", "-g", "daemon off;"]
19 changes: 19 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
server {
listen 80;

server_name localhost;

root /usr/share/nginx/html;
index index.html;

location / {
try_files $uri /index.html;
}

error_page 404 /index.html;

location ~* \.(js|css|png|jpg|jpeg|gif|ico|woff|woff2|ttf|svg)$ {
expires 30d;
access_log off;
}
}
Loading