Skip to main content

Docker compose files

Two compose files are meant for running Spanway on one host. The quickstart stack starts the gateway and a Postgres database, and the Admin Assistant overlay adds the Admin Assistant for Slack next to a gateway. Both pull the published spanway-ai image, and neither runs a separate migration step, because the gateway image migrates the schema itself at startup. Both files come with the deployment files in your onboarding pack, and the quickstart file is printed in full below so you can also copy it from this page.

A real-world scenario​

A developer wants the gateway on one VM for a two week pilot with a database, so models and keys added in the Admin UI survive restarts. They use the quickstart compose file, which starts the published image and Postgres with one command and a two line .env file.

Steps​

  1. Put docker-compose.quickstart.yml from your onboarding pack, or the copy below, into an empty directory.

  2. Write the .env file and start the stack, as shown under docker-compose.quickstart.yml.

  3. Check that it answers.

    curl http://localhost:4000/health/liveliness
    curl http://localhost:4000/health/readiness
  4. Open http://localhost:4000/ui, sign in as admin with SPANWAY_MASTER_KEY from .env, open Models + Endpoints and click Add Model to add your first model.

Expected result​

docker compose ps shows both containers healthy, /health/readiness reports the database as connected, and a model added in the Admin UI is still there after docker compose restart.

docker-compose.quickstart.yml​

The two-container stack behind the Docker quick start. It pulls the gateway image, starts Postgres with a health check the gateway waits on, and gives the gateway its own health check on /health/liveliness. Replace registry.spanway.ai with the registry address from your onboarding pack and <tag> with the release you run.

services:
spanway:
image: registry.spanway.ai/spanway/spanway-ai:<tag>
ports:
- "${SPANWAY_BIND:-}${SPANWAY_PORT:-4000}:4000"
environment:
SPANWAY_MASTER_KEY: ${SPANWAY_MASTER_KEY:?set it in .env}
SPANWAY_SALT_KEY: ${SPANWAY_SALT_KEY:?set it in .env}
DATABASE_URL: postgresql://spanway:${POSTGRES_PASSWORD:-spanway}@db:5432/spanway
STORE_MODEL_IN_DB: "True"
healthcheck:
test: ["CMD", "/app/.venv/bin/python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:4000/health/liveliness')"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
depends_on:
db:
condition: service_healthy

db:
image: postgres:16
environment:
POSTGRES_USER: spanway
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-spanway}
POSTGRES_DB: spanway
healthcheck:
test: ["CMD-SHELL", "pg_isready -U spanway"]
interval: 5s
timeout: 5s
retries: 10
volumes:
- postgres_data:/var/lib/postgresql/data

volumes:
postgres_data:

Start it from the directory that holds the file.

printf 'SPANWAY_MASTER_KEY=sk-%s\nSPANWAY_SALT_KEY=sk-%s\n' "$(openssl rand -hex 32)" "$(openssl rand -hex 32)" > .env
docker compose -f docker-compose.quickstart.yml up -d

SPANWAY_MASTER_KEY and SPANWAY_SALT_KEY are required and read from .env. Keep that file, because credentials stored in the database are encrypted with the salt key and become unreadable if it changes. SPANWAY_IMAGE in .env sets the image the onboarding pack copy pulls, for example registry.spanway.ai/spanway/spanway-ai:2.0.0, so you can pin a release without editing the file. SPANWAY_PORT changes the published port (default 4000) and SPANWAY_BIND can be set to 127.0.0.1: to listen on the local machine only. POSTGRES_PASSWORD overrides the database password, which defaults to spanway.

The quickstart installer​

The onboarding pack also carries quickstart.sh for macOS and Linux and quickstart.ps1 for Windows PowerShell, next to docker-compose.quickstart.yml. They do the steps above for you, so someone who has never used Compose gets a running gateway by answering a few questions. Each question has a default you accept by pressing Enter.

sh quickstart.sh

