File size: 2,337 Bytes
15f1210
 
 
 
 
 
 
 
 
 
 
20edea9
 
 
 
 
15f1210
 
 
 
20edea9
e7c1485
 
 
20edea9
e7c1485
 
 
 
 
20edea9
 
15f1210
 
e7c1485
15f1210
 
 
20edea9
 
 
15f1210
e7c1485
20edea9
e7c1485
20edea9
 
15f1210
20edea9
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# QModel Docker Compose Configuration — production-safe base
# ============================================================
# This base file is safe to deploy as-is: it does NOT bind-mount the repo,
# so the image's own code is what runs. It ships with just the two data
# files mounted read-only (they're excluded from the built image via
# .dockerignore since they're large binaries that shouldn't bloat it or
# require a rebuild every time the dataset changes).
#
# For local development with live code reload, `docker-compose.override.yml`
# is picked up automatically and adds a full bind-mount on top of this.
#
# Configure via .env file:
#   LLM_BACKEND=ollama   (default: local Ollama on host machine)
#   LLM_BACKEND=hf       (HuggingFace backend)
#
# Usage:
#   docker-compose up                            # Dev (uses override.yml automatically)
#   docker-compose -f docker-compose.yml up -d    # Prod (base file only, no bind-mount)
#   docker-compose logs -f                        # View logs
#   docker-compose down                           # Stop services

services:
  qmodel:
    build: .
    container_name: qmodel-api
    ports:
      - "8000:8000"
    env_file:
      - .env
    environment:
      # Pass through HF token if using HuggingFace backend
      - HF_TOKEN=${HF_TOKEN:-}
      # Ollama host: override .env to use Docker host IP for container-to-host access
      - OLLAMA_HOST=http://host.docker.internal:11434
    volumes:
      # Data files: read-only, so a data update doesn't require an image rebuild
      - ./QModel.index:/app/QModel.index:ro
      - ./metadata.json:/app/metadata.json:ro
      # Cache HuggingFace models to avoid re-downloading
      - huggingface_cache:/root/.cache/huggingface
    # Restart automatically if container exits
    restart: on-failure:5
    extra_hosts:
      # Allow container to reach host.docker.internal on Mac/Windows
      - "host.docker.internal:host-gateway"
    networks:
      - qmodel-network
    # Health check for orchestration — /health returns 503 until ready
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 60s

networks:
  qmodel-network:
    driver: bridge

volumes:
  # Persistent cache for HuggingFace models
  huggingface_cache: