-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
214 lines (207 loc) · 7.08 KB
/
Copy pathdocker-compose.yml
File metadata and controls
214 lines (207 loc) · 7.08 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
services:
# ==========================================================================
# Cold tier: Neo4j (graph source of truth)
# ==========================================================================
neo4j:
image: neo4j:5.26
container_name: cogram-neo4j
ports:
- "7474:7474"
- "7687:7687"
environment:
NEO4J_AUTH: neo4j/password
NEO4J_PLUGINS: '["apoc"]'
NEO4J_dbms_security_procedures_unrestricted: apoc.*
NEO4J_server_memory_heap_max__size: ${NEO4J_HEAP:-512m}
NEO4J_server_memory_pagecache_size: ${NEO4J_PAGECACHE:-256m}
volumes:
- neo4j_data:/data
- neo4j_logs:/logs
healthcheck:
test: ["CMD-SHELL", "wget -O - --quiet http://localhost:7474 || exit 1"]
interval: 10s
timeout: 5s
retries: 12
networks:
- cogram
# ==========================================================================
# Hot tier: Redis (active subgraph cache)
# ==========================================================================
redis:
image: redis:7-alpine
container_name: cogram-redis
command: ["redis-server", "/usr/local/etc/redis/redis.conf"]
ports:
- "6379:6379"
volumes:
- redis_data:/data
- ./containers/redis/redis.conf:/usr/local/etc/redis/redis.conf:ro
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 3s
retries: 5
networks:
- cogram
# ==========================================================================
# Warm tier: Postgres (Engram decision cache + audit + training_data)
# ==========================================================================
postgres:
image: postgres:16-alpine
container_name: cogram-postgres
ports:
- "5432:5432"
environment:
POSTGRES_USER: cogram
POSTGRES_PASSWORD: cogram
POSTGRES_DB: cogram
volumes:
- postgres_data:/var/lib/postgresql/data
- ./containers/postgres/init.sql:/docker-entrypoint-initdb.d/init.sql:ro
healthcheck:
test: ["CMD-SHELL", "pg_isready -U cogram -d cogram"]
interval: 5s
timeout: 3s
retries: 10
networks:
- cogram
# ==========================================================================
# Cogram MCP server (stdio + HTTP/SSE on :7800/mcp)
# Image: pulled from ghcr.io by default. If unavailable (offline / fork),
# falls back to building from local source via the build: block.
# ==========================================================================
cogram-mcp:
image: ghcr.io/srk0102/cogram-mcp:latest
pull_policy: missing
build:
context: .
dockerfile: containers/cogram-mcp/Dockerfile
container_name: cogram-mcp
ports:
- "7800:7800"
environment:
OPENAI_API_KEY: ${OPENAI_API_KEY:?set OPENAI_API_KEY in .env}
OPENAI_BASE_URL: ${OPENAI_BASE_URL:-https://api.openai.com/v1}
GRAPHITI_LLM_MODEL: ${GRAPHITI_LLM_MODEL:-gpt-4o-mini}
ANNOTATOR_LLM_MODEL: ${ANNOTATOR_LLM_MODEL:-gpt-4o-mini}
EMBEDDING_MODEL: ${EMBEDDING_MODEL:-text-embedding-3-small}
EMBEDDING_DIM: ${EMBEDDING_DIM:-1536}
RATE_LIMIT_PER_MIN: ${RATE_LIMIT_PER_MIN:-150}
NEO4J_URI: bolt://neo4j:7687
NEO4J_USER: neo4j
NEO4J_PASSWORD: password
REDIS_URL: redis://redis:6379/0
POSTGRES_DSN: postgresql://cogram:cogram@postgres:5432/cogram
TRAINER_URL: http://cogram-trainer:7900
MCP_HTTP_PORT: 7800
MAX_DAILY_INGEST_CALLS: ${MAX_DAILY_INGEST_CALLS:-300}
COGRAM_FULL_PIPELINE: "true"
volumes:
- cogram_episodes:/app/episodes
- cogram_cache:/app/cache
depends_on:
neo4j:
condition: service_healthy
redis:
condition: service_healthy
postgres:
condition: service_healthy
healthcheck:
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:7800/health')"]
interval: 60s
timeout: 5s
retries: 5
start_period: 20s
networks:
- cogram
# ==========================================================================
# Cogram trainer (Qwen / Gemma + PEFT + LoRA scheduler)
# GPU optional; falls back to CPU. Uses VRAM coexistence (5-layer).
#
# Purpose: trains per-node LoRA adapters from accumulated synthesis pairs in
# engram.training_data. Once trained, those adapters REPLACE Gemma for that
# node's narrations — smaller, faster, personalized to the user's voice.
#
# Opt-in only: requires `--profile training` to start, since it needs ≥50
# samples per node before doing anything useful (months of normal usage).
# `docker compose up` skips trainer; `docker compose --profile training up`
# brings it in.
# ==========================================================================
cogram-trainer:
profiles: ["training"]
build:
context: .
dockerfile: containers/cogram-trainer/Dockerfile
container_name: cogram-trainer
ports:
- "7900:7900"
environment:
POSTGRES_DSN: postgresql://cogram:cogram@postgres:5432/cogram
BASE_MODEL: ${BASE_MODEL:-Qwen/Qwen2.5-1.5B-Instruct}
TRAINER_VRAM_FRACTION: ${TRAINER_VRAM_FRACTION:-0.40}
TRAINER_GPU_UTIL_PAUSE: ${TRAINER_GPU_UTIL_PAUSE:-50}
TRAINER_SCHEDULE: ${TRAINER_SCHEDULE:-02:00-06:00}
TRAINER_REQUIRE_USER_IDLE: ${TRAINER_REQUIRE_USER_IDLE:-false}
TRAINER_MIN_SAMPLES: ${TRAINER_MIN_SAMPLES:-20}
TRAINER_MIN_DAYS_BETWEEN: ${TRAINER_MIN_DAYS_BETWEEN:-7}
HF_HOME: /app/hf_cache
volumes:
- cogram_adapters:/cogram/adapters
- cogram_hf_cache:/app/hf_cache
deploy:
resources:
limits:
memory: 8G
reservations:
devices:
- driver: nvidia
count: all
capabilities: [gpu]
depends_on:
postgres:
condition: service_healthy
networks:
- cogram
# If you have no NVIDIA GPU, comment out the deploy.resources block above.
# ==========================================================================
# Cogram dashboard (FastAPI + force-graph viz + live metrics on :7801)
# Image: pulled from ghcr.io by default. Falls back to local build.
# ==========================================================================
cogram-dashboard:
image: ghcr.io/srk0102/cogram-dashboard:latest
pull_policy: missing
build:
context: .
dockerfile: containers/cogram-dashboard/Dockerfile
container_name: cogram-dashboard
ports:
- "7801:7801"
environment:
NEO4J_URI: bolt://neo4j:7687
NEO4J_USER: neo4j
NEO4J_PASSWORD: password
REDIS_URL: redis://redis:6379/0
POSTGRES_DSN: postgresql://cogram:cogram@postgres:5432/cogram
MCP_URL: http://cogram-mcp:7800
DASHBOARD_PORT: 7801
depends_on:
neo4j:
condition: service_healthy
redis:
condition: service_healthy
postgres:
condition: service_healthy
networks:
- cogram
volumes:
neo4j_data:
neo4j_logs:
redis_data:
postgres_data:
cogram_episodes:
cogram_cache:
cogram_adapters:
cogram_hf_cache:
networks:
cogram:
driver: bridge