Docker Compose¶
This page installs the Spongram server on a single host with docker-compose.yml: the four
containers, the variables that must be set, the two images to build, the ports, the first login
and the checks that tell you the stack is ready. For a multi-node production cluster see
Docker Swarm with Portainer; for the full variable reference see
Configuration.
What the Compose file starts¶
| Service | Image | Role |
|---|---|---|
spongram |
built from spongram_proxy/Dockerfile |
The only public service: MCP endpoint (/mcp), admin API and admin UI (/admin/), explorers (/v1/graph), inference proxy for Graphiti (/_internal/v1/*), this documentation (/documentation/) |
graphiti-mcp |
built from docker/Dockerfile.graphiti |
Extraction engine: turns episodes into entities and facts. Reached only by spongram |
postgres |
postgres:16-alpine, pinned by digest |
Instances, keys, ingestion queue, runtime configuration, usage |
neo4j |
neo4j:5.26-community, pinned by digest |
The knowledge graph |
All client traffic goes through spongram. graphiti-mcp and postgres declare expose: only
and are never published on the host. Do not add a ports: entry to them: spongram injects the
brain's group_id on every call, and a client that reached Graphiti directly would bypass that
isolation.
Prerequisites¶
- Docker Engine with Compose v2 (
docker compose, notdocker-compose). - Outbound access to your inference provider, or none if the provider runs on your own network (see Inference providers).
- A host directory for state. The Compose file bind-mounts
/data/spongram/postgresand/data/spongram/neo4j; Docker creates them on first start. - Memory for Neo4j: the file sets a 2 GB heap and a 1 GB page cache.
Configure the environment¶
Compose refuses to start until these four variables have a value:
| Variable | How to produce it | Used for |
|---|---|---|
POSTGRES_PASSWORD |
any strong password | Postgres superuser of the spongram database; the file builds SPONGRAM_DATABASE_URL from it |
NEO4J_PASSWORD |
any strong password | Neo4j neo4j user; passed to graphiti-mcp and spongram |
SPONGRAM_ADMIN_TOKEN |
openssl rand -hex 32 |
Bearer token of /admin/api/*, /metrics and the admin UI login |
SPONGRAM_INTERNAL_AUTH_TOKEN |
openssl rand -hex 32 |
Shared secret between graphiti-mcp and the inference proxy of spongram |
Set these as well before the first real use:
| Variable | Why |
|---|---|
SPONGRAM_ENCRYPTION_KEY |
Fernet key that encrypts the provider API key stored in the database. If empty, a key is derived from SPONGRAM_ADMIN_TOKEN, which means rotating the admin token makes the stored provider key unreadable. Generate one with python3 -c "from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())" and keep it stable |
SPONGRAM_INFERENCE_API_KEY |
Key for the inference endpoint, used until a key is saved from the admin UI. The endpoint URL itself is not taken from the environment: the database is seeded with https://models.sponge-theory.dev/v1 and you change it on the Settings page |
SPONGRAM_PUBLIC_URL |
The URL clients use. It is written into the generated client bundles; set your HTTPS hostname before distributing any |
Only interpolated variables reach the container
The spongram service has no env_file: entry. A variable written in .env reaches the
container only if the environment: block of docker-compose.yml references it. Variables
that the file does not reference (most feature flags, the Langfuse keys, the Dream tunables)
must be added in a docker-compose.override.yml. See Feature flags.
Build the two images¶
docker compose build # builds the spongram image only
make build-graphiti # builds the Graphiti image
docker compose build builds spongram and nothing else: the graphiti-mcp service has an
image: but no build: key. make build-graphiti runs docker build -f docker/Dockerfile.graphiti
and tags the result with the image name that docker-compose.yml references, so Compose finds it
in the local image store and does not contact a registry. Keep the Makefile defaults for
REGISTRY and GRAPHITI_TAG when you build for Compose, or change the image: line to match.
The Graphiti image is the upstream zepai/knowledge-graph-mcp image with the Spongram
configuration baked in at /app/mcp/config/config.yaml, a set of build-time patches, and the
GPU libraries removed. The build fails if one of the patch points no longer matches upstream.
Start and check¶
make up # docker compose up -d
curl -fsS http://localhost:8091/readyz # 200 when Graphiti, Postgres and Neo4j answer
curl -sS http://localhost:8091/healthz # full diagnostic, includes the version
On start the spongram container waits for Postgres (up to two minutes), applies the SQL
migrations, then starts the HTTP server. The log shows ==> applying migrations, one
{"migration": "<file>", "state": "applied"} line per new file, then ==> migrations applied.
/readyz judges the three hard dependencies. /healthz also reports the background workers and
answers "status": "starting" during the first 90 seconds. Both are described in
Observability.
Note
The healthcheck in docker-compose.yml calls /healthz. Compose only displays that state
(docker compose ps); it does not restart a container that turns unhealthy. On an
orchestrator that acts on health, such as Swarm or Kubernetes, the healthcheck must call
/readyz instead.
Makefile targets¶
| Target | Command it runs |
|---|---|
make up |
docker compose up -d |
make down |
docker compose down (containers only; the bind-mounted data stays) |
make logs |
docker compose logs -f |
make ps |
docker compose ps |
make build-image |
docker build -f spongram_proxy/Dockerfile -t $(REGISTRY)/spongram:$(TAG) . |
make build-graphiti |
docker build -f docker/Dockerfile.graphiti -t $(REGISTRY)/spongram-graphiti:$(GRAPHITI_TAG) . |
make push-image, make push-graphiti |
build, then docker push to $(REGISTRY) |
Ports¶
| Port | Service | Exposure |
|---|---|---|
8091 |
spongram |
Published on the host. Change the host side with SPONGRAM_HOST_PORT |
7475 → 7474 |
Neo4j Browser (HTTP) | Published for administration and debugging only. Host side set by NEO4J_HTTP_PORT; .env.example sets it to 7474 |
7688 → 7687 |
Neo4j Bolt | Published for administration and debugging only. Host side set by NEO4J_BOLT_PORT; .env.example sets it to 7687 |
5432 |
Postgres | Internal only |
8000 |
graphiti-mcp |
Internal only |
Clients need port 8091 and nothing else. Keep the two Neo4j ports closed to the outside or
behind a VPN: they lead to the database that holds every brain. Client bundles never reference
them; the graph explorers are served by spongram under /v1/graph.
First login and first brain¶
- Open
http://localhost:8091/admin/and enter the value ofSPONGRAM_ADMIN_TOKEN. - In Settings, choose the inference provider and models, then run the connection test. The embedding dimension cannot be changed after memories exist, so choose the embedder first. See Inference providers.
- Create an instance (a brain). The
spt_brain_…key is displayed once; only its SHA-256 hash is stored.
The same step through the API:
curl -sS -X POST http://localhost:8091/admin/api/spongram/instances \
-H "Authorization: Bearer <admin-token>" \
-H "Content-Type: application/json" \
-d '{"owner_email": "<owner-email>", "display_name": "First brain"}'
The response contains id, group_id and api_key (the clear key, returned this one time). The
Admin UI and HTTP API pages cover the rest, and
Quickstart connects a first client.
Where state lives¶
| Path on the host | Mounted at | Content |
|---|---|---|
/data/spongram/postgres |
/var/lib/postgresql/data |
Instances, hashed keys, ingestion queue, runtime configuration, personas, wiki pages |
/data/spongram/neo4j |
/data |
The graph of every brain |
Rebuilding or recreating containers never touches these directories. make down leaves them in
place. Back them up as described in Backup and restore.
On a workstation where /data is not shared with the Docker VM (Docker Desktop on macOS, for
example), replace the bind mounts with named volumes in a docker-compose.override.yml, which
Compose loads automatically:
services:
postgres:
volumes:
- !reset []
- dev_postgres_data:/var/lib/postgresql/data
neo4j:
volumes:
- !reset []
- dev_neo4j_data:/data
volumes:
dev_postgres_data:
dev_neo4j_data:
TLS¶
spongram listens in plain HTTP on 8091. Terminate TLS in a reverse proxy in front of it, then
set SPONGRAM_PUBLIC_URL to the HTTPS URL. The MCP endpoint and the explorer stream
(/v1/graph/stream) are long-lived streamed responses: disable response buffering and raise the
read timeout for them in the proxy.
location / {
proxy_pass http://127.0.0.1:8091;
proxy_set_header Host $host;
proxy_http_version 1.1;
}
location /v1/graph/stream {
proxy_pass http://127.0.0.1:8091;
proxy_buffering off;
proxy_read_timeout 1h;
}
The Cloud overlay: docker-compose.cloud.yml¶
docker-compose.cloud.yml is not a separate installation. It is an overlay merged with
docker-compose.yml that turns on the Cloud control plane (organisations, user accounts, a
signed licence) on the same containers, volumes and ports:
docker compose -f docker-compose.yml -f docker-compose.cloud.yml config --quiet # render and check
docker compose -f docker-compose.yml -f docker-compose.cloud.yml up -d
Prepare three things before the up: a second database role for the API, with its DSN in
SPONGRAM_RUNTIME_DATABASE_URL; the migrations, run once with the owner role by the separate
migration command; and, on an existing server, the encryption key the installation already
uses. Upgrades and migrations describes the commands.
The overlay changes the following and nothing else:
| Service | Change |
|---|---|
spongram |
SPONGRAM_CLOUD_CONTROL_ENABLED=true, SPONGRAM_CLOUD_CUSTOMER_INSTALLATION=true, SPONGRAM_CLOUD_COOKIE_SECURE (default true) |
spongram |
SPONGRAM_CLOUD_LICENSE_PUBLIC_KEYS and SPONGRAM_ENCRYPTION_KEY become mandatory |
spongram |
SPONGRAM_DATABASE_URL is taken from SPONGRAM_RUNTIME_DATABASE_URL, a non-owner database role |
spongram |
SPONGRAM_RUN_MIGRATIONS=false: migrations are run by a separate command with the owner role (see Upgrades and migrations) |
spongram |
FORWARDED_ALLOW_IPS from SPONGRAM_FORWARDED_ALLOW_IPS (default 127.0.0.1): the address of the reverse proxy whose X-Forwarded-For is trusted for the login rate limit |
graphiti-mcp |
SPONGRAM_CLOUD_JOB_RECEIPTS=true and a spongram-execution-receipts volume mounted at /var/lib/spongram/receipts |
Without the overlay, the server authenticates clients by brain key and the administrator by
SPONGRAM_ADMIN_TOKEN, and none of the Cloud routes are mounted.