Skip to content

Commit ddd1cee

Browse files
authored
Merge pull request #197 from Context-Engine-AI/feature/yaml-anchors-optimization
refactor: optimize Docker Compose with YAML anchors and aliases
2 parents efd1928 + 2c3d0a9 commit ddd1cee

3 files changed

Lines changed: 161 additions & 146 deletions

File tree

docker-compose-bindmount-checkout.yml

Lines changed: 49 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,31 @@
1+
# YAML Anchors for common configurations
2+
x-common-config: &common-config
3+
env_file:
4+
- .env
5+
depends_on:
6+
- qdrant
7+
8+
x-work-dir: &work-dir
9+
working_dir: /work
10+
11+
x-huggingface-cache: &hf-cache
12+
HF_HOME: /tmp/huggingface
13+
HF_HUB_CACHE: /tmp/huggingface/hub
14+
HUGGINGFACE_HUB_CACHE: /tmp/huggingface/hub
15+
TRANSFORMERS_CACHE: /tmp/huggingface/transformers
16+
FASTEMBED_CACHE_PATH: /tmp/huggingface/fastembed
17+
HF_HUB_DISABLE_XET: 1
18+
19+
x-embedding-config: &embedding-config
20+
EMBEDDING_MODEL: ${EMBEDDING_MODEL}
21+
QWEN3_EMBEDDING_ENABLED: ${QWEN3_EMBEDDING_ENABLED:-0}
22+
QWEN3_QUERY_INSTRUCTION: ${QWEN3_QUERY_INSTRUCTION:-1}
23+
QWEN3_INSTRUCTION_TEXT: ${QWEN3_INSTRUCTION_TEXT}
24+
25+
x-standard-volumes: &standard-volumes
26+
- ${HOST_INDEX_PATH:-.}:/work:ro
27+
- ${HOST_INDEX_PATH:-.}/.codebase:/work/.codebase:rw
28+
129
services:
230
qdrant:
331
image: qdrant/qdrant:latest
@@ -75,7 +103,6 @@ services:
75103
volumes:
76104
- ${HOST_INDEX_PATH:-.}:/work
77105

78-
79106
mcp_http:
80107
build:
81108
context: .
@@ -160,7 +187,7 @@ services:
160187
- "8080:8080"
161188
volumes:
162189
- ./models:/models:ro
163-
entrypoint: ["/bin/sh","-lc"]
190+
entrypoint: [ "/bin/sh", "-lc" ]
164191
command:
165192
- |
166193
set -e
@@ -186,67 +213,35 @@ services:
186213
exec /app/llama-server $$ARGS
187214
188215
indexer:
216+
<<: [ *common-config, *work-dir ]
189217
build:
190218
context: .
191219
dockerfile: Dockerfile.indexer
192-
depends_on:
193-
- qdrant
194-
env_file:
195-
- .env
196220
environment:
197-
- QDRANT_URL=${QDRANT_URL}
198-
- COLLECTION_NAME=${COLLECTION_NAME:-codebase}
199-
- HF_HOME=/tmp/huggingface
200-
- HF_HUB_CACHE=/tmp/huggingface/hub
201-
- HUGGINGFACE_HUB_CACHE=/tmp/huggingface/hub
202-
- TRANSFORMERS_CACHE=/tmp/huggingface/transformers
203-
- FASTEMBED_CACHE_PATH=/tmp/huggingface/fastembed
204-
- HF_HUB_DISABLE_XET=1
205-
- EMBEDDING_MODEL=${EMBEDDING_MODEL}
206-
- QWEN3_EMBEDDING_ENABLED=${QWEN3_EMBEDDING_ENABLED:-0}
207-
- QWEN3_QUERY_INSTRUCTION=${QWEN3_QUERY_INSTRUCTION:-1}
208-
- QWEN3_INSTRUCTION_TEXT=${QWEN3_INSTRUCTION_TEXT}
209-
working_dir: /work
210-
volumes:
211-
- ${HOST_INDEX_PATH:-.}:/work:ro
212-
- ${HOST_INDEX_PATH:-.}/.codebase:/work/.codebase:rw
213-
214-
entrypoint: ["sh", "-c", "mkdir -p /tmp/huggingface/hub /tmp/huggingface/transformers /tmp/huggingface/fastembed && exec python /app/scripts/ingest_code.py"]
221+
<<: [ *hf-cache, *embedding-config ]
222+
QDRANT_URL: ${QDRANT_URL}
223+
COLLECTION_NAME: ${COLLECTION_NAME:-codebase}
224+
volumes: *standard-volumes
225+
entrypoint: [ "sh", "-c", "mkdir -p /tmp/huggingface/hub /tmp/huggingface/transformers /tmp/huggingface/fastembed && exec python /app/scripts/ingest_code.py" ]
215226

