# Engram — Docker Compose Example # # Copy this file to docker-compose.yml (or use it as-is with `-f`): # # cp docker-compose.example.yml docker-compose.yml # docker compose up -d --build # # By default this starts Engram on http://localhost:8000, exposed only to the # host loopback interface. See the commented-out Traefik section at the bottom # for a production reverse-proxy setup. # # Required environment variables (set in .env — see .env.example): # EPIMNEME_PG_PASSWORD — PostgreSQL password for the engram user # DOMAINNAME — Your domain (only used by the commented Traefik labels) # TZ — Timezone (e.g. America/Chicago) ########################### SERVICES services: # ── Engram — Persistent Memory for AI Agents ── engram: build: context: . dockerfile: Dockerfile image: engram:latest container_name: engram security_opt: - no-new-privileges:true restart: unless-stopped depends_on: epimneme-db: condition: service_healthy environment: TZ: ${TZ:-UTC} EPIMNEME_PG_HOST: epimneme-db EPIMNEME_PG_PORT: 5432 EPIMNEME_PG_USER: engram EPIMNEME_PG_PASSWORD: ${EPIMNEME_PG_PASSWORD} EPIMNEME_PG_DATABASE: engram # Embedding backend. The defaults below are the in-process behaviour. # Set EPIMNEME_EMBEDDING_BACKEND=ollama to embed on a remote Ollama host — # this avoids HuggingFace-gated weights (Ollama serves its own) and lets a # GPU host absorb the cost of a larger model. # Changing the MODEL also means changing EPIMNEME_EMBEDDING_DIM, migrating # the pgvector column and re-embedding (`manage.py reembed`). The server # refuses to start on a dimension mismatch rather than failing every write. # Instruction-tuned models need their prefixes set, or they score well # below their potential (EmbeddingGemma: query "task: search result | query: ", # doc "title: none | text: "). # Require a Bearer token on the MCP transport (/sse, /messages). The # FastMCP app is mounted as a sub-application and does not run the # dependency that guards /api/*, so without this GET /sse hands a session # id to anyone who asks. Leave at 1 in anything with a network route. # X-Forwarded-User grants admin when trusted, so trust is OFF by default: # anything able to reach the app directly could otherwise forge it. Turn it # on only behind an authenticating proxy, and set EPIMNEME_PROXY_SECRET so # the header is honoured only with a matching X-Proxy-Secret. EPIMNEME_TRUST_FORWARDED_USER: ${EPIMNEME_TRUST_FORWARDED_USER:-0} EPIMNEME_PROXY_SECRET: ${EPIMNEME_PROXY_SECRET:-} EPIMNEME_MCP_AUTH_REQUIRED: ${EPIMNEME_MCP_AUTH_REQUIRED:-1} EPIMNEME_EMBEDDING_BACKEND: ${EPIMNEME_EMBEDDING_BACKEND:-sentence-transformers} EPIMNEME_EMBEDDING_MODEL: ${EPIMNEME_EMBEDDING_MODEL:-all-MiniLM-L6-v2} EPIMNEME_EMBEDDING_DIM: ${EPIMNEME_EMBEDDING_DIM:-384} EPIMNEME_EMBEDDING_QUERY_PREFIX: ${EPIMNEME_EMBEDDING_QUERY_PREFIX:-} EPIMNEME_EMBEDDING_DOC_PREFIX: ${EPIMNEME_EMBEDDING_DOC_PREFIX:-} # Torch threads per encode. 1 stays fast on a busy host and lets requests # run in parallel; raise it only on an otherwise idle machine. 0 = torch default. EPIMNEME_TORCH_THREADS: ${EPIMNEME_TORCH_THREADS:-1} EPIMNEME_OLLAMA_URL: ${EPIMNEME_OLLAMA_URL:-http://localhost:11434} EPIMNEME_OLLAMA_TIMEOUT: ${EPIMNEME_OLLAMA_TIMEOUT:-60} EPIMNEME_OLLAMA_BATCH_SIZE: ${EPIMNEME_OLLAMA_BATCH_SIZE:-64} # Expose only on loopback by default. Remove or change to 8000:8000 to # bind on all interfaces (and put a reverse proxy in front of it!). ports: - "127.0.0.1:8000:8000" # ── Traefik labels — uncomment and adjust for production ── # networks: # - proxy # labels: # - "traefik.enable=true" # # Browser route — protect with your OAuth/SSO middleware # - "traefik.http.routers.engram-rtr.tls=true" # - "traefik.http.routers.engram-rtr.entrypoints=https" # - "traefik.http.routers.engram-rtr.rule=Host(`engram.${DOMAINNAME}`)" # - "traefik.http.routers.engram-rtr.middlewares=chain-oauth@file" # - "traefik.http.routers.engram-rtr.service=engram-svc" # - "traefik.http.services.engram-svc.loadbalancer.server.port=8000" # # API/SSE route — Bearer auth only, NO gzip (compression breaks SSE) # - "traefik.http.routers.engram-api-rtr.tls=true" # - "traefik.http.routers.engram-api-rtr.entrypoints=https" # - "traefik.http.routers.engram-api-rtr.rule=Host(`engram.${DOMAINNAME}`) && (PathPrefix(`/api`) || PathPrefix(`/sse`) || PathPrefix(`/messages`) || Path(`/health`))" # - "traefik.http.routers.engram-api-rtr.middlewares=chain-api@file" # - "traefik.http.routers.engram-api-rtr.service=engram-svc" # - "traefik.http.routers.engram-api-rtr.priority=100" # ── PostgreSQL + pgvector ── epimneme-db: image: pgvector/pgvector:pg16 container_name: epimneme-db security_opt: - no-new-privileges:true restart: unless-stopped volumes: - epimneme-db-data:/var/lib/postgresql/data environment: TZ: ${TZ:-UTC} POSTGRES_USER: engram POSTGRES_PASSWORD: ${EPIMNEME_PG_PASSWORD} POSTGRES_DB: engram healthcheck: test: ["CMD-SHELL", "pg_isready -U engram"] interval: 10s timeout: 5s retries: 5 start_period: 30s ########################### VOLUMES volumes: epimneme-db-data: driver: local ########################### NETWORKS # Uncomment if you use Traefik or another external proxy network. # networks: # proxy: # external: true