Installing with Docker Compose
Run Structam on one host with Docker Compose (PostgreSQL 18, structam all and Caddy), its settings, TLS modes, and the HA topology for drills.
On this page
Status. Tested: deploy/compose/compose.yaml and deploy/compose/compose.ha.yaml brought up with Docker Compose 5.5 on Docker Desktop (arm64) and signed in through Caddy. On one Docker host the HA topology shows behaviour, not redundancy.
deploy/compose/compose.yaml runs PostgreSQL 18, structam all and Caddy. Only Caddy publishes ports (80 and 443); the app and the database are on the project network only.
Start it
Load the Structam image KazLabs provided (for example with docker load) and point STRUCTAM_IMAGE at it, then:
cd deploy/compose
umask 077
{ echo "STRUCTAM_SECRET_KEY=$(openssl rand -base64 32)" # seals stored secrets: keep a copy elsewhere
echo "POSTGRES_PASSWORD=$(openssl rand -hex 24)"
echo "STRUCTAM_BOOTSTRAP_ADMIN_PASSWORD=$(openssl rand -base64 18)"
echo "STRUCTAM_SITE=structam.example.com" # the name agents and browsers use
echo "STRUCTAM_IMAGE=structam:0.1.0" # the image you loaded
} > .env
docker compose up -d
docker compose ps # db, app and caddy healthySign in at https://structam.example.com as admin with the password from .env. The password must be changed at the first sign-in. Then delete the STRUCTAM_BOOTSTRAP_ADMIN_PASSWORD line from .env: the account is created only while the database has no users, so the line does nothing afterwards. There are no default passwords: compose refuses to start until .env sets them.
Settings of the compose file
Variable (in .env) | Default | Meaning |
|---|---|---|
STRUCTAM_SITE | localhost | the host name Caddy serves and the public URL uses |
STRUCTAM_PUBLIC_URL | https://$STRUCTAM_SITE | set it when the published HTTPS port is not 443 |
STRUCTAM_TLS_MODE | internal | internal (Caddy's own CA), acme (Let's Encrypt or STRUCTAM_ACME_CA), byo (your certificate) |
STRUCTAM_ACME_EMAIL | unset | ACME account e-mail |
STRUCTAM_IMAGE | a locally built image | the Structam image |
STRUCTAM_HTTP_PUBLISH, STRUCTAM_HTTPS_PUBLISH | 80, 443 | published ports (127.0.0.1:8443 binds loopback only) |
STRUCTAM_SUBNET, STRUCTAM_PROXY_IP | 172.30.83.0/24, 172.30.83.10 | the project network and Caddy's fixed address, which is the only STRUCTAM_TRUSTED_PROXIES entry |
With byo, Caddy reads /etc/caddy/tls/cert.pem (the full chain) and /etc/caddy/tls/key.pem.
Every other server setting (configuration reference) goes in deploy/compose/structam.env, which the app reads when it exists (for example STRUCTAM_NETBOX_URL, STRUCTAM_NETBOX_TOKEN or STRUCTAM_LOG_LEVEL=debug), and takes effect at the next docker compose up -d.
The compose file itself sets five server variables from .env: STRUCTAM_DATABASE_URL, STRUCTAM_SECRET_KEY, STRUCTAM_PUBLIC_URL, STRUCTAM_TRUSTED_PROXIES (Caddy's address) and STRUCTAM_BOOTSTRAP_ADMIN_PASSWORD; the HA file also sets STRUCTAM_MIGRATE=off, because its migrate service runs the migrations. It sets the file forms of the three secrets among them to empty, which Structam treats as unset. Compose gives these precedence over structam.env, so a line for one of them in structam.env is ignored: change them through .env.
Agents and Caddy's own CA
With STRUCTAM_TLS_MODE=internal the hosts' system trust stores do not know Caddy's CA. Agents do not need it for trust (they pin the server's own key), but the install script and the agent's TLS connection do. Copy Caddy's root certificate into Add hosts → Private CA for agents, so the install script writes it to each agent's ca.pem:
docker compose exec caddy cat /data/caddy/pki/authorities/local/root.crtFor hosts outside a lab, prefer STRUCTAM_TLS_MODE=acme or byo with a certificate the hosts already trust.
Backups and upgrades
docker compose exec -T db pg_dump -U structam -Fc structam > structam-$(date +%F).dumpKeep the secret key from .env apart from the dumps (backup and restore). To upgrade, set STRUCTAM_IMAGE to the new image and run docker compose up -d: the new app migrates the schema at start (upgrading).
The HA topology, for drills
deploy/compose/compose.ha.yaml runs pg1 (primary), pg2 (a streaming standby cloned from pg1 on first start), a migrate job, app1 and app2 (structam serve), a worker and Caddy. It uses the same .env plus REPLICATION_PASSWORD; STRUCTAM_PG_SYNC_STANDBY=pg2 makes pg2 a synchronous standby (set it before the first start: it is applied when pg1 is initialised).
cd deploy/compose
echo "REPLICATION_PASSWORD=$(openssl rand -hex 24)" >> .env
echo "STRUCTAM_PG_SYNC_STANDBY=pg2" >> .env
docker compose -f compose.ha.yaml up -d --wait
docker compose -f compose.ha.yaml exec pg1 psql -U structam -d structam \
-c 'select application_name, state, sync_state from pg_stat_replication' # pg2 | streaming | syncPostgreSQL failover in this topology is manual. On one Docker host it shows how Structam behaves when a node or the database goes away; it is not redundancy. The drills to run with it are on the high availability page.
Questions the docs do not answer?
Ask the people who build Structam. Installation media and licences come from KazLabs.