216227
watcher:
228+
<<: [ *common-config, *work-dir ]
217229
build:
218230
context: .
219231
dockerfile: Dockerfile.indexer
220-
depends_on:
221-
- qdrant
222-
env_file:
223-
- .env
224232
environment:
225-
- QDRANT_URL=${QDRANT_URL}
226-
- COLLECTION_NAME=${COLLECTION_NAME:-codebase}
227-
- HF_HOME=/tmp/huggingface
228-
- HF_HUB_CACHE=/tmp/huggingface/hub
229-
- HUGGINGFACE_HUB_CACHE=/tmp/huggingface/hub
230-
- TRANSFORMERS_CACHE=/tmp/huggingface/transformers
231-
- FASTEMBED_CACHE_PATH=/tmp/huggingface/fastembed
232-
- HF_HUB_DISABLE_XET=1
233-
- EMBEDDING_MODEL=${EMBEDDING_MODEL}
234-
- QWEN3_EMBEDDING_ENABLED=${QWEN3_EMBEDDING_ENABLED:-0}
235-
- QWEN3_QUERY_INSTRUCTION=${QWEN3_QUERY_INSTRUCTION:-1}
236-
- QWEN3_INSTRUCTION_TEXT=${QWEN3_INSTRUCTION_TEXT}
237-
- WATCH_ROOT=/work
233+
<<: [ *hf-cache, *embedding-config ]
234+
QDRANT_URL: ${QDRANT_URL}
235+
COLLECTION_NAME: ${COLLECTION_NAME:-codebase}
236+
WATCH_ROOT: /work
238237
# Watcher-specific backpressure & timeouts (safer defaults)
239-
- QDRANT_TIMEOUT=60
240-
- MAX_MICRO_CHUNKS_PER_FILE=${MAX_MICRO_CHUNKS_PER_FILE:-200}
241-
- INDEX_UPSERT_BATCH=128
242-
- INDEX_UPSERT_RETRIES=5
243-
- WATCH_DEBOUNCE_SECS=${WATCH_DEBOUNCE_SECS:-1.5}
244-
working_dir: /work
245-
volumes:
246-
- ${HOST_INDEX_PATH:-.}:/work:ro
247-
- ${HOST_INDEX_PATH:-.}/.codebase:/work/.codebase:rw
248-
entrypoint: ["sh", "-c", "mkdir -p /tmp/huggingface/hub /tmp/huggingface/transformers /tmp/huggingface/fastembed && exec python /app/scripts/watch_index.py"]
249-
238+
QDRANT_TIMEOUT: 60
239+
MAX_MICRO_CHUNKS_PER_FILE: ${MAX_MICRO_CHUNKS_PER_FILE:-200}
240+
INDEX_UPSERT_BATCH: 128
241+
INDEX_UPSERT_RETRIES: 5
242+
WATCH_DEBOUNCE_SECS: ${WATCH_DEBOUNCE_SECS:-1.5}
243+
volumes: *standard-volumes
244+
entrypoint: [ "sh", "-c", "mkdir -p /tmp/huggingface/hub /tmp/huggingface/transformers /tmp/huggingface/fastembed && exec python /app/scripts/watch_index.py" ]
250245

251246
upload_service:
252247
build:
@@ -277,7 +272,7 @@ services:
277272
- ${HOST_INDEX_PATH:-.}/.codebase:/work/.codebase:rw
278273
user: "0:0"
279274
healthcheck:
280-
test: ["CMD", "curl", "-f", "http://localhost:8002/health"]
275+
test: [ "CMD", "curl", "-f", "http://localhost:8002/health" ]
281276
interval: 30s
282277
timeout: 10s
283278
retries: 3
@@ -300,7 +295,7 @@ services:
300295
- ${HOST_INDEX_PATH:-.}:/work:ro
301296
- ${HOST_INDEX_PATH:-.}/.codebase:/work/.codebase:rw
302297

303-
entrypoint: ["python", "/app/scripts/create_indexes.py"]
298+
entrypoint: [ "python", "/app/scripts/create_indexes.py" ]
304299

305300
volumes:
306301
qdrant_storage:

docker-compose.openlit.yml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,19 @@
44
# This adds OpenLit observability to your existing Context-Engine stack.
55
# Dashboard: http://localhost:3000 (login: user@openlit.io / openlituser)
66

7+
# YAML Anchors for reusable configurations
8+
x-clickhouse-health-condition: &clickhouse-health-condition
9+
clickhouse:
10+
condition: service_healthy
11+
712
services:
813
# ClickHouse - storage backend for OpenLit
914
clickhouse:
1015
image: clickhouse/clickhouse-server:24.4.1
1116
container_name: openlit-clickhouse
1217
ports:
13-
- "9000:9000" # Native protocol (for OTEL exporter)
14-
- "8123:8123" # HTTP interface (for dashboard queries)
18+
- "9000:9000" # Native protocol (for OTEL exporter)
19+
- "8123:8123" # HTTP interface (for dashboard queries)
1520
volumes:
1621
- clickhouse_data:/var/lib/clickhouse
1722
- ./config/clickhouse-config.xml:/etc/clickhouse-server/config.d/custom-config.xml:ro
@@ -20,7 +25,7 @@ services:
2025
- CLICKHOUSE_PASSWORD=OPENLIT
2126
- CLICKHOUSE_USER=default
2227
healthcheck:
23-
test: ["CMD", "clickhouse-client", "--query", "SELECT 1"]
28+
test: [ "CMD", "clickhouse-client", "--query", "SELECT 1" ]
2429
interval: 10s
2530
timeout: 5s
2631
retries: 5
@@ -32,9 +37,9 @@ services:
3237
image: ghcr.io/openlit/openlit:latest
3338
container_name: openlit-dashboard
3439
ports:
35-
- "3000:3000" # Dashboard UI
36-
- "4317:4317" # OTLP gRPC receiver
37-
- "4318:4318" # OTLP HTTP receiver
40+
- "3000:3000" # Dashboard UI
41+
- "4317:4317" # OTLP gRPC receiver
42+
- "4318:4318" # OTLP HTTP receiver
3843
environment:
3944
- INIT_DB_HOST=clickhouse
4045
- INIT_DB_PORT=8123
@@ -45,9 +50,7 @@ services:
4550
volumes:
4651
- openlit_data:/app/client/data
4752
- ./config/otel-collector-config.yaml:/etc/otel/otel-collector-config.yaml:ro
48-
depends_on:
49-
clickhouse:
50-
condition: service_healthy
53+
depends_on: *clickhouse-health-condition
5154
networks:
5255
- dev-remote-network
5356

0 commit comments

Comments
 (0)