# 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 ```