Repository navigation
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
123 lines (117 loc) · 3.84 KB
/
Copy pathdocker-compose.yml
File metadata and controls
123 lines (117 loc) · 3.84 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
services:
# ── Ollama: local LLM runtime ────────────────────────────────────────────
ollama:
image: ollama/ollama:latest
container_name: gateway-ollama
restart: unless-stopped
ports:
- "11434:11434"
volumes:
- ollama_data:/root/.ollama
healthcheck:
test: ["CMD", "ollama", "list"]
interval: 10s
timeout: 5s
retries: 10
start_period: 30s
# One-shot init: pulls the models the gateway is configured to serve, read
# from the same settings (.env) as the gateway, so there is no second list.
# Exits 0 once the models are present: gateway depends on this completing.
ollama-init:
build:
context: .
dockerfile: Dockerfile
container_name: gateway-ollama-init
depends_on:
ollama:
condition: service_healthy
env_file:
- path: .env
required: false
environment:
GATEWAY_OLLAMA_BASE_URL: http://ollama:11434
command: ["python", "-m", "llm_gateway.pull_models"]
restart: "no"
# ── Redis: token bucket rate limiter ─────────────────────────────────────
redis:
image: redis:7-alpine
container_name: gateway-redis
restart: unless-stopped
ports:
- "6379:6379"
volumes:
- redis_data:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 3s
retries: 10
# ── Prometheus: scrapes the gateway /metrics ─────────────────────────────
prometheus:
image: prom/prometheus:latest
container_name: gateway-prometheus
restart: unless-stopped
ports:
- "9090:9090"
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml:ro
- prometheus_data:/prometheus
command:
- "--config.file=/etc/prometheus/prometheus.yml"
- "--storage.tsdb.path=/prometheus"
- "--storage.tsdb.retention.time=7d"
# ── Grafana: pre-provisioned dashboards ──────────────────────────────────
grafana:
image: grafana/grafana:latest
container_name: gateway-grafana
restart: unless-stopped
depends_on:
- prometheus
ports:
- "3000:3000"
environment:
GF_SECURITY_ADMIN_USER: admin
GF_SECURITY_ADMIN_PASSWORD: admin
GF_AUTH_ANONYMOUS_ENABLED: "true"
GF_AUTH_ANONYMOUS_ORG_ROLE: Viewer
GF_USERS_ALLOW_SIGN_UP: "false"
volumes:
- ./grafana/provisioning:/etc/grafana/provisioning:ro
- ./grafana/dashboards:/var/lib/grafana/dashboards:ro
- grafana_data:/var/lib/grafana
# ── Gateway: the FastAPI app ─────────────────────────────────────────────
gateway:
build:
context: .
dockerfile: Dockerfile
container_name: gateway-app
restart: unless-stopped
depends_on:
ollama:
condition: service_healthy
ollama-init:
condition: service_completed_successfully
redis:
condition: service_healthy
ports:
- "8000:8000"
env_file:
- path: .env
required: false
environment:
GATEWAY_OLLAMA_BASE_URL: http://ollama:11434
GATEWAY_REDIS_URL: redis://redis:6379/0
GATEWAY_DB_PATH: /app/data/gateway.db
GATEWAY_TEAMS_YAML: /app/config/teams.yaml
GATEWAY_LOG_LEVEL: INFO
volumes:
- gateway_data:/app/data
# Mounted read-only so operators can edit teams.yaml without rebuilding
# the image. config/teams.yaml is gitignored: copy teams.example.yaml.
- ./config:/app/config:ro
volumes:
ollama_data:
redis_data:
prometheus_data:
grafana_data:
gateway_data: