Skip to content

Commit

Permalink
Merge branch 'main' of github.com:SachaWildCode/Projet-POEC into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
SachaWildCode committed Jun 19, 2024
2 parents c976cb7 + e0851bb commit 2bf3c68
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 15 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: CI/CD Pipeline

on:
push:
branches:
- main

jobs:
build-and-deploy:
runs-on: ubuntu-latest

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

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

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

- name: Build and push Docker image
run: |
docker build -t sachawildcode/projet-poec:latest .
docker push sachawildcode/projet-poec:latest
- name: Deploy to server
uses: appleboy/ssh-action@v0.1.3
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
port: ${{ secrets.SSH_PORT }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
passphrase: ${{ secrets.SSH_PASSPHRASE }}
script: |
docker pull sachawildcode/projet-poec:latest &&
docker-compose down &&
docker-compose up -d
10 changes: 8 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,16 @@ RUN npm install -g pnpm && \
FROM nginx:stable

COPY --from=build-stage /app/dist/PROJET-POEC/browser /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY nginx.conf /etc/nginx/nginx.conf

# Create a non-root user and use it
RUN adduser -D -H -s /bin/bash nginxuser
RUN groupadd -r nginxuser && useradd -r -g nginxuser nginxuser

# Create necessary directories and set permissions
RUN mkdir -p /var/cache/nginx/client_temp && \
chown -R nginxuser:nginxuser /var/cache/nginx

# Switch to the new user
USER nginxuser

EXPOSE 80
Expand Down
4 changes: 1 addition & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ version: '3.8'

services:
app:
build:
context: .
dockerfile: Dockerfile
image: sachawildcode/projet-poec:latest
ports:
- '80:80'
33 changes: 23 additions & 10 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -1,19 +1,32 @@
server {
listen 80;
server_name localhost;
# nginx.conf
user nginxuser;
pid /var/cache/nginx/nginx.pid;

events {
worker_connections 1024;
}

http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

sendfile on;
keepalive_timeout 65;

server {
listen 80;
server_name localhost;


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

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}

location /health {
return 200;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
}

0 comments on commit 2bf3c68

Please sign in to comment.