Docker Compose with your own Postgres
This page shows how to run SREInsights on a host with Docker, using a PostgreSQL server you already run. You put a TLS proxy in front of it and point your domain at the proxy.
You need access to the SREInsights repository, which is private: ask the SREInsights team. The compose file is docker-compose.coolify.yml at the repository root. Despite its name, it is an ordinary compose file.
What it runs
Section titled “What it runs”One image, built from deploy/Dockerfile, runs as three services:
| Service | Command | What it does | Public |
|---|---|---|---|
migrate |
migrate |
Applies migrations and seeds built-in roles and plans, then exits. Runs before the others on every deploy | No |
app |
api |
The API, the runner protocol and the web app, on port 8080 | Yes, behind your proxy and domain |
worker |
worker |
Scheduler, alert processor and notification delivery | No |
app serves the web app, so the UI, /api and /runner/v1 share one origin. The sign-in refresh cookie needs that. Runners are not part of this deployment: they run inside the networks they monitor and connect out to your domain.
1. Prepare the database
Section titled “1. Prepare the database”Do this once. You need PostgreSQL 14 or newer. As a superuser on your Postgres server, run deploy/postgres/setup.sql with a password for each role:
psql "postgresql://postgres:<password>@<host>:5432/postgres" \ -v owner_password='…' -v app_password='…' -v system_password='…' \ -f deploy/postgres/setup.sqlIt creates the sreinsights database and three roles:
| Role | Used by | Row-level security |
|---|---|---|
sreinsights_owner |
Owns the schema. Used only by migrate |
Owns the schema |
sreinsights_app |
Every API request | Enforced |
sreinsights_system |
The workers and cross-organization claims | Bypassed |
- Add
-v dbname=…to use a database name other thansreinsights. - Running it again is safe: existing roles get the passwords you pass, and nothing else changes.
- On a managed server such as RDS, run it as the master user. A managed server gives out no superuser, so
sreinsights_systemis created withoutBYPASSRLSand a migration grants it a policy on every table instead.
In an interactive psql -U postgres session, set the passwords first, then paste the file:
\set owner_password '…'\set app_password '…'\set system_password '…'2. Get the code onto the host
Section titled “2. Get the code onto the host”Clone the repository on a host with Docker. Run every command below from the repository root, where docker-compose.coolify.yml is.
3. Set environment variables
Section titled “3. Set environment variables”Put these in a .env file next to the compose file. Give it mode 600 and never commit it. Percent-encode special characters in passwords inside the URLs.
| Variable | Value |
|---|---|
DATABASE_OWNER_URL |
postgresql://sreinsights_owner:…@<db-host>:5432/sreinsights (used by migrate only) |
DATABASE_URL |
postgresql://sreinsights_app:…@<db-host>:5432/sreinsights |
SYSTEM_DATABASE_URL |
postgresql://sreinsights_system:…@<db-host>:5432/sreinsights |
SREINSIGHTS_BASE_URL |
https://sreinsights.example.com: the domain you give app, with no trailing slash |
SREINSIGHTS_SESSION_SECRET |
Output of openssl rand -base64 48 |
SREINSIGHTS_MASTER_KEY |
Output of openssl rand -base64 32 |
SREINSIGHTS_RUNNER_IMAGE |
Optional. The runner image shown on the Runners page. Default ghcr.io/bintree-softwares/sreinsights-runner:latest |
SREINSIGHTS_API_URL |
Optional. Where runners reach SREInsights, if not SREINSIGHTS_BASE_URL |
ADAM_API_KEY |
Optional. Anthropic API key for ADAM |
ADAM_MODEL |
Optional. Default claude-opus-5 |
LOG_LEVEL |
Optional. Default info |
A complete .env:
DATABASE_OWNER_URL=postgresql://sreinsights_owner:owner-password@db.example.com:5432/sreinsightsDATABASE_URL=postgresql://sreinsights_app:app-password@db.example.com:5432/sreinsightsSYSTEM_DATABASE_URL=postgresql://sreinsights_system:system-password@db.example.com:5432/sreinsightsSREINSIGHTS_BASE_URL=https://sreinsights.example.comSREINSIGHTS_SESSION_SECRET=<output of openssl rand -base64 48>SREINSIGHTS_MASTER_KEY=<output of openssl rand -base64 32>Every other setting is in Environment variables.
4. Set up the domain and TLS
Section titled “4. Set up the domain and TLS”Put a TLS-terminating proxy (Caddy, nginx, Traefik) in front of app’s port 8080 and point your domain at it. Never expose worker or migrate.
Polling runners hold lease requests open for up to 25 seconds, so give the proxy a read timeout above that. A Caddy example, from the repository’s deploy/ec2/Caddyfile:
sreinsights.example.com { encode zstd gzip reverse_proxy app:8080 { transport http { read_timeout 60s } }}The compose file only exposes port 8080 to other containers. Either run the proxy on the same Docker network, or publish app’s port 8080 to it by adding a ports entry. If Postgres runs in Docker on the same host, put it on the same Docker network too and use its service name as the database host.
5. Deploy
Section titled “5. Deploy”The migrate service carries an exclude_from_hc: true line for hosting panels that health-check every container. Plain docker compose rejects unknown keys, so delete that line first. Then:
docker compose -f docker-compose.coolify.yml up -d --buildmigrate runs first. app and worker start once it exits successfully. app is healthy when /readyz can reach the database.
Open your domain and sign up. The first sign-up creates your organization.
To deploy a new version, update the code and run the same command again. migrate runs again before app and worker restart; it is safe to run on every deploy.
- Build memory. The image builds the web app on the host. Give it about 2 GB of free memory, or build elsewhere with
npm run docker:sreinsightsand push the image to a registry. - Scaling.
appandworkercan each run more than one container. Workers claim work withFOR UPDATE SKIP LOCKEDand advisory locks, so containers that overlap during a redeploy are safe too. - Stopping.
appandworkerhave a stop grace period of 35 seconds, so open requests and the current round of background work can finish.
Publish your own runner image
Section titled “Publish your own runner image”Your runners can pull the public image, ghcr.io/bintree-softwares/sreinsights-runner:latest. To run your own build instead, publish it to a registry your runners can pull from:
docker buildx build --platform linux/amd64,linux/arm64 \ -f deploy/Dockerfile.runner -t ghcr.io/acme/sreinsights-runner:1 --push .Then set SREINSIGHTS_RUNNER_IMAGE=ghcr.io/acme/sreinsights-runner:1 so the Runners page shows it in its install commands. See Runner settings.