# ==================================================
# docker-compose.yml -- local testing (Podman or Docker)
# ==================================================
services:
  marker-api:
    build:
      context: .
      dockerfile: Containerfile
    image: marker-api:latest
    env_file:
      - .env
    environment:
      - TORCH_DEVICE=${TORCH_DEVICE:-cpu}
      - MODEL_DTYPE=${MODEL_DTYPE:-float32}
      - OLLAMA_HOST=${OLLAMA_HOST:-http://localhost:11435}
      - DEESEEK_OCR_MODEL=${DEESEEK_OCR_MODEL:-}
      - OCR_BACKEND=${OCR_BACKEND:-marker}
      - DEEPSEEK_OLLAMA_HOST=${DEEPSEEK_OLLAMA_HOST:-http://host.containers.internal:11434}
      - DEEPSEEK_OCR_MODEL=${DEEPSEEK_OCR_MODEL:-deepseek-ocr:latest}
      - DEEPSEEK_OCR_PROMPT=${DEEPSEEK_OCR_PROMPT:-<|grounding|>Free OCR.}
      - API_KEY=${API_KEY:-}
      - SELF_URL=${SELF_URL:-http://localhost:8001}
      - LLM_SERVICE=${LLM_SERVICE:-marker.services.ollama.OllamaService}
      - USE_LLM=${USE_LLM:-false}
      - OPENAI_BASE_URL=${OPENAI_BASE_URL:-}
      - OPENAI_API_KEY=${OPENAI_API_KEY:-}
      - OPENAI_MODEL=${OPENAI_MODEL:-}
      - PORT=${PORT:-8001}
      - HOST=0.0.0.0
      - GUNICORN_WORKERS=${GUNICORN_WORKERS:-3}
      - GUNICORN_THREADS=${GUNICORN_THREADS:-2}
      - GUNICORN_TIMEOUT=${GUNICORN_TIMEOUT:-600}
    ports:
      - "${PORT:-8001}:${PORT:-8001}"
    volumes:
      - marker-results:/app/conversion_results:rw,Z
      - marker-cache:/app/.cache:rw,Z
    restart: unless-stopped
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:${PORT:-8001}/health"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 120s

volumes:
  marker-results:
  marker-cache:
