# Minder Academy Reference Deployment Stack
#
# A minimal self-hosted LLM stack: inference server + vector database.
# Runs on any Docker-capable host (Linux server, workstation, or cloud VM).
#
# Services:
#   qdrant  - vector database for RAG pipelines (port 6333 HTTP / 6334 gRPC)
#   vllm    - OpenAI-compatible inference server (requires NVIDIA GPU)
#   ollama  - simpler alternative to vLLM (uncomment if preferred)
#
# Quick start:
#   1. cp .env.example .env       # set your model and credentials
#   2. docker compose up -d
#   3. curl http://localhost:8000/v1/models
#
# No GPU? Comment out the vllm service and use the ollama CPU image, or
# point your application at any OpenAI-compatible remote endpoint.

services:
  # ============================================
  # QDRANT - Vector Database
  # ============================================
  qdrant:
    image: qdrant/qdrant:v1.19.1
    container_name: academy-qdrant
    ports:
      - "6333:6333"  # REST API
      - "6334:6334"  # gRPC
    volumes:
      - ./data/qdrant:/qdrant/storage
    environment:
      - QDRANT__STORAGE__OPTIMIZER_CPU_BUDGET=2
    restart: unless-stopped
    networks:
      - academy-net
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:6333/health"]
      interval: 30s
      timeout: 10s
      retries: 3

  # ============================================
  # VLLM - High-Performance Inference (GPU)
  # Requires: NVIDIA Container Toolkit on the host
  # ============================================
  vllm:
    image: vllm/vllm-openai:v0.30.0
    container_name: academy-vllm
    ports:
      - "8000:8000"
    volumes:
      - ./data/hf-cache:/root/.cache/huggingface
    environment:
      # Model must fit your VRAM. An 8B AWQ-quantized model fits comfortably
      # on an 11GB VRAM GPU; pick a larger model for bigger cards.
      - MODEL=${MODEL:-Qwen/Qwen3-8B-AWQ}
      - HF_TOKEN=${HF_TOKEN:-}
      - TENSOR_PARALLEL_SIZE=1
      - GPU_MEMORY_UTILIZATION=0.85
      - MAX_MODEL_LEN=${MAX_MODEL_LEN:-8192}
    command: >
      --model ${MODEL:-Qwen/Qwen3-8B-AWQ}
      --tensor-parallel-size 1
      --gpu-memory-utilization 0.85
      --max-model-len ${MAX_MODEL_LEN:-8192}
      --quantization awq
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: 1
              capabilities: [gpu]
    restart: unless-stopped
    networks:
      - academy-net

  # ============================================
  # OLLAMA - Simpler Alternative to vLLM
  # Uncomment to use instead of vllm (works CPU-only too)
  # ============================================
  # ollama:
  #   image: ollama/ollama:latest
  #   container_name: academy-ollama
  #   ports:
  #     - "11434:11434"
  #   volumes:
  #     - ./data/ollama:/root/.ollama
  #   environment:
  #     - OLLAMA_HOST=0.0.0.0
  #   deploy:
  #     resources:
  #       reservations:
  #         devices:
  #           - driver: nvidia
  #             count: 1
  #             capabilities: [gpu]
  #   restart: unless-stopped
  #   networks:
  #     - academy-net

networks:
  academy-net:
    driver: bridge
