version: '3.8'

services:
  app:
    # build:
    #   context: .
    #   dockerfile: Dockerfile
    image: ghcr.io/withanouar/saasspringbootforge:latest
    container_name: saas-fullstack-app
    restart: unless-stopped
    network_mode: host
    environment:
      # Database (MariaDB/MySQL on VPS)
      MYSQL_HOST: localhost
      MYSQL_PORT: 3306
      MYSQL_DATABASE: ${MYSQL_DATABASE}
      MYSQL_USER: ${MYSQL_USER}
      MYSQL_PASSWORD: ${MYSQL_PASSWORD}
      
      # Server Configuration
      SERVER_PORT: 8000
      SERVER_BASE_URL: ${SERVER_BASE_URL:-http://localhost:8000}
      SESSION_SECRET: ${SESSION_SECRET}
      
      # Twilio VoIP
      TWILIO_ACCOUNT_SID: ${TWILIO_ACCOUNT_SID}
      TWILIO_AUTH_TOKEN: ${TWILIO_AUTH_TOKEN}
      TWILIO_PHONE_NUMBER: ${TWILIO_PHONE_NUMBER}
      TWILIO_AI_PROVIDER: ${TWILIO_AI_PROVIDER:-OPENAI}
      
      # Telnyx VoIP
      TELNYX_API_KEY: ${TELNYX_API_KEY}
      
      # Vapi.ai Voice Assistants
      VAPI_PRIVATE_TOKEN: ${VAPI_PRIVATE_TOKEN}
      VAPI_WEBHOOK_SECRET: ${VAPI_WEBHOOK_SECRET}
      
      # AI Providers
      OPENAI_API_KEY: ${OPENAI_API_KEY}
      GEMINI_API_KEY: ${GEMINI_API_KEY:-}
      ELEVENLABS_API_KEY: ${ELEVENLABS_API_KEY:-}
      ELEVENLABS_AGENT_ID: ${ELEVENLABS_AGENT_ID:-}
      
      # JVM Optimization
      JAVA_OPTS: "-XX:MaxRAMPercentage=75.0 -XX:+UseG1GC -XX:+UseStringDeduplication -Djava.security.egd=file:/dev/./urandom"
      
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8000/actuator/health"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 120s
    
    ports:
      - "8000:8000"