From 1f80c80475acfeffdcf3108fa5ead4ab1f248049 Mon Sep 17 00:00:00 2001 From: Weijun Lim Date: Sun, 16 Mar 2025 16:36:42 +0100 Subject: [PATCH 01/14] Create nginx_deploy.html --- .github/workflows/nginx_deploy.html | 49 +++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 .github/workflows/nginx_deploy.html diff --git a/.github/workflows/nginx_deploy.html b/.github/workflows/nginx_deploy.html new file mode 100644 index 0000000..521067b --- /dev/null +++ b/.github/workflows/nginx_deploy.html @@ -0,0 +1,49 @@ +name: Setup Nginx from the configuration file + +on: + push: + branches: + - main + +jobs: + deploy: + runs-on: self-hosted # Ensure your runner is self-hosted + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + # Optionally set environment variables (skip if not needed) + - name: Set up environment variables + uses: falti/dotenv-action@v1.1.4 + with: + export-variables: true + keys-case: bypass + + - name: Check environment variables + run: env + + # Copy Nginx configuration to the server + - name: Copy Nginx configuration to server + run: | + sudo cp ./nginx_securefit.conf /etc/nginx/conf.d/nginx_securefit.conf + + # Test the Nginx configuration for errors + - name: Test Nginx Configuration + run: | + sudo nginx -t + + # Reload Nginx to apply the new configuration + - name: Reload Nginx + run: | + sudo systemctl reload nginx + + # Check if Nginx is running properly + - name: Check Nginx status + run: | + sudo systemctl status nginx + + # Optionally, display the deployed Nginx configuration for debugging + - name: Show deployed Nginx configuration + run: | + cat /etc/nginx/conf.d/nginx_securefit.conf From bd2f15f5ad078dd696d140980972454f7fc28b7e Mon Sep 17 00:00:00 2001 From: Weijun Lim Date: Sun, 16 Mar 2025 16:36:58 +0100 Subject: [PATCH 02/14] Create docker_deploy.yml --- .github/workflows/docker_deploy.yml | 45 +++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 .github/workflows/docker_deploy.yml diff --git a/.github/workflows/docker_deploy.yml b/.github/workflows/docker_deploy.yml new file mode 100644 index 0000000..2aec4ad --- /dev/null +++ b/.github/workflows/docker_deploy.yml @@ -0,0 +1,45 @@ +name: Deploy to Development + +on: + push: + branches: + - main # Trigger workflow when code is pushed to the main branch + +jobs: + deploy-dev: + runs-on: self-hosted # Ensure you're using your self-hosted runner + + steps: + - name: Checkout repository + uses: actions/checkout@v3 # Checkout the latest code + + # Optionally, set environment variables (if needed) + - name: Set up environment variables + uses: falti/dotenv-action@v1.1.4 + with: + export-variables: true + keys-case: bypass + + - name: Check environment variables + run: env + + # Stop and remove existing Docker containers + - name: Stop and remove existing containers + run: | + sudo docker compose down || true + + # Pull the latest Docker images (if using remote images) + - name: Pull latest Docker images + run: sudo docker compose pull || true + + # Build Docker images if there are any changes + - name: Build Docker images + run: sudo docker compose build --no-cache + + # Start Docker containers (detached mode) + - name: Start Docker containers + run: sudo docker compose up -d + + # Verify that the containers are running + - name: Verify running Docker containers + run: sudo docker ps -a From 9e3ac9a6406955c267696092aa4e49e7d5b462fb Mon Sep 17 00:00:00 2001 From: Weijun Lim Date: Sun, 16 Mar 2025 16:37:13 +0100 Subject: [PATCH 03/14] Rename nginx_deploy.html to nginx_deploy.yml --- .github/workflows/{nginx_deploy.html => nginx_deploy.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{nginx_deploy.html => nginx_deploy.yml} (100%) diff --git a/.github/workflows/nginx_deploy.html b/.github/workflows/nginx_deploy.yml similarity index 100% rename from .github/workflows/nginx_deploy.html rename to .github/workflows/nginx_deploy.yml From 8254819d5b854d4344840ecaab0e3ddb19741a9e Mon Sep 17 00:00:00 2001 From: Weijun Lim Date: Sun, 16 Mar 2025 16:39:14 +0100 Subject: [PATCH 04/14] Create nginx_securefit.conf --- nginx_securefit.conf | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 nginx_securefit.conf diff --git a/nginx_securefit.conf b/nginx_securefit.conf new file mode 100644 index 0000000..048d7bb --- /dev/null +++ b/nginx_securefit.conf @@ -0,0 +1,35 @@ +# Production server configuration +server { + listen 80; + + location / { + proxy_pass http://0.0.0.0:8080/; # Replace with actual service URL + proxy_set_header Host $http_host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } +} + +# Development server configuration +server { + listen 8081; + + location / { + proxy_pass http://0.0.0.0:8081/; # Replace with actual service URL + proxy_set_header Host $http_host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } +} + +# Staging server configuration +server { + listen 8082; + + location / { + proxy_pass http://0.0.0.0:8082/; # Replace with actual service URL + proxy_set_header Host $http_host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } +} From c85b61dcbc101bdabc0768b1fc7dd56986d9cf25 Mon Sep 17 00:00:00 2001 From: Weijun Lim Date: Sun, 16 Mar 2025 17:01:23 +0100 Subject: [PATCH 05/14] Update nginx_deploy.yml --- .github/workflows/nginx_deploy.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/nginx_deploy.yml b/.github/workflows/nginx_deploy.yml index 521067b..764c069 100644 --- a/.github/workflows/nginx_deploy.yml +++ b/.github/workflows/nginx_deploy.yml @@ -1,9 +1,7 @@ name: Setup Nginx from the configuration file on: - push: - branches: - - main + workflow_dispatch: # Manual trigger for the workflow jobs: deploy: From 420d5dcf11c399949c448c9c13faf209bafc2faf Mon Sep 17 00:00:00 2001 From: Weijun Lim Date: Sun, 16 Mar 2025 17:02:52 +0100 Subject: [PATCH 06/14] Update nginx_deploy.yml --- .github/workflows/nginx_deploy.yml | 45 ++++++++++-------------------- 1 file changed, 14 insertions(+), 31 deletions(-) diff --git a/.github/workflows/nginx_deploy.yml b/.github/workflows/nginx_deploy.yml index 764c069..5d215a6 100644 --- a/.github/workflows/nginx_deploy.yml +++ b/.github/workflows/nginx_deploy.yml @@ -1,47 +1,30 @@ -name: Setup Nginx from the configuration file +name: Deploy Nginx Configuration on: - workflow_dispatch: # Manual trigger for the workflow + push: + branches: + - main + paths: + - "nginx/nginx.conf" # Adjust the path to your nginx.conf file in the root directory jobs: deploy: - runs-on: self-hosted # Ensure your runner is self-hosted + runs-on: self-hosted # Make sure your runner is self-hosted (or adjust this for GitHub-hosted runners) steps: - - name: Checkout repository - uses: actions/checkout@v3 + # Checkout the repository + - name: Checkout Repository + uses: actions/checkout@v4 - # Optionally set environment variables (skip if not needed) - - name: Set up environment variables - uses: falti/dotenv-action@v1.1.4 - with: - export-variables: true - keys-case: bypass - - - name: Check environment variables - run: env - - # Copy Nginx configuration to the server - - name: Copy Nginx configuration to server + # Copy Nginx Configuration to the server's /etc/nginx directory + - name: Copy Nginx Configuration run: | - sudo cp ./nginx_securefit.conf /etc/nginx/conf.d/nginx_securefit.conf - - # Test the Nginx configuration for errors + sudo cp ./nginx/nginx.conf /etc/nginx/conf.d/nginx_securefit.conf + # Test Nginx configuration to check for syntax errors - name: Test Nginx Configuration run: | sudo nginx -t - # Reload Nginx to apply the new configuration - name: Reload Nginx run: | sudo systemctl reload nginx - - # Check if Nginx is running properly - - name: Check Nginx status - run: | - sudo systemctl status nginx - - # Optionally, display the deployed Nginx configuration for debugging - - name: Show deployed Nginx configuration - run: | - cat /etc/nginx/conf.d/nginx_securefit.conf From a909d06937c6783f5be011dddf94cb0c57256c0f Mon Sep 17 00:00:00 2001 From: Weijun Lim Date: Sun, 16 Mar 2025 17:13:38 +0100 Subject: [PATCH 07/14] Update .env --- .env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env b/.env index 2462cc4..23f1356 100644 --- a/.env +++ b/.env @@ -1,4 +1,4 @@ -GROUP_ID=00 +GROUP_ID=10 DOMAIN=localhost URL_PREFIX=http:// PORT_PREFIX=2 From 8b9496361683529cc83afa1e20babfc7ed97bb54 Mon Sep 17 00:00:00 2001 From: Weijun Lim Date: Mon, 17 Mar 2025 16:52:19 +0100 Subject: [PATCH 08/14] Create code-quality-check.yml --- .github/workflows/code-quality-check.yml | 43 ++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/code-quality-check.yml diff --git a/.github/workflows/code-quality-check.yml b/.github/workflows/code-quality-check.yml new file mode 100644 index 0000000..d5939d2 --- /dev/null +++ b/.github/workflows/code-quality-check.yml @@ -0,0 +1,43 @@ +name: Code Quality Check + +on: + pull_request: + branches: [ main, dev ] + +jobs: + lint-and-test: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Set up Python for Backend + uses: actions/setup-python@v3 + with: + python-version: '3.9' + + - name: Install Backend Dependencies + run: pip install -r backend/requirements.txt + + - name: Run Backend Linting + run: flake8 backend/ + + - name: Set up Node.js for Frontend + uses: actions/setup-node@v3 + with: + node-version: '18' + + - name: Install Frontend Dependencies + run: npm install --prefix frontend/ + + - name: Run Frontend Linting + run: npm run lint --prefix frontend/ + + - name: Run Backend Tests + run: pytest backend/tests/ + + - name: Run Frontend Tests + run: npm test --prefix frontend/ + + + From c7381b05eeb7683331bcdb8b37dab567c3ce057d Mon Sep 17 00:00:00 2001 From: Weijun Lim Date: Mon, 17 Mar 2025 17:04:28 +0100 Subject: [PATCH 09/14] Update nginx_deploy.yml --- .github/workflows/nginx_deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nginx_deploy.yml b/.github/workflows/nginx_deploy.yml index 5d215a6..93d8467 100644 --- a/.github/workflows/nginx_deploy.yml +++ b/.github/workflows/nginx_deploy.yml @@ -1,7 +1,7 @@ name: Deploy Nginx Configuration on: - push: + pull: branches: - main paths: From ce6bfc8b92a829b728d01c8604256311bcc470a6 Mon Sep 17 00:00:00 2001 From: Weijun Lim Date: Mon, 17 Mar 2025 17:04:40 +0100 Subject: [PATCH 10/14] Update nginx_deploy.yml --- .github/workflows/nginx_deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nginx_deploy.yml b/.github/workflows/nginx_deploy.yml index 93d8467..ed479c8 100644 --- a/.github/workflows/nginx_deploy.yml +++ b/.github/workflows/nginx_deploy.yml @@ -1,7 +1,7 @@ name: Deploy Nginx Configuration on: - pull: + pull_request: branches: - main paths: From 0f89558ba4072809303fae8aedfae4e2281a2c17 Mon Sep 17 00:00:00 2001 From: Weijun Lim Date: Mon, 17 Mar 2025 17:07:41 +0100 Subject: [PATCH 11/14] Update nginx_deploy.yml --- .github/workflows/nginx_deploy.yml | 41 ++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/.github/workflows/nginx_deploy.yml b/.github/workflows/nginx_deploy.yml index ed479c8..b5bc465 100644 --- a/.github/workflows/nginx_deploy.yml +++ b/.github/workflows/nginx_deploy.yml @@ -1,30 +1,49 @@ -name: Deploy Nginx Configuration +name: Setup Nginx from the configuration file on: pull_request: branches: - main - paths: - - "nginx/nginx.conf" # Adjust the path to your nginx.conf file in the root directory jobs: deploy: - runs-on: self-hosted # Make sure your runner is self-hosted (or adjust this for GitHub-hosted runners) + runs-on: self-hosted # Ensure your runner is self-hosted steps: - # Checkout the repository - - name: Checkout Repository - uses: actions/checkout@v4 + - name: Checkout repository + uses: actions/checkout@v3 - # Copy Nginx Configuration to the server's /etc/nginx directory - - name: Copy Nginx Configuration + # Optionally set environment variables (skip if not needed) + - name: Set up environment variables + uses: falti/dotenv-action@v1.1.4 + with: + export-variables: true + keys-case: bypass + + - name: Check environment variables + run: env + + # Copy Nginx configuration to the server + - name: Copy Nginx configuration to server run: | - sudo cp ./nginx/nginx.conf /etc/nginx/conf.d/nginx_securefit.conf - # Test Nginx configuration to check for syntax errors + sudo cp ./nginx_securefit.conf /etc/nginx/conf.d/nginx_securefit.conf + + # Test the Nginx configuration for errors - name: Test Nginx Configuration run: | sudo nginx -t + # Reload Nginx to apply the new configuration - name: Reload Nginx run: | sudo systemctl reload nginx + + # Check if Nginx is running properly + - name: Check Nginx status + run: | + sudo systemctl status nginx + + # Optionally, display the deployed Nginx configuration for debugging + - name: Show deployed Nginx configuration + run: | + cat /etc/nginx/conf.d/nginx_securefit.conf From a2dcccee8830873b3c3ab81419baf5fb598da18a Mon Sep 17 00:00:00 2001 From: Weijun Lim Date: Mon, 17 Mar 2025 17:11:03 +0100 Subject: [PATCH 12/14] Update nginx_deploy.yml --- .github/workflows/nginx_deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nginx_deploy.yml b/.github/workflows/nginx_deploy.yml index b5bc465..521067b 100644 --- a/.github/workflows/nginx_deploy.yml +++ b/.github/workflows/nginx_deploy.yml @@ -1,7 +1,7 @@ name: Setup Nginx from the configuration file on: - pull_request: + push: branches: - main From 010627928c93a88af6fb8e8fd6ca1b0273476eaf Mon Sep 17 00:00:00 2001 From: Weijun Lim Date: Mon, 17 Mar 2025 17:41:12 +0100 Subject: [PATCH 13/14] Update nginx_deploy.yml --- .github/workflows/nginx_deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nginx_deploy.yml b/.github/workflows/nginx_deploy.yml index 521067b..b5bc465 100644 --- a/.github/workflows/nginx_deploy.yml +++ b/.github/workflows/nginx_deploy.yml @@ -1,7 +1,7 @@ name: Setup Nginx from the configuration file on: - push: + pull_request: branches: - main From 6899d68a561f3826fb4309d693e52938fed93383 Mon Sep 17 00:00:00 2001 From: Weijun Lim Date: Tue, 18 Mar 2025 15:01:42 +0100 Subject: [PATCH 14/14] Rename docker_deploy.yml to docker-deploy.yml --- .github/workflows/{docker_deploy.yml => docker-deploy.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{docker_deploy.yml => docker-deploy.yml} (100%) diff --git a/.github/workflows/docker_deploy.yml b/.github/workflows/docker-deploy.yml similarity index 100% rename from .github/workflows/docker_deploy.yml rename to .github/workflows/docker-deploy.yml