* Dockerfile: python:3.12-slim, layer-cached requirements first, COPY lore_engine_poc/scripts, bake .graph.pkl, EXPOSE 8765, HEALTHCHECK via stdlib urllib against POST /mcp initialize. CMD runs scripts/06_mcp_http_server.py --host 0.0.0.0. * .dockerignore: exclude __pycache__, tests/, .git/, data/raw/, etc. * docker-compose.yml: one service lore-engine-mcp, port 8765:8765 (overridable via $LORE_HTTP_PORT), bind mount for graph override (commented), healthcheck. Image tag overridable via $TAG. * tests/test_mcp/test_dockerfile.py: 4 tests gated on docker availability. Build, run + round-trip, compose up + round-trip, healthcheck reaches 'healthy'. All 4 pass on this host. 550 -> 554 green.
28 lines
1.2 KiB
YAML
28 lines
1.2 KiB
YAML
services:
|
|
lore-engine-mcp:
|
|
build: .
|
|
image: lore-engine-mcp:${TAG:-slice11}
|
|
container_name: lore-engine-mcp
|
|
restart: unless-stopped
|
|
ports:
|
|
- "${LORE_HTTP_PORT:-8765}:8765"
|
|
environment:
|
|
LORE_HTTP_HOST: "0.0.0.0"
|
|
LORE_HTTP_PORT: "8765"
|
|
# LORE_GRAPH_PATH: "/data/.graph.pkl" # uncomment + add volume below to override
|
|
# volumes:
|
|
# # Optional: mount a fresh graph without rebuilding the image.
|
|
# # Build via `python3 scripts/01_ingest.py --out data/.graph.pkl` first.
|
|
# - ./lore_engine_poc/data:/data:ro
|
|
healthcheck:
|
|
# Same path an MCP client would use. Mirrors the Dockerfile HEALTHCHECK.
|
|
test:
|
|
- "CMD"
|
|
- "python"
|
|
- "-c"
|
|
- "import json, urllib.request; r = urllib.request.urlopen(urllib.request.Request('http://127.0.0.1:8765/mcp', method='POST', data=json.dumps({'jsonrpc':'2.0','id':1,'method':'initialize','params':{}}).encode(), headers={'Content-Type':'application/json','Accept':'application/json'}), timeout=3); assert json.loads(r.read())['result']['protocolVersion'] == '2024-11-05'"
|
|
interval: 30s
|
|
timeout: 5s
|
|
retries: 3
|
|
start_period: 5s
|