From 80999b36592c134ab1259c96a7495d59b3fb06cd Mon Sep 17 00:00:00 2001 From: zwitschi Date: Mon, 27 Apr 2026 21:35:35 +0200 Subject: [PATCH] Update service ports in documentation and configuration files to 12000 for backend --- README.md | 2 +- docs/7-deployment-view.md | 12 ++++++------ docs/deployment/coolify.md | 38 ++++++++++++++------------------------ frontend/app/config.py | 2 +- nginx/coolify.conf | 2 +- 5 files changed, 23 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index 5fb00c4..a55f474 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ cp .env.example .env ```bash cd backend -uvicorn app.main:app --reload --port 8000 +uvicorn app.main:app --reload --port 12000 ``` ### Running the frontend diff --git a/docs/7-deployment-view.md b/docs/7-deployment-view.md index 70261a4..fe44c61 100644 --- a/docs/7-deployment-view.md +++ b/docs/7-deployment-view.md @@ -13,7 +13,7 @@ Describes: │ ┌─────────────┐ ┌─────────────────────┐ │ │ │ frontend │ │ backend │ │ │ │ (Flask) │ │ (FastAPI) │ │ -│ │ :5000 │ │ :8000 │ │ +│ │ :5000 │ │ :12000 │ │ │ └──────┬──────┘ └──────────┬──────────┘ │ │ │ │ │ │ └────────┬──────────┘ │ @@ -31,11 +31,11 @@ Describes: **Mapping of Building Blocks to Infrastructure:** -| Building Block | Container / Process | Port | -| --------------- | ---------------------------- | ---- | -| Flask frontend | `frontend` | 5000 | -| FastAPI backend | `backend` | 8000 | -| DuckDB | File on host (`data/app.db`) | — | +| Building Block | Container / Process | Port | +| --------------- | ---------------------------- | ----- | +| Flask frontend | `frontend` | 5000 | +| FastAPI backend | `backend` | 12000 | +| DuckDB | File on host (`data/app.db`) | — | ## Infrastructure Level 2 diff --git a/docs/deployment/coolify.md b/docs/deployment/coolify.md index a092849..032c9b2 100644 --- a/docs/deployment/coolify.md +++ b/docs/deployment/coolify.md @@ -6,14 +6,14 @@ This guide covers deploying `ai.allucanget.biz` using [Coolify](https://coolify. The application consists of two Python services: -| Service | Framework | Port | Description | -| -------- | ----------------- | ---- | ------------------------------------------ | -| Backend | FastAPI + uvicorn | 8000 | REST API, auth, AI generation, DuckDB | -| Frontend | Flask + gunicorn | 5000 | SSR web UI, session auth, proxy to backend | +| Service | Framework | Port | Description | +| -------- | ----------------- | ----- | ------------------------------------------ | +| Backend | FastAPI + uvicorn | 12000 | REST API, auth, AI generation, DuckDB | +| Frontend | Flask + gunicorn | 5000 | SSR web UI, session auth, proxy to backend | Coolify's built-in reverse proxy routes traffic: -- `/api/*` → Backend (port 8000) +- `/api/*` → Backend (port 12000) - `/` → Frontend (port 5000) ## Prerequisites @@ -30,10 +30,10 @@ Coolify's built-in reverse proxy routes traffic: 4. Choose the `main` branch 5. Set **Build Pack** to `nixpacks` 6. **CRITICAL: Set Base Directory to `/backend`** — this tells Nixpacks to look in the `backend/` subdirectory for `requirements.txt` and the Python application -7. Set **Ports Exposed** to `8000` +7. Set **Ports Exposed** to `12000` 8. Set **Start Command** to: ```txt - uvicorn app.main:app --host 0.0.0.0 --port 8000 + uvicorn app.main:app --host 0.0.0.0 --port 12000 ``` 9. Click **Create Resource** @@ -73,10 +73,10 @@ Add these as **Runtime** environment variables in Coolify: Add these as **Runtime** environment variables in Coolify: -| Variable | Description | Example | -| ------------------ | ----------------------------------------- | -------------------------------------------------------------- | -| `FLASK_SECRET_KEY` | Flask session cookie signing key | Generate with `openssl rand -hex 32` | -| `BACKEND_URL` | Internal URL to reach the backend service | `http://localhost:8000` (or use Coolify's internal networking) | +| Variable | Description | Example | +| ------------------ | ----------------------------------------- | --------------------------------------------------------------- | +| `FLASK_SECRET_KEY` | Flask session cookie signing key | Generate with `openssl rand -hex 32` | +| `BACKEND_URL` | Internal URL to reach the backend service | `http://localhost:12000` (or use Coolify's internal networking) | ## Step 3: Configure Reverse Proxy @@ -85,7 +85,7 @@ Coolify provides a built-in reverse proxy. Configure routing rules: ### Backend Proxy Rules - **Domain**: `api.ai.allucanget.biz` (or subdomain of your choice) -- **Port**: `8000` +- **Port**: `12000` - **Path**: `/api/*` → forward to backend ### Frontend Proxy Rules @@ -104,7 +104,7 @@ If you need custom Nginx configuration, create `nginx/coolify.conf`: # Backend API proxy location /api/ { - proxy_pass http://backend:8000; + proxy_pass http://backend:12000; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; @@ -152,7 +152,7 @@ If you want to persist DuckDB data: ### Frontend can't reach backend - Ensure `BACKEND_URL` points to the correct internal URL -- If both services are on the same Coolify server, use `http://localhost:8000` +- If both services are on the same Coolify server, use `http://localhost:12000` - Check that the backend service is running and healthy ### CORS errors @@ -191,13 +191,3 @@ All required environment variables: - [ ] Domain names configured - [ ] Health checks passing - [ ] Logs reviewed for errors - -## Nixpacks Configuration - -The project includes Nixpacks configuration files for both services: - -- `nixpacks.toml` — Shared configuration (Python version, packages) -- `backend/nixpacks.toml` — Backend-specific (uvicorn, port 8000) -- `frontend/nixpacks.toml` — Frontend-specific (gunicorn, port 5000) - -Nixpacks automatically detects Python projects and installs dependencies from `requirements.txt`. No additional configuration is needed for basic deployments. diff --git a/frontend/app/config.py b/frontend/app/config.py index 996387f..88f22a9 100644 --- a/frontend/app/config.py +++ b/frontend/app/config.py @@ -4,6 +4,6 @@ import os class Config: SECRET_KEY = os.getenv("FLASK_SECRET_KEY", "dev-secret-change-in-production") - BACKEND_URL = os.getenv("BACKEND_URL", "http://localhost:8000") + BACKEND_URL = os.getenv("BACKEND_URL", "http://localhost:12000") SESSION_COOKIE_HTTPONLY = True SESSION_COOKIE_SAMESITE = "Lax" diff --git a/nginx/coolify.conf b/nginx/coolify.conf index 524e2df..ff16b7f 100644 --- a/nginx/coolify.conf +++ b/nginx/coolify.conf @@ -3,7 +3,7 @@ # Backend API proxy upstream backend { - server 127.0.0.1:8000; + server 127.0.0.1:12000; } # Frontend proxy