The installer asks which folder to keep the files in, generates the master key, the salt key and the database password with openssl rand, writes them only to .env with permissions 600 and never prints them, starts the stack, waits until /health/readiness answers, and offers to copy the admin password to your clipboard and open the Admin UI. A second run in the same folder reuses .env, so your models and keys keep working. When the folder is inside a git repository it keeps .env out of git, and it refuses to continue when git already tracks a .env there.

OptionDefaultWhat it does
--yes or -y (-Yes in PowerShell)offAsks nothing, installs to ~/spanway-gateway and does not open a browser. The installer also asks nothing when there is no terminal or it runs under CI.
SPANWAY_DIRaskedThe folder to install into, which skips the folder question.
SPANWAY_PORT4000, or the next free portThe port the gateway listens on.
SPANWAY_COMPOSE_FILEthe file next to the scriptAnother compose file to use.
NO_COLORoffPlain output without colours, which log files and CI always get.

A new install listens on this machine only, because the installer writes SPANWAY_BIND=127.0.0.1: to .env. To reach the gateway from other machines, remove that line from .env, put the gateway behind TLS, and run docker compose up -d again. The installer needs Docker, Podman or Rancher Desktop with Compose v2.

docker-compose.admin-assistant.yml​

An overlay that adds the Admin Assistant for Slack as a worker next to a gateway already defined in another compose file. It starts a second container from the same proxy image with the --admin-agent argument and wires the two together.

export SPANWAY_IMAGE=registry.spanway.ai/spanway/spanway-ai:<tag>
export SPANWAY_PUBLIC_URL=https://gateway.example.com
export SPANWAY_ADMIN_MODEL=<a model with tool calling>
export ADMIN_AGENT_SERVICE_TOKEN=$(openssl rand -hex 32)
export CREDENTIAL_ENCRYPTION_KEY=$(openssl rand -base64 32 | tr '+/' '-_')
export SLACK_BOT_TOKEN=... SLACK_APP_TOKEN=... SLACK_WORKSPACE_ID=...
docker compose -f docker-compose.quickstart.yml -f docker-compose.admin-assistant.yml up -d

Every variable above is required and the file fails fast with a message naming the missing one. The gateway service gains SPANWAY_ADMIN_AGENT_URL=http://admin-assistant:10000, ADMIN_AGENT_SERVICE_TOKEN and PROXY_BASE_URL, plus a health check on /health/liveliness, so the overlay works on top of a base file whose gateway has none. The admin-assistant service runs read-only with all capabilities dropped, keeps its SQLite state in the admin_assistant_state volume at /var/data/events.sqlite3, waits for the gateway to be healthy, and exposes /readyz on port 10000 for its health check. ADMIN_READ_ONLY defaults to false.

Moving on​

Compose is a single-host tool. When you need rolling upgrades, autoscaling or a managed database, move to one of the Helm charts or a Terraform stack. The configuration file and the environment variables carry over unchanged.

Errors​

What you seeWhat it meansFix
required variable SPANWAY_MASTER_KEY is missing.env is missing or not in the current directory.Create it as shown, next to the compose file.
The gateway waits and never startsPostgres is not healthy yet, or its volume holds a database with another password.Check docker compose logs db, and remove the old volume only if its data is not needed.
Stored credentials stop working after a restartSPANWAY_SALT_KEY changed.Restore the original value from your backup of .env.
port is already allocatedSomething else listens on 4000.Set SPANWAY_PORT to a free port.

Logs​

Each container writes its log to the container output. docker compose logs spanway shows the gateway and docker compose logs db shows Postgres.

LevelLineMeaningAction
OutputSpanway proxy refused to start: ...The master key in .env is unset, empty or a known default, so the gateway exits.Generate the keys as shown above.
WARNINGAttempt <n> timed out after <s>s or The process failed to execute. Details: ... Retrying... (<n> attempts left)The schema migration at startup did not finish on that try.None if a later try succeeds. Otherwise read the Prisma error above it and check the database password.
ERROR_db_health_readiness_check: reconnect failedThe gateway lost the database. /health/readiness answers 503.Check docker compose ps and the db log.

docker compose ps shows the health of each container, which comes from the health checks in the file. The log reference lists every startup and database line.