-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
236 lines (225 loc) · 7.99 KB
/
Copy pathdocker-compose.yml
File metadata and controls
236 lines (225 loc) · 7.99 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
# ── Profiles ──────────────────────────────────────────────────────────────────
#
# dev → infrastructure + dev tools (neo4j + redis + redisinsight)
# prod → full production stack (infra + api + ui + mcp + agents)
# gpu → Ollama with NVIDIA GPU support (use alongside dev or prod)
# cpu → Ollama CPU-only, no GPU required (use alongside dev or prod)
#
# Quick reference (see Makefile):
# docker compose --profile dev up -d # infra only
# docker compose --profile prod up -d # full stack (Ollama on host)
# docker compose --profile prod --profile gpu up # full stack + Ollama GPU
# docker compose --profile prod --profile cpu up # full stack + Ollama CPU
#
# ──────────────────────────────────────────────────────────────────────────────
services:
# ── Neo4j (Graph DB) ────────────────────────────────────────────────────────
neo4j:
container_name: kg-neo4j
profiles: [dev, prod]
image: neo4j:5.18
ports:
- "7474:7474"
- "7687:7687"
environment:
NEO4J_AUTH: "neo4j/${NEO4J_PASSWORD}"
NEO4J_PLUGINS: '["apoc"]'
volumes:
- neo4j_data:/data
- neo4j_logs:/logs
healthcheck:
test:
[
"CMD",
"cypher-shell",
"-u",
"neo4j",
"-p",
"${NEO4J_PASSWORD}",
"RETURN 1",
]
interval: 30s
timeout: 10s
retries: 5
# ── Redis Stack (Vector Store) ───────────────────────────────────────────────
redis:
container_name: kg-redis
profiles: [dev, prod]
image: redis/redis-stack:latest
ports:
- "6379:6379"
- "8001:8001"
volumes:
- redis_data:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 15s
timeout: 5s
retries: 3
# ── Ollama GPU (NVIDIA) ──────────────────────────────────────────────────────
# Use profile "gpu" on machines with an NVIDIA GPU.
# If Ollama is already running on the host, omit both ollama profiles and
# set OLLAMA_BASE_URL=http://host.docker.internal:11434 in your .env instead.
ollama-gpu:
container_name: kg-ollama-gpu
profiles: [gpu]
build:
context: ./infra/ollama
dockerfile: Dockerfile
environment:
- OLLAMA_MODELS=${OLLAMA_MODELS:-nomic-embed-text qwen2.5:14b}
ports:
- "127.0.0.1:11434:11434"
volumes:
- ollama_models:/root/.ollama
healthcheck:
test: ["CMD", "curl", "-sf", "http://localhost:11434/api/tags"]
interval: 30s
timeout: 10s
retries: 10
start_period: 120s
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: all
capabilities: [gpu]
# ── Ollama CPU-only (no GPU required) ────────────────────────────────────────
# Use profile "cpu" on machines without NVIDIA GPU.
ollama-cpu:
container_name: kg-ollama-cpu
profiles: [cpu]
build:
context: ./infra/ollama
dockerfile: Dockerfile
environment:
- OLLAMA_MODELS=${OLLAMA_MODELS:-nomic-embed-text qwen2.5:14b}
ports:
- "127.0.0.1:11434:11434"
volumes:
- ollama_models:/root/.ollama
healthcheck:
test: ["CMD", "curl", "-sf", "http://localhost:11434/api/tags"]
interval: 30s
timeout: 10s
retries: 10
start_period: 120s
# ── API (FastAPI / Python) ───────────────────────────────────────────────────
api:
container_name: kg-api
profiles: [prod]
build:
context: ./knowledge-graph-api
dockerfile: Dockerfile
ports:
- "8000:8000"
# OLLAMA_BASE_URL is read from .env:
# default prod → http://host.docker.internal:11434 (Ollama on host)
# profile gpu → http://ollama-gpu:11434
# profile cpu → http://ollama-cpu:11434
env_file: .env
depends_on:
neo4j:
condition: service_healthy
redis:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
interval: 30s
timeout: 10s
retries: 3
# ── UI (Next.js) ─────────────────────────────────────────────────────────────
ui:
container_name: kg-ui
profiles: [prod]
build:
context: ./knowledge-graph-ui
dockerfile: Dockerfile
args:
- NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL:-http://localhost:8000}
ports:
- "3000:3000"
environment:
- NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL:-http://localhost:8000}
- NEXT_PUBLIC_ENABLE_STREAMING=${NEXT_PUBLIC_ENABLE_STREAMING:-true}
- NEXT_PUBLIC_ENABLE_GRAPH_VIEW=${NEXT_PUBLIC_ENABLE_GRAPH_VIEW:-true}
depends_on:
api:
condition: service_healthy
healthcheck:
test: ["CMD", "wget", "-q", "--spider", "http://localhost:3000"]
interval: 30s
timeout: 10s
retries: 3
# ── MCP Server ───────────────────────────────────────────────────────────────
mcp:
container_name: kg-mcp
profiles: [prod]
build:
context: ./knowledge-graph-mcp
dockerfile: Dockerfile
ports:
- "8080:8080"
environment:
- KG_API_URL=http://api:8000
- MCP_TRANSPORT=sse
- MCP_HOST=0.0.0.0
- MCP_PORT=8080
- KG_API_TIMEOUT=600
depends_on:
api:
condition: service_healthy
healthcheck:
test: ["CMD-SHELL", "python3 -c \"import socket; socket.create_connection(('localhost', 8080), 3).close()\""]
interval: 15s
timeout: 10s
retries: 5
start_period: 30s
# ── Agents (Multi-Agent Orchestration) ──────────────────────────────────────
agents:
container_name: kg-agents
profiles: [prod]
build:
context: ./knowledge-graph-agents
dockerfile: Dockerfile
ports:
- "8002:8001"
environment:
- KG_MCP_URL=http://mcp:8080
- KG_API_URL=http://api:8000
- OLLAMA_BASE_URL=${OLLAMA_BASE_URL:-http://host.docker.internal:11434}
- OLLAMA_LLM_MODEL=${OLLAMA_LLM_MODEL:-qwen2.5:14b}
- KG_API_TIMEOUT=60
depends_on:
mcp:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8001/agents/health"]
interval: 30s
timeout: 10s
retries: 3
# ── RedisInsight ─────────────────────────────────────────────────────────────
# Web UI for browsing Redis keys, data structures and vectors.
# Access: http://localhost:5540
# First-time setup: add connection → host: redis port: 6379
redisinsight:
container_name: kg-redisinsight
profiles: [dev, prod]
image: redis/redisinsight:latest
ports:
- "5540:5540"
volumes:
- redisinsight_data:/data
depends_on:
redis:
condition: service_healthy
volumes:
neo4j_data:
neo4j_logs:
redis_data:
ollama_models:
redisinsight_data:
networks:
default:
name: kg_network