- Add .env file for production deployment with reverse proxy - Add docker-compose.prod.yml for production profile - Add docker-compose.override.yml for local development - Update docker-compose.yml with all configurable variables - Update frontend to use VITE_* environment variables - Update backend to support CORS_ORIGINS and WEBHOOK_BASE_URL - Add vite.config.ts allowedHosts for reverse proxy - Add documentation for docker-compose and reverse proxy setup All URLs are now configurable via environment variables: - VITE_API_URL: Backend API endpoint - VITE_WEBHOOK_BASE_URL: Webhook base URL - VITE_INSTALL_SCRIPT_URL: Install script URL - VITE_APP_URL: Frontend URL - CORS_ORIGINS: Allowed CORS origins - WEBHOOK_BASE_URL: Backend webhook base URL
131 lines
3.4 KiB
Markdown
131 lines
3.4 KiB
Markdown
# Docker Compose Configuration
|
|
|
|
Questa directory contiene diverse configurazioni Docker Compose per vari ambienti.
|
|
|
|
## File Disponibili
|
|
|
|
| File | Scopo | Uso |
|
|
|------|-------|-----|
|
|
| `docker-compose.yml` | Configurazione base con variabili d'ambiente | Sviluppo e produzione |
|
|
| `docker-compose.override.yml` | Override per sviluppo locale | Caricato automaticamente |
|
|
| `docker-compose.prod.yml` | Configurazione produzione | Da usare con `-f` |
|
|
|
|
## Variabili d'Ambiente
|
|
|
|
Tutte le variabili sono configurabili tramite file `.env` o variabili di sistema.
|
|
|
|
### Frontend (VITE_*)
|
|
|
|
| Variabile | Default | Descrizione |
|
|
|-----------|---------|-------------|
|
|
| `VITE_API_URL` | `http://fake-backend:3000` | URL del backend API |
|
|
| `VITE_WEBHOOK_BASE_URL` | `http://localhost:3001/webhook` | Base URL webhook |
|
|
| `VITE_INSTALL_SCRIPT_URL` | `http://localhost:3001/install.sh` | URL script installazione |
|
|
| `VITE_APP_NAME` | `LogWhispererAI` | Nome applicazione |
|
|
| `VITE_APP_URL` | `http://localhost:5173` | URL pubblico app |
|
|
|
|
### Backend
|
|
|
|
| Variabile | Default | Descrizione |
|
|
|-----------|---------|-------------|
|
|
| `PORT` | `3000` | Porta server (interna) |
|
|
| `DELAY_MS` | `1500` | Delay simulazione API |
|
|
| `NODE_ENV` | `production` | Ambiente Node |
|
|
| `CORS_ORIGINS` | `*` | Origini CORS consentite |
|
|
| `WEBHOOK_BASE_URL` | `https://logwhisperer.ai/webhook` | Base URL webhook |
|
|
|
|
## Utilizzo
|
|
|
|
### Sviluppo Locale (default)
|
|
|
|
```bash
|
|
# Le variabili di docker-compose.override.yml vengono usate automaticamente
|
|
docker compose up -d
|
|
```
|
|
|
|
### Sviluppo con configurazione personalizzata
|
|
|
|
```bash
|
|
# Crea un file .env nella root del progetto
|
|
cat > .env << 'EOF'
|
|
VITE_API_URL=http://192.168.254.79:3001
|
|
VITE_WEBHOOK_BASE_URL=http://192.168.254.79:3001/webhook
|
|
CORS_ORIGINS=*
|
|
EOF
|
|
|
|
# Avvia con le variabili dal file .env
|
|
docker compose up -d
|
|
```
|
|
|
|
### Produzione con Reverse Proxy
|
|
|
|
```bash
|
|
# 1. Crea il file .env con i valori di produzione
|
|
cat > .env << 'EOF'
|
|
VITE_API_URL=https://srv-logwhispererai.lab.home.lucasacchi.net
|
|
VITE_WEBHOOK_BASE_URL=https://logwhispererai.lab.home.lucasacchi.net/webhook
|
|
VITE_INSTALL_SCRIPT_URL=https://logwhispererai.lab.home.lucasacchi.net/install.sh
|
|
VITE_APP_URL=https://logwhispererai.lab.home.lucasacchi.net
|
|
CORS_ORIGINS=https://logwhispererai.lab.home.lucasacchi.net
|
|
WEBHOOK_BASE_URL=https://logwhispererai.lab.home.lucasacchi.net/webhook
|
|
NODE_ENV=production
|
|
EOF
|
|
|
|
# 2. Avvia con la configurazione di produzione
|
|
# (ignora docker-compose.override.yml)
|
|
docker compose -f docker-compose.yml -f docker-compose.prod.yml up -d
|
|
```
|
|
|
|
### Solo Backend
|
|
|
|
```bash
|
|
docker compose up fake-backend -d
|
|
```
|
|
|
|
### Solo Frontend
|
|
|
|
```bash
|
|
docker compose up frontend -d
|
|
```
|
|
|
|
## Verifica Configurazione
|
|
|
|
```bash
|
|
# Controlla le variabili caricate
|
|
docker compose config
|
|
|
|
# Verifica il backend
|
|
curl https://srv-logwhispererai.lab.home.lucasacchi.net/health
|
|
|
|
# Verifica la generazione webhook
|
|
curl -X POST https://srv-logwhispererai.lab.home.lucasacchi.net/api/webhook
|
|
```
|
|
|
|
## Troubleshooting
|
|
|
|
### Cambiare le variabili
|
|
|
|
Se modifichi il file `.env`, devi ricreare i container:
|
|
|
|
```bash
|
|
docker compose down
|
|
docker compose up -d
|
|
```
|
|
|
|
### Vedere le variabili in uso
|
|
|
|
```bash
|
|
# Frontend
|
|
docker exec logwhisperer-frontend-dev env | grep VITE
|
|
|
|
# Backend
|
|
docker exec logwhisperer-fake-backend env | grep -E '(CORS|WEBHOOK)'
|
|
```
|
|
|
|
### Reset alla configurazione default
|
|
|
|
```bash
|
|
docker compose down
|
|
rm .env # Rimuovi configurazione personalizzata
|
|
docker compose up -d # Userà i valori default
|
|
``` |