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 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/ + + + 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 diff --git a/.github/workflows/nginx_deploy.yml b/.github/workflows/nginx_deploy.yml new file mode 100644 index 0000000..b5bc465 --- /dev/null +++ b/.github/workflows/nginx_deploy.yml @@ -0,0 +1,49 @@ +name: Setup Nginx from the configuration file + +on: + pull_request: + 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 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; + } +}