Skip to content

Architecture on Docker Swarm with Portainer

This page shows how the stack is laid out when it is deployed as a Docker Swarm stack managed from Portainer, using docker/docker-stack.yml. For the procedure, see Docker Swarm with Portainer.

Open the diagram in its own tab.

Services

The stack file defines four services, each with one replica.

Service Image Update order Notes
spongram <your-registry>/spongram:<tag> start-first, rollback on failure Publishes 8091. Healthcheck on /readyz. Joins both overlay networks. Applies migrations at start-up.
graphiti-mcp <your-registry>/spongram-graphiti:<tag> Swarm default (stop-first) Internal only. Its model calls target http://spongram:8091/_internal/v1/graphiti.
postgresspg postgres:16-alpine, pinned by digest Swarm default Internal only.
neo4jspg neo4j:5.26-community, pinned by digest, with APOC Swarm default Publishes 7475 (HTTP) and 7688 (Bolt) for administration and debugging.

The two Spongram images are built from the source tree and pushed to your own registry. spongram-graphiti is the upstream Graphiti MCP image rebuilt with Spongram's configuration and patches baked in, so no source directory is bind-mounted on the cluster.

Networks

Network Type Members Purpose
spongram Overlay, created by the stack All four services Internal traffic: MCP to Graphiti, Bolt, SQL.
webfacing Overlay, external spongram and your reverse proxy The path from your TLS-terminating proxy to port 8091. Create it once before the first deployment: docker network create --driver overlay --attachable webfacing.

The stack file carries no reverse-proxy configuration. Attach the proxy you already run to webfacing and route your hostname to spongram:8091.

State

Host path Mounted in Content
/data/spongram/postgres postgresspg PostgreSQL data directory.
/data/spongram/neo4j neo4jspg Neo4j data.
/data/spongram/downloads spongram Public download area, served under /downloads.
/data/spongram/marketplace spongram, read-only Organisation persona catalogues, see persona marketplace.

These are bind mounts on the node that runs each service. Docker creates the directories on first start. Because state is tied to a node, constrain the stateful services to it or use storage that follows them.

How updates behave

spongram updates start-first
Swarm starts the new task, waits for its healthcheck, then stops the old one. MCP clients stay connected through a deployment. The healthcheck calls /readyz, with a start period of 120 seconds to leave room for migrations.
graphiti-mcp updates stop-first
There is a gap while it restarts, and spongram's readiness depends on Graphiti. A gap of more than about 30 seconds makes the running spongram task unhealthy too. For that reason a new Graphiti image is rolled by hand, as a planned operation, and never as a side effect of a webhook.
The webhook redeploys the stored definition
A Portainer stack webhook re-applies the stack definition that Portainer holds, with its stored variables. It does not read the YAML file from your repository. Two consequences: a change to the stack file must be pasted into the Portainer stack editor, and after updating a service by hand the matching stack variable (for example the Graphiti tag) must be aligned, or the next webhook brings the old image back.
Settings that must survive every redeploy are baked into the image
The server image sets several feature flags in its ENV block. A value set on the service or in the stack overrides the image default. See feature flags.
Database images are pinned by digest
A floating tag would be pulled again on redeploy and could change the PostgreSQL or Neo4j version without a decision. Upgrading means changing the digest on purpose.

Exposure checklist

  • Only 8091 needs to be reachable by clients, and only through TLS.
  • 8000 (Graphiti) and 5432 (PostgreSQL) are not published.
  • 7475 and 7688 (Neo4j) are published on the node: restrict them with your firewall to administrators.