# Create a .env file for overrides. At the very least, set the following:
#
# VITE_GOOGLE_MAPS_API_KEY=your_api_key_here
# VITE_GOOGLE_MAPS_ID=your_maps_id_here

services:
  meshstream:
    build:
      context: .
      dockerfile: Dockerfile
      args:
        # Web application build-time variables
        - MESHSTREAM_API_BASE_URL=${MESHSTREAM_API_BASE_URL:-}
        - MESHSTREAM_APP_ENV=${MESHSTREAM_APP_ENV:-production}
        - MESHSTREAM_SITE_TITLE=${MESHSTREAM_SITE_TITLE:-Bay Area Mesh}
        - MESHSTREAM_SITE_DESCRIPTION=${MESHSTREAM_SITE_DESCRIPTION:-Meshtastic activity in the Bay Area region, CA.}
        - MESHSTREAM_GOOGLE_MAPS_ID=${MESHSTREAM_GOOGLE_MAPS_ID}
        - MESHSTREAM_GOOGLE_MAPS_API_KEY=${MESHSTREAM_GOOGLE_MAPS_API_KEY}
    ports:
      - "5446:5446"
    environment:
      # Runtime configuration with defaults from .env file or inline defaults
      # MQTT connection settings
      - MESHSTREAM_MQTT_BROKER=${MESHSTREAM_MQTT_BROKER:-mqtt.bayme.sh}
      - MESHSTREAM_MQTT_USERNAME=${MESHSTREAM_MQTT_USERNAME:-meshdev}
      - MESHSTREAM_MQTT_PASSWORD=${MESHSTREAM_MQTT_PASSWORD:-large4cats}
      - MESHSTREAM_MQTT_TOPIC_PREFIX=${MESHSTREAM_MQTT_TOPIC_PREFIX:-msh/US/bayarea}
      - MESHSTREAM_MQTT_CLIENT_ID=${MESHSTREAM_MQTT_CLIENT_ID:-meshstream-${HOSTNAME:-local}}
      
      # MQTT connection tuning parameters
      - MESHSTREAM_MQTT_KEEPALIVE=${MESHSTREAM_MQTT_KEEPALIVE:-60}
      - MESHSTREAM_MQTT_CONNECT_TIMEOUT=${MESHSTREAM_MQTT_CONNECT_TIMEOUT:-30s}
      - MESHSTREAM_MQTT_PING_TIMEOUT=${MESHSTREAM_MQTT_PING_TIMEOUT:-10s}
      - MESHSTREAM_MQTT_MAX_RECONNECT=${MESHSTREAM_MQTT_MAX_RECONNECT:-5m}
      - MESHSTREAM_MQTT_USE_TLS=${MESHSTREAM_MQTT_USE_TLS:-false}
      - MESHSTREAM_MQTT_TLS_PORT=${MESHSTREAM_MQTT_TLS_PORT:-8883}
      
      # Server configuration
      - MESHSTREAM_SERVER_HOST=${MESHSTREAM_SERVER_HOST:-0.0.0.0}
      - MESHSTREAM_SERVER_PORT=${MESHSTREAM_SERVER_PORT:-5446}
      - MESHSTREAM_STATIC_DIR=${MESHSTREAM_STATIC_DIR:-/app/static}
      
      # Logging and debugging
      - MESHSTREAM_LOG_LEVEL=${MESHSTREAM_LOG_LEVEL:-info}
      - MESHSTREAM_VERBOSE_LOGGING=${MESHSTREAM_VERBOSE_LOGGING:-false}
      - MESHSTREAM_CACHE_SIZE=${MESHSTREAM_CACHE_SIZE:-1000}
      
      # Channel keys for decryption
      - MESHSTREAM_CHANNEL_KEYS=${MESHSTREAM_CHANNEL_KEYS:-}
    restart: unless-stopped
    healthcheck:
      test: ["CMD", "wget", "-q", "--spider", "http://localhost:5446/api/status"]
      interval: 30s
      timeout: 5s
      retries: 3