version: '3.8' services: # ============================================================================ # Core Application Services # ============================================================================ backend: build: ./backend environment: # Langflow Integration - LANGFLOW_URL=http://langflow:7860/api/v1/predict/${LANGFLOW_FLOW_ID} # Database Connections - DATABASE_URL=postgresql://preflight:preflight_secure_pass@postgres:5432/preflight_db - REDIS_URL=redis://redis:6379/0 # MCP Server URLs (Model Context Protocol) - OPENMETEO_MCP_SERVER_URL=http://openmeteo-mcp:3000 - AVIATIONSTACK_MCP_SERVER_URL=http://aviationstack-mcp:3001 # MCP Connection Settings - MCP_CONNECTION_TIMEOUT=5 - MCP_REQUEST_TIMEOUT=30 # API Keys (for MCP fallback) - AVIATIONSTACK_API_KEY=${AVIATIONSTACK_API_KEY} - GOOGLE_MAPS_API_KEY=${GOOGLE_MAPS_API_KEY:-} # External APIs - Notifications (Optional) - TWILIO_ACCOUNT_SID=${TWILIO_ACCOUNT_SID:-} - TWILIO_AUTH_TOKEN=${TWILIO_AUTH_TOKEN:-} - TWILIO_PHONE_NUMBER=${TWILIO_PHONE_NUMBER:-} - SENDGRID_API_KEY=${SENDGRID_API_KEY:-} - SENDGRID_FROM_EMAIL=${SENDGRID_FROM_EMAIL:-alerts@preflight.ai} - SLACK_WEBHOOK_URL=${SLACK_WEBHOOK_URL:-} # Security Configuration - ALLOWED_ORIGINS=${ALLOWED_ORIGINS:-http://localhost:3000,http://localhost:8000} - API_RATE_LIMIT_PER_MINUTE=${API_RATE_LIMIT_PER_MINUTE:-60/minute} # Application Settings - APP_ENV=${APP_ENV:-production} - LOG_LEVEL=${LOG_LEVEL:-INFO} volumes: - app_data:/app_data # PRODUCTION: Comment out source code mount to prevent runtime modification - ./backend:/app ports: - "8000:5000" depends_on: - postgres - redis - langflow - ollama - openmeteo-mcp - aviationstack-mcp restart: unless-stopped # Resource limits for production stability deploy: resources: limits: cpus: '2' memory: 2G reservations: cpus: '0.5' memory: 512M healthcheck: test: ["CMD", "curl", "-f", "http://localhost:5000/health"] interval: 30s timeout: 10s retries: 3 start_period: 40s frontend: build: ./frontend environment: - REACT_APP_API_URL=http://localhost:5000 - NODE_ENV=production ports: - "3000:3000" depends_on: - backend stdin_open: true tty: true restart: unless-stopped # ============================================================================ # MCP Server Services (Model Context Protocol) # ============================================================================ openmeteo-mcp: build: ./mcp-servers/openmeteo ports: - "3000:3000" environment: - PORT=3000 restart: unless-stopped healthcheck: test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:3000/health"] interval: 30s timeout: 10s retries: 3 start_period: 10s aviationstack-mcp: build: ./mcp-servers/aviationstack ports: - "3001:3001" environment: - PORT=3001 - AVIATIONSTACK_API_KEY=${AVIATIONSTACK_API_KEY} restart: unless-stopped healthcheck: test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:3001/health"] interval: 30s timeout: 10s retries: 3 start_period: 10s # ============================================================================ # AI & ML Services # ============================================================================ langflow: image: langflowai/langflow:latest environment: - LANGFLOW_DATABASE_URL=postgresql://preflight:preflight_secure_pass@postgres:5432/langflow_db - LANGFLOW_CONFIG_DIR=/app/langflow_config volumes: - langflow_data:/app/langflow - ./backend/langflow_flow:/app/langflow_flow ports: - "7860:7860" depends_on: - postgres - ollama restart: unless-stopped healthcheck: test: ["CMD", "curl", "-f", "http://localhost:7860/health"] interval: 30s timeout: 10s retries: 3 ollama: image: ollama/ollama:latest ports: - "11434:11434" volumes: - ollama_models:/root/.ollama restart: unless-stopped deploy: resources: reservations: devices: - driver: nvidia count: all capabilities: [gpu] # For CPU-only systems, remove the deploy section above # ============================================================================ # Database Services # ============================================================================ postgres: image: postgres:15-alpine environment: - POSTGRES_USER=preflight - POSTGRES_PASSWORD=preflight_secure_pass - POSTGRES_MULTIPLE_DATABASES=preflight_db,langflow_db volumes: - postgres_data:/var/lib/postgresql/data - ./backend/database/schema.sql:/docker-entrypoint-initdb.d/01-schema.sql - ./scripts/create_multiple_databases.sh:/docker-entrypoint-initdb.d/00-create-dbs.sh ports: - "5432:5432" restart: unless-stopped healthcheck: test: ["CMD-SHELL", "pg_isready -U preflight"] interval: 10s timeout: 5s retries: 5 redis: image: redis:7-alpine command: redis-server --appendonly yes --requirepass redis_secure_pass volumes: - redis_data:/data ports: - "6379:6379" restart: unless-stopped healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 10s timeout: 5s retries: 5 # ============================================================================ # Database Management Tools # ============================================================================ pgadmin: image: dpage/pgadmin4:latest environment: - PGADMIN_DEFAULT_EMAIL=admin@preflight.ai - PGADMIN_DEFAULT_PASSWORD=admin_secure_pass - PGADMIN_CONFIG_SERVER_MODE=False volumes: - pgadmin_data:/var/lib/pgadmin ports: - "5050:80" depends_on: - postgres restart: unless-stopped profiles: - tools redis-commander: image: rediscommander/redis-commander:latest environment: - REDIS_HOSTS=local:redis:6379:0:redis_secure_pass ports: - "8081:8081" depends_on: - redis restart: unless-stopped profiles: - tools # ============================================================================ # Monitoring & Observability (Optional) # ============================================================================ prometheus: image: prom/prometheus:latest volumes: - ./monitoring/prometheus.yml:/etc/prometheus/prometheus.yml - prometheus_data:/prometheus ports: - "9090:9090" command: - '--config.file=/etc/prometheus/prometheus.yml' - '--storage.tsdb.path=/prometheus' restart: unless-stopped profiles: - monitoring grafana: image: grafana/grafana:latest environment: - GF_SECURITY_ADMIN_PASSWORD=admin_secure_pass - GF_USERS_ALLOW_SIGN_UP=false volumes: - grafana_data:/var/lib/grafana - ./monitoring/grafana/dashboards:/etc/grafana/provisioning/dashboards - ./monitoring/grafana/datasources:/etc/grafana/provisioning/datasources ports: - "3001:3000" depends_on: - prometheus restart: unless-stopped profiles: - monitoring # ============================================================================ # Volumes # ============================================================================ volumes: postgres_data: driver: local redis_data: driver: local ollama_models: driver: local langflow_data: driver: local pgadmin_data: driver: local prometheus_data: driver: local grafana_data: driver: local app_data: driver: local # ============================================================================ # Networks # ============================================================================ networks: default: name: preflight_network driver: bridge