---
estimated_steps: 37
estimated_files: 3
skills_used: []
---

# T01: Add LightRAG service to Docker Compose and create .env.lightrag

Add the chrysopedia-lightrag service definition to docker-compose.yml and create the .env.lightrag configuration file. This is the infrastructure config task — all file changes are local, verified with `docker compose config`.

## Steps

1. Read the existing `docker-compose.yml` to understand the current service layout, network, and patterns.
2. Add the `chrysopedia-lightrag` service to `docker-compose.yml` after the `chrysopedia-ollama` service (before the application services). Use:
   - Image: `ghcr.io/hkuds/lightrag:latest`
   - Container name: `chrysopedia-lightrag`
   - Port: `127.0.0.1:9621:9621`
   - Volume: `/vmPool/r/services/chrysopedia_lightrag:/app/data`
   - env_file: `.env.lightrag`
   - Environment: `TIKTOKEN_CACHE_DIR=/app/data/tiktoken`
   - depends_on: `chrysopedia-qdrant` (service_healthy), `chrysopedia-ollama` (service_healthy)
   - Network: `chrysopedia`
   - Health check: `curl -sf http://localhost:9621/health || exit 1` with interval 15s, timeout 5s, retries 5, start_period 30s
   - restart: unless-stopped
3. Create `.env.lightrag` with these settings:
   - `HOST=0.0.0.0`, `PORT=9621`, `WORKSPACE=chrysopedia`
   - LLM: `LLM_BINDING=openai`, `LLM_MODEL=fyn-llm-agent-chat`, `LLM_BINDING_HOST=https://chat.forgetyour.name/api`, `LLM_BINDING_API_KEY=` (placeholder — to be set on ub01)
   - Embedding: `EMBEDDING_BINDING=ollama`, `EMBEDDING_BINDING_HOST=http://chrysopedia-ollama:11434`, `EMBEDDING_MODEL=nomic-embed-text`, `EMBEDDING_DIM=768`
   - Storage: `LIGHTRAG_VECTOR_STORAGE=QdrantVectorDBStorage`, `QDRANT_URL=http://chrysopedia-qdrant:6333`, `LIGHTRAG_GRAPH_STORAGE=NetworkXStorage`
   - Entity types: `ENTITY_TYPES=["Creator", "Technique", "Plugin", "Synthesizer", "Effect", "Genre", "DAW", "SamplePack", "SignalChain", "Concept", "Frequency", "SoundDesignElement"]`
   - Cache: `ENABLE_LLM_CACHE_FOR_EXTRACT=true`
4. Add `.env.lightrag` to `.gitignore` if not already covered by a wildcard pattern. Check if `.env*` or `.env.lightrag` is already ignored.
5. Run `docker compose config` to validate — must exit 0 with no errors.

## Must-Haves

- [ ] chrysopedia-lightrag service in docker-compose.yml with correct image, ports, volumes, depends_on, healthcheck
- [ ] .env.lightrag with all required LightRAG configuration
- [ ] .env.lightrag excluded from git tracking
- [ ] `docker compose config` exits 0

## Verification

- `docker compose config 2>&1 | grep -q chrysopedia-lightrag && echo PASS || echo FAIL`
- `docker compose config` exits 0 (validates all service definitions, env var references, network config)
- `grep -q 'env.lightrag' .gitignore && echo PASS || echo FAIL`

## Failure Modes

| Dependency | On error | On timeout | On malformed response |
|------------|----------|-----------|----------------------|
| docker compose config | Fix syntax error in compose file | N/A | N/A |
| .env.lightrag file | Verify all env var names match LightRAG's expected names | N/A | N/A |

## Inputs

- ``docker-compose.yml` — existing Docker Compose stack definition`
- ``.env.example` — reference for existing env var patterns`
- ``.gitignore` — check if .env files are already excluded`

## Expected Output

- ``docker-compose.yml` — updated with chrysopedia-lightrag service definition`
- ``.env.lightrag` — new file with LightRAG configuration`
- ``.gitignore` — updated to exclude .env.lightrag if needed`

## Verification

docker compose config 2>&1 | grep -q chrysopedia-lightrag && echo PASS
