update for pc server
This commit is contained in:
@@ -1,31 +0,0 @@
|
||||
testarena.nabd-co.com {
|
||||
# API and Auth
|
||||
handle /api/* {
|
||||
reverse_proxy backend:8000
|
||||
}
|
||||
handle /auth/* {
|
||||
reverse_proxy backend:8000
|
||||
}
|
||||
handle /admin/* {
|
||||
reverse_proxy backend:8000
|
||||
}
|
||||
handle /jobs/* {
|
||||
reverse_proxy backend:8000
|
||||
}
|
||||
|
||||
# WebSocket
|
||||
handle /ws/* {
|
||||
reverse_proxy backend:8000
|
||||
}
|
||||
|
||||
# Results (Mounted volume)
|
||||
handle /results/* {
|
||||
root * /srv
|
||||
file_server
|
||||
}
|
||||
|
||||
# Frontend
|
||||
handle {
|
||||
reverse_proxy frontend:80
|
||||
}
|
||||
}
|
||||
@@ -13,42 +13,55 @@ A full-stack web application to manage automated software test jobs.
|
||||
- **Backend**: FastAPI (Python)
|
||||
- **Frontend**: React + Vite (TypeScript)
|
||||
- **Database**: PostgreSQL
|
||||
- **Reverse Proxy**: Caddy
|
||||
- **Containerization**: Docker Compose
|
||||
- **Reverse Proxy**: Nginx (Local Host)
|
||||
- **Containerization**: Docker Compose (Backend + DB)
|
||||
|
||||
## Deployment Instructions
|
||||
|
||||
### Prerequisites
|
||||
- Docker and Docker Compose installed on the server.
|
||||
- Domain `testarena.nabd-co.com` pointing to the server IP.
|
||||
- Docker and Docker Compose installed.
|
||||
- Nginx installed on the host machine.
|
||||
- Node.js installed (to build frontend).
|
||||
- Domain `asf-testarena.duckdns.org` pointing to your PC.
|
||||
|
||||
### Steps
|
||||
1. **Clone the repository** to your VPS.
|
||||
```bash
|
||||
git clone <repo_url>
|
||||
cd testarena
|
||||
```
|
||||
|
||||
2. **Configure Environment**
|
||||
- Edit `docker-compose.yml` if you need to change database passwords.
|
||||
- Edit `backend/app/auth.py` to change the `SECRET_KEY`.
|
||||
|
||||
3. **Run with Docker Compose**
|
||||
### 1. Backend & Database
|
||||
Start the backend and database using Docker Compose:
|
||||
```bash
|
||||
docker-compose up -d --build
|
||||
```
|
||||
This will expose the backend API on `localhost:8000`.
|
||||
|
||||
4. **Verify**
|
||||
- Open `https://testarena.nabd-co.com` in your browser.
|
||||
- Login with default credentials:
|
||||
- Username: `admin`
|
||||
- Password: `admin123`
|
||||
### 2. Frontend
|
||||
Build the frontend application:
|
||||
```bash
|
||||
cd frontend
|
||||
npm install
|
||||
npm run build
|
||||
```
|
||||
Copy the contents of `frontend/dist` to your web root:
|
||||
```bash
|
||||
# Example path based on your request
|
||||
sudo cp -r dist/* /var/www/testarena/
|
||||
```
|
||||
|
||||
### 3. Nginx Configuration
|
||||
Update your Nginx configuration (usually in `/etc/nginx/sites-available/default` or similar) using the snippet provided in `nginx_config_snippet.conf`.
|
||||
|
||||
Key configurations:
|
||||
- Serve static files from `/var/www/testarena`.
|
||||
- Proxy `/api/`, `/auth/`, `/admin/`, `/jobs/`, `/ws/` to `http://localhost:8000`.
|
||||
- Alias `/results/` to the `results` folder in this project directory.
|
||||
|
||||
Restart Nginx:
|
||||
```bash
|
||||
sudo systemctl restart nginx
|
||||
```
|
||||
|
||||
### 4. Verify
|
||||
- Open `http://asf-testarena.duckdns.org`.
|
||||
- Login with `admin` / `admin123`.
|
||||
|
||||
### Scripts Integration
|
||||
- The mock scripts are located in `backend/scripts/`.
|
||||
- Replace `get_scenarios.sh` and `run_tests.sh` with your actual implementation.
|
||||
- Ensure the scripts are executable (`chmod +x`).
|
||||
|
||||
### Troubleshooting
|
||||
- Check logs: `docker-compose logs -f`
|
||||
- Restart services: `docker-compose restart`
|
||||
- Ensure the scripts are executable.
|
||||
|
||||
@@ -19,6 +19,8 @@ services:
|
||||
volumes:
|
||||
- ./backend:/app
|
||||
- ./results:/results
|
||||
ports:
|
||||
- "8000:8000"
|
||||
environment:
|
||||
- DATABASE_URL=postgresql://user:password@db/testarena
|
||||
- SCRIPTS_DIR=/app/scripts
|
||||
@@ -28,36 +30,9 @@ services:
|
||||
- app-network
|
||||
restart: always
|
||||
|
||||
frontend:
|
||||
build:
|
||||
context: ./frontend
|
||||
dockerfile: Dockerfile
|
||||
networks:
|
||||
- app-network
|
||||
restart: always
|
||||
|
||||
caddy:
|
||||
image: caddy:2
|
||||
ports:
|
||||
- "80:80"
|
||||
- "443:443"
|
||||
volumes:
|
||||
- ./Caddyfile:/etc/caddy/Caddyfile
|
||||
- ./results:/srv/results
|
||||
- caddy_data:/data
|
||||
- caddy_config:/config
|
||||
depends_on:
|
||||
- backend
|
||||
- frontend
|
||||
networks:
|
||||
- app-network
|
||||
restart: always
|
||||
|
||||
networks:
|
||||
app-network:
|
||||
driver: bridge
|
||||
|
||||
volumes:
|
||||
postgres_data:
|
||||
caddy_data:
|
||||
caddy_config:
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
:80 {
|
||||
root * /srv
|
||||
encode gzip
|
||||
file_server
|
||||
try_files {path} /index.html
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
FROM node:18-alpine as build
|
||||
WORKDIR /app
|
||||
COPY package*.json ./
|
||||
RUN npm install
|
||||
COPY . .
|
||||
RUN npm run build
|
||||
|
||||
FROM caddy:2-alpine
|
||||
COPY --from=build /app/dist /srv
|
||||
COPY Caddyfile /etc/caddy/Caddyfile
|
||||
54
asf-cloud-server/testarena/nginx_config_snippet.conf
Normal file
54
asf-cloud-server/testarena/nginx_config_snippet.conf
Normal file
@@ -0,0 +1,54 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name asf-testarena.duckdns.org;
|
||||
|
||||
# Frontend Static Files
|
||||
location / {
|
||||
root /var/www/testarena;
|
||||
index index.html;
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
# Backend API Proxy
|
||||
location /api/ {
|
||||
proxy_pass http://localhost:8000/;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
}
|
||||
|
||||
location /auth/ {
|
||||
proxy_pass http://localhost:8000/auth/;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
}
|
||||
|
||||
location /admin/ {
|
||||
proxy_pass http://localhost:8000/admin/;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
}
|
||||
|
||||
location /jobs/ {
|
||||
proxy_pass http://localhost:8000/jobs/;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
}
|
||||
|
||||
# WebSocket Proxy
|
||||
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 (Assuming you mount/copy results to this path or proxy to backend if it served them)
|
||||
# The backend was configured to write to /results.
|
||||
# Since we are running backend in docker, we mapped ./results to /results.
|
||||
# You can alias this location to the local folder on your PC.
|
||||
location /results/ {
|
||||
alias /path/to/your/project/testarena/results/;
|
||||
autoindex on;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user