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
This commit is contained in:
@@ -1,7 +1,19 @@
|
||||
# Docker Compose - LogWhispererAI Development Environment
|
||||
# Usage: docker compose up -d
|
||||
# Access Frontend: http://localhost:5173
|
||||
# Access Fake Backend API: http://localhost:3000
|
||||
# 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:
|
||||
@@ -17,9 +29,38 @@ services:
|
||||
# Use named volume for node_modules to avoid conflicts with host
|
||||
- node_modules:/app/node_modules
|
||||
environment:
|
||||
- NODE_ENV=development
|
||||
# Node environment
|
||||
- NODE_ENV=${NODE_ENV:-development}
|
||||
- CHOKIDAR_USEPOLLING=true
|
||||
- VITE_API_URL=http://fake-backend:3000
|
||||
|
||||
# ============================================
|
||||
# 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:
|
||||
@@ -38,11 +79,33 @@ services:
|
||||
dockerfile: Dockerfile
|
||||
container_name: logwhisperer-fake-backend
|
||||
ports:
|
||||
- "3000:3000"
|
||||
- "3001:3000"
|
||||
environment:
|
||||
# Server port (internal)
|
||||
- PORT=3000
|
||||
- DELAY_MS=1500
|
||||
- NODE_ENV=production
|
||||
|
||||
# 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))"]
|
||||
|
||||
Reference in New Issue
Block a user