Files
LogWhispererAI/docker-compose.yml
Luca Sacchi Ricciardi 26879acba4 feat: add production configuration with environment variables
- 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
2026-04-03 18:49:53 +02:00

119 lines
4.4 KiB
YAML

# Docker Compose - LogWhispererAI Development Environment
# Usage: docker compose up -d
# Access Frontend: http://localhost:5173
# Access Fake Backend API: http://localhost:3001
#
# For production deployment with reverse proxy:
# 1. Copy .env.example to .env and customize values
# 2. Run: docker compose up -d
#
# Required environment variables for production:
# 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
services:
frontend:
build:
context: ./frontend
dockerfile: Dockerfile.dev
container_name: logwhisperer-frontend-dev
ports:
- "5173:5173"
volumes:
# Mount source code for Hot Module Replacement (HMR)
- ./frontend:/app
# Use named volume for node_modules to avoid conflicts with host
- node_modules:/app/node_modules
environment:
# Node environment
- NODE_ENV=${NODE_ENV:-development}
- CHOKIDAR_USEPOLLING=true
# ============================================
# FRONTEND CONFIGURATION (VITE_* variables)
# These are exposed to the browser
# ============================================
# Backend API URL - where the frontend will make API calls
# Default: http://fake-backend:3000 (internal Docker network)
# Production: https://srv-logwhispererai.lab.home.lucasacchi.net
- VITE_API_URL=${VITE_API_URL:-http://fake-backend:3000}
# Webhook base URL - used for displaying webhook URLs to users
# Default: http://localhost:3001/webhook
# Production: https://logwhispererai.lab.home.lucasacchi.net/webhook
- VITE_WEBHOOK_BASE_URL=${VITE_WEBHOOK_BASE_URL:-http://localhost:3001/webhook}
# Install script URL - the curl command shown to users
# Default: http://localhost:3001/install.sh
# Production: https://logwhispererai.lab.home.lucasacchi.net/install.sh
- VITE_INSTALL_SCRIPT_URL=${VITE_INSTALL_SCRIPT_URL:-http://localhost:3001/install.sh}
# Application identification
- VITE_APP_NAME=${VITE_APP_NAME:-LogWhispererAI}
# Application public URL
# Default: http://localhost:5173
# Production: https://logwhispererai.lab.home.lucasacchi.net
- VITE_APP_URL=${VITE_APP_URL:-http://localhost:5173}
# Ensure container restarts on failure
restart: unless-stopped
depends_on:
- fake-backend
# Health check to verify the service is running
healthcheck:
test: ["CMD", "wget", "-q", "--spider", "http://localhost:5173"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
fake-backend:
build:
context: ./tools/fake-backend
dockerfile: Dockerfile
container_name: logwhisperer-fake-backend
ports:
- "3001:3000"
environment:
# Server port (internal)
- PORT=3000
# API delay simulation (milliseconds)
- DELAY_MS=${DELAY_MS:-1500}
# Node environment
- NODE_ENV=${NODE_ENV:-production}
# ============================================
# BACKEND CONFIGURATION
# ============================================
# CORS origins - comma-separated list of allowed frontend origins
# Use '*' for development (allows all origins)
# Production: set to your frontend domain for security
# Example: https://logwhispererai.lab.home.lucasacchi.net
- CORS_ORIGINS=${CORS_ORIGINS:-*}
# Webhook base URL - used for generating webhook URLs
# This should be the public URL that users see
# Default: https://logwhisperer.ai/webhook
# Production: https://logwhispererai.lab.home.lucasacchi.net/webhook
- WEBHOOK_BASE_URL=${WEBHOOK_BASE_URL:-https://logwhisperer.ai/webhook}
restart: unless-stopped
healthcheck:
test: ["CMD", "node", "-e", "require('http').get('http://localhost:3000/health', (r) => r.statusCode === 200 ? process.exit(0) : process.exit(1))"]
interval: 30s
timeout: 3s
retries: 3
start_period: 5s
volumes:
node_modules:
driver: local