From 9bfaa5e59bd86527dc24e50b8e70b42dd2e3c13f Mon Sep 17 00:00:00 2001 From: mahmamdouh Date: Mon, 24 Nov 2025 20:44:31 +0100 Subject: [PATCH] update for pc server --- asf-cloud-server/testarena/DEPLOYMENT.md | 127 +++++++++++++++++++++++ asf-cloud-server/testarena/deploy.sh | 40 +++++++ 2 files changed, 167 insertions(+) create mode 100644 asf-cloud-server/testarena/DEPLOYMENT.md create mode 100644 asf-cloud-server/testarena/deploy.sh diff --git a/asf-cloud-server/testarena/DEPLOYMENT.md b/asf-cloud-server/testarena/DEPLOYMENT.md new file mode 100644 index 0000000..b27f145 --- /dev/null +++ b/asf-cloud-server/testarena/DEPLOYMENT.md @@ -0,0 +1,127 @@ +# Deployment Guide - ASF TestArena + +This guide explains how to deploy the ASF TestArena application on your local PC server using Nginx and Docker. + +## Prerequisites + +1. **Git**: To pull the repository. +2. **Docker & Docker Compose**: To run the backend and database. +3. **Node.js & npm**: To build the frontend. +4. **Nginx**: To serve the frontend and proxy requests. +5. **Domain**: `asf-testarena.duckdns.org` configured. + +## Quick Deployment + +We have provided a script to automate the deployment process. + +1. Make the script executable: + ```bash + chmod +x deploy.sh + ``` + +2. Run the script: + ```bash + ./deploy.sh + ``` + +## Manual Deployment Steps + +If you prefer to deploy manually, follow these steps: + +### 1. Update Code +```bash +git pull origin main +``` + +### 2. Backend Setup +Start the backend services (API + Database): +```bash +docker-compose up -d --build +``` +*The backend will be available at `http://localhost:8000`.* + +### 3. Frontend Setup +Build the React application: +```bash +cd frontend +npm install +npm run build +``` +This creates a `dist` folder with the static files. + +Copy the build artifacts to your web server root: +```bash +sudo mkdir -p /var/www/testarena +sudo cp -r dist/* /var/www/testarena/ +``` + +### 4. Nginx Configuration +Ensure your Nginx is configured to serve the app. + +1. Edit your Nginx config (e.g., `/etc/nginx/sites-available/default`): + ```nginx + server { + listen 80; + server_name asf-testarena.duckdns.org; + + # Frontend + location / { + root /var/www/testarena; + index index.html; + try_files $uri $uri/ /index.html; + } + + # Backend API + location /api/ { + proxy_pass http://localhost:8000/; + proxy_set_header Host $host; + } + + # Auth + location /auth/ { + proxy_pass http://localhost:8000/auth/; + proxy_set_header Host $host; + } + + # Admin + location /admin/ { + proxy_pass http://localhost:8000/admin/; + proxy_set_header Host $host; + } + + # Jobs + location /jobs/ { + proxy_pass http://localhost:8000/jobs/; + proxy_set_header Host $host; + } + + # WebSocket + location /ws/ { + proxy_pass http://localhost:8000/ws/; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "Upgrade"; + proxy_set_header Host $host; + } + + # Results + location /results/ { + alias /path/to/your/project/testarena/results/; + autoindex on; + } + } + ``` +2. Test and Reload Nginx: + ```bash + sudo nginx -t + sudo systemctl reload nginx + ``` + +## Troubleshooting + +- **Backend not starting?** + Check logs: `docker-compose logs -f backend` +- **Frontend 404s?** + Ensure `try_files $uri $uri/ /index.html;` is present in Nginx config. +- **WebSocket connection failed?** + Ensure the `/ws/` location block has the `Upgrade` headers. diff --git a/asf-cloud-server/testarena/deploy.sh b/asf-cloud-server/testarena/deploy.sh new file mode 100644 index 0000000..5e23a47 --- /dev/null +++ b/asf-cloud-server/testarena/deploy.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +# Deployment Script for ASF TestArena +# Usage: ./deploy.sh + +echo "Starting deployment..." + +# 1. Pull latest changes +echo "Pulling latest changes from git..." +git pull + +# 2. Build Frontend +echo "Building frontend..." +cd frontend +npm install +npm run build +cd .. + +# 3. Deploy Frontend +echo "Deploying frontend to /var/www/testarena..." +# Ensure directory exists +if [ ! -d "/var/www/testarena" ]; then + echo "Creating /var/www/testarena..." + sudo mkdir -p /var/www/testarena + sudo chown $USER:$USER /var/www/testarena +fi + +# Copy files +sudo cp -r frontend/dist/* /var/www/testarena/ + +# 4. Restart Backend +echo "Restarting backend services..." +docker-compose down +docker-compose up -d --build + +# 5. Reload Nginx (Optional, if config changed) +echo "Reloading Nginx..." +sudo systemctl reload nginx + +echo "Deployment complete! Access at http://asf-testarena.duckdns.org"