services:
  open-webui:
    image: ghcr.io/open-webui/open-webui:latest
    container_name: open-webui
    restart: unless-stopped
    # Changed from network_mode: host to bridge for security
    # Container reachable on LAN via 0.0.0.0:3081
    ports:
      - "0.0.0.0:3081:3081"
    extra_hosts:
      - "host.docker.internal:host-gateway"
    volumes:
      - /home/rurouni/openwebui-data:/app/backend/data
      - /home/rurouni/openwebui-overrides/tools.py:/app/backend/open_webui/utils/tools.py:ro
    environment:
      - PORT=3081
      - OLLAMA_BASE_URL=
      - OPENAI_API_BASE_URL=http://host.docker.internal:9292/v1
      - OPENAI_API_KEY=sk-no-...ired
      - HERMES_API_KEY=c2a18b6c8c041c94dd784dcf0a907956acdfffb87a0d59207245a2e23440eeb5
      - HERMES_API_URL=http://host.docker.internal:18789
      - CORS_ALLOW_ORIGIN=*
      - WEBUI_SECRET_KEY=1ee02b6cac60929e29fc6f9b1fe4a68e93d1be84784f198c3a312ebb67add65b
      - FORWARDED_ALLOW_IPS=*
      - SCARF_NO_ANALYTICS=true
      - DO_NOT_TRACK=true
      - ANONYMIZED_TELEMETRY=false
      - ENABLE_WEB_SEARCH=true
      - WEB_SEARCH_ENGINE=searxng
      - SEARXNG_QUERY_URL=http://host.docker.internal:8080/search?q=<query>&format=json
      - SEARXNG_LANGUAGE=all
      - BYPASS_WEB_SEARCH_EMBEDDING_AND_RETRIEVAL=true
      - WEB_SEARCH_RESULT_COUNT=10
      - ENABLE_IMAGE_GENERATION=true
      - ENABLE_MEMORIES=true
      - ENABLE_NOTES=true
      - ENABLE_FOLDERS=true
      - ENABLE_CHANNELS=false
      - ENABLE_CALENDAR=false
      - ENABLE_AUTOMATIONS=false
      - ENABLE_COMMUNITY_SHARING=false
      - ENABLE_SIGNUP=false
      - ENABLE_LOGIN_FORM=true
      - ENABLE_ADMIN_CHAT_ACCESS=true
      - ENABLE_DIRECT_CONNECTIONS=true
      - ENABLE_BASE_MODELS_CACHE=true
      - ENABLE_ASYNC_EMBEDDING=true
      - ENABLE_QUERIES_CACHE=true
      - ENABLE_EVALUATION_ARENA_MODELS=false
      - ENABLE_GOOGLE_DRIVE_INTEGRATION=false
      - ENABLE_IMAGE_EDIT=true
      - ENABLE_AUTOCOMPLETE_GENERATION=true
      - ENABLE_FOLLOW_UP_GENERATION=true
      - AIOHTTP_CLIENT_TIMEOUT=300
      - AIOHTTP_CLIENT_TIMEOUT_MODEL_LIST=10
      - AIOHTTP_POOL_CONNECTIONS=10
      - AIOHTTP_POOL_CONNECTIONS_PER_HOST=2
      - TERMINAL_SERVER_CONNECTIONS=[{"id":"debian-terminal","name":"Debian Terminal","url":"http://host.docker.internal:8000","key":"wuF7CugRfNJJOc1zG_-hWomh63wO29f4QdDnPZOagUw","auth_type":"bearer","server_type":"terminal"}]
    healthcheck:
      test: ["CMD", "curl", "-f", "http://127.0.0.1:3081/health"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 30s
