Files
ASF_tools/asf-cloud-server/testarena/DEPLOYMENT.md
2025-11-25 00:42:27 +01:00

142 lines
3.4 KiB
Markdown

# 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
```
## assigne admin
docker-compose exec backend python scripts/reset_admin.py
## 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
- **npm: command not found**:
You need to install Node.js and npm on your server.
```bash
sudo apt update
sudo apt install nodejs npm
```
- **Permission denied (Docker)**:
The script tries to handle this by using `sudo`. If running manually, use `sudo docker-compose ...` or add your user to the docker group:
```bash
sudo usermod -aG docker $USER
newgrp docker
```
- **Backend not starting?**
Check logs: `sudo docker-compose logs -f backend`
- **Frontend 404s?**
Ensure `try_files $uri $uri/ /index.html;` is present in Nginx config.