# Copied from docker-compose.example.yml and modified to expose port 8000 on the host for Engram API access networks: t2_proxy: external: true engram_internal: external: true name: engram_engram_internal services: engram: build: context: . dockerfile: Dockerfile image: engram:latest container_name: engram networks: - t2_proxy - engram_internal 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 EPIMNEME_ALLOWED_HOSTS: engram.${DOMAINNAME},epimneme.${DOMAINNAME} EPIMNEME_DEMO_MODE: 0 EPIMNEME_RATE_LIMIT_RPM: 10000 EPIMNEME_RATE_LIMIT_BURST: 500 EPIMNEME_RERANK_ENABLED: 0 EPIMNEME_LLM_RERANK_ENABLED: ${EPIMNEME_LLM_RERANK_ENABLED:-0} EPIMNEME_LLM_RERANK_MODEL: ${EPIMNEME_LLM_RERANK_MODEL:-gpt-4o-mini} EPIMNEME_LLM_RERANK_URL: ${EPIMNEME_LLM_RERANK_URL:-} EPIMNEME_LLM_RERANK_TOP_N: ${EPIMNEME_LLM_RERANK_TOP_N:-20} EPIMNEME_LLM_RERANK_TIMEOUT: ${EPIMNEME_LLM_RERANK_TIMEOUT:-15} # Embedding backend. Defaults reproduce the in-process behaviour exactly; # set EPIMNEME_EMBEDDING_BACKEND=ollama to move embedding out of process. # Changing the MODEL also means changing EPIMNEME_EMBEDDING_DIM, migrating # the pgvector column and re-embedding — see `manage.py reembed`. # 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:-} 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} EPIMNEME_RRF_KEYWORD_WEIGHT: ${EPIMNEME_RRF_KEYWORD_WEIGHT:-0.75} EPIMNEME_DECAY_STABILITY: ${EPIMNEME_DECAY_STABILITY:-30} EPIMNEME_BACKUP_DIR: /backups EPIMNEME_LOG_DIR: /logs ports: - "127.0.0.1:8000:8000" labels: - "traefik.enable=true" - "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.service=engram-svc" - "traefik.http.routers.engram-rtr.middlewares=chain-oauth-epimneme@file" - "traefik.http.services.engram-svc.loadbalancer.server.port=8000" - "traefik.http.services.engram-svc.loadbalancer.responseForwarding.flushInterval=-1s" # engram-api-rtr intentionally does NOT match on an Authorization # header. It used to, which meant a request WITHOUT a token fell # through to the browser router and got redirected to Google OAuth — # an agent that forgot its token received an HTML login page instead # of a 401, with nothing to indicate it was an auth problem. The app # now authenticates /api, /sse and /messages itself (see # epimneme/mcp_auth.py), so the header match is no longer security # and its only effect was to hide the error. - "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(`/mcp`) || Path(`/health`)) && HeadersRegexp(`Authorization`, `Bearer .+`)" - "traefik.http.routers.engram-api-rtr.service=engram-svc" - "traefik.http.routers.engram-api-rtr.middlewares=chain-api@file" - "traefik.http.routers.engram-api-rtr.priority=100" - "traefik.http.routers.epimneme-rtr.tls=true" - "traefik.http.routers.epimneme-rtr.entrypoints=https" - "traefik.http.routers.epimneme-rtr.rule=Host(`epimneme.${DOMAINNAME}`)" - "traefik.http.routers.epimneme-rtr.service=engram-svc" - "traefik.http.routers.epimneme-rtr.middlewares=chain-oauth-epimneme@file" # epimneme-api-rtr intentionally does NOT match on an Authorization # header. It used to, which meant a request WITHOUT a token fell # through to the browser router and got redirected to Google OAuth — # an agent that forgot its token received an HTML login page instead # of a 401, with nothing to indicate it was an auth problem. The app # now authenticates /api, /sse and /messages itself (see # epimneme/mcp_auth.py), so the header match is no longer security # and its only effect was to hide the error. - "traefik.http.routers.epimneme-api-rtr.tls=true" - "traefik.http.routers.epimneme-api-rtr.entrypoints=https" - "traefik.http.routers.epimneme-api-rtr.rule=Host(`epimneme.${DOMAINNAME}`) && (PathPrefix(`/api`) || PathPrefix(`/mcp`) || Path(`/health`)) && HeadersRegexp(`Authorization`, `Bearer .+`)" - "traefik.http.routers.epimneme-api-rtr.service=engram-svc" - "traefik.http.routers.epimneme-api-rtr.middlewares=chain-api@file" - "traefik.http.routers.epimneme-api-rtr.priority=100" epimneme-db: image: pgvector/pgvector:pg16 container_name: epimneme-db networks: - engram_internal security_opt: - no-new-privileges:true restart: unless-stopped volumes: - ./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 labels: - "traefik.enable=false"