# SZR Knowledge Hub - Docker Compose

services:
  hub:
    build: ./backend
    container_name: szr-hub
    restart: unless-stopped
    ports:
      - "127.0.0.1:8001:8000"  # Bind to localhost only for security
    volumes:
      # Persist database
      - ./data:/app/data
      # Mount documentation (read-only)
      - ./docs:/app/docs:ro
    environment:
      - AI_API_KEY=${AI_API_KEY}
      - AI_API_BASE=${AI_API_BASE:-https://api.deepseek.com}
      - AI_MODEL=${AI_MODEL:-deepseek-chat}
      - SECRET_KEY=${SECRET_KEY}
      - DATABASE_URL=sqlite+aiosqlite:///./data/hub.db
      - DOCS_PATH=/app/docs
      - BASE_URL=${BASE_URL:-https://szr.glocalis.com/hub}
      - SMTP_SERVER=${SMTP_SERVER}
      - SMTP_PORT=${SMTP_PORT:-587}
      - SMTP_USER=${SMTP_USER}
      - SMTP_PASSWORD=${SMTP_PASSWORD}
      - ADMIN_EMAIL=${ADMIN_EMAIL}
    healthcheck:
      test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8000/api/health')"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 10s
