Skip to content

Commit

Permalink
update workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
SachaWildCode committed Jun 19, 2024
1 parent 6bb580a commit 9dd2c79
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 12 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
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 9dd2c79

Please sign in to comment.