Skip to content

Install with Docker Compose

This page comes from deploy/selfhost in the repository.

API, web app behind Caddy, PostgreSQL with TimescaleDB and Redis, from one docker compose up. The community edition runs the full product, with the plan limits and quotas switched off (editions).

The images are published on ghcr.io, public, no login. The stack pulls ghcr.io/ostrakon-app/api and ghcr.io/ostrakon-app/web at the tag set by OSTRAKON_VERSION in .env (release tags carry a leading v, for example v0.9.2; latest follows the newest release), which .env.example sets to the release tag (v0.9.2). Building them from this clone is the alternative, see Install.

First account window. On an empty instance, the first account that registers becomes the admin (plan=admin, no limits). If the instance is reachable before you registered yours, whoever gets there first owns it. So:

  1. Start it bound to 127.0.0.1 (the default), register your account, save your OSP.
  2. Only then expose it (mode b below).
  3. Optionally close registrations: set OSTRAKON_SIGNUP_ENABLED=false in .env, then docker compose up -d. POST /api/v1/auth/register answers 403 registration_disabled.

Do not close registrations before the admin exists: a closed empty instance cannot be claimed by anyone, you would have to set it back to true and restart.

Docker Engine with Compose v2 (the docker compose plugin) and git (a few GB of free disk more if you build the images yourself). Nothing else: the API applies its own migrations at start.

Terminal window
git clone https://github.com/ostrakon-app/ostrakon.git
cd ostrakon/deploy/selfhost
cp .env.example .env

Fill the three secrets of .env. They are empty on purpose, and Compose refuses to start while one is empty:

Terminal window
openssl rand -base64 48 # OSTRAKON_AUTH_JWT_SECRET
openssl rand -base64 48 # OSTRAKON_AUTH_OSP_PEPPER
openssl rand -hex 24 # OSTRAKON_DATABASE_PASSWORD

Then:

Terminal window
docker compose up -d # pulls the images, then starts the stack

To build the images from the clone instead of pulling them, uncomment COMPOSE_FILE=compose.yaml:compose.build.yaml in .env, then docker compose build (several minutes) and docker compose up -d. Fill the build identity first, or Settings > About and system/info show dev / unknown:

Terminal window
export APP_VERSION=$(git describe --tags --always) APP_COMMIT=$(git rev-parse HEAD) \
APP_BUILD_DATE=$(date -u +%Y-%m-%dT%H:%M:%SZ)
docker compose build

(or set the three APP_* variables in .env, see .env.example).

Open http://localhost:8080, register (the page shows your OSP once, save it), and you are the admin. docker compose ps shows the four services healthy when it is ready (web is probed on a loopback-only listener of the Caddyfile, port 8081, which is not published).

Back up the JWT secret and the pepper with your database. The pepper keys the OSP index of every account: lose it and nobody can log in again. Changing the JWT secret only logs everyone out.

Every API setting is an environment variable, so .env is the only file you edit. No config.yaml is mounted. The names are OSTRAKON_*, listed in the key table. .env.example documents the ones this stack passes through. To set another one, add it to .env and to the environment: of the api service in compose.yaml.

Variable Default Role
OSTRAKON_AUTH_JWT_SECRET required Signs access tokens, 32 bytes or more
OSTRAKON_AUTH_OSP_PEPPER required Keys the OSP index of every account
OSTRAKON_DATABASE_PASSWORD required Password of the Postgres user (also set on the database)
OSTRAKON_VERSION latest (v0.9.2 in .env.example) Image tag of the pulled images, with the leading v (v0.9.2, not 0.9.2)
APP_VERSION / APP_COMMIT / APP_BUILD_DATE dev / unknown / unknown Build identity of images you build yourself (not set when pulling)
OSTRAKON_BIND_ADDRESS 127.0.0.1 Host address of the published ports
OSTRAKON_HTTP_PORT / OSTRAKON_HTTPS_PORT 8080 / 8443 Host ports
OSTRAKON_SITE_ADDRESS :80 :80 is plain HTTP, a domain turns on HTTPS
OSTRAKON_ACME_EMAIL empty Optional contact address for the certificate authority (mode b)
OSTRAKON_COOKIE_SECURE true .env.example sets false for mode a
OSTRAKON_SIGNUP_ENABLED true false closes registrations
OSTRAKON_GEOIP_ENABLED false See GeoIP
OSTRAKON_TRUSTED_PROXIES empty Another proxy in front of Caddy

The edition is not set: community is the default. The database user and name are ostrakon (OSTRAKON_DATABASE_USER, OSTRAKON_DATABASE_DATABASE); they are only applied when the volume is created, so choose them before the first start.

The default. Caddy listens on 127.0.0.1:8080, nothing else is published. The refresh cookie is not Secure (browsers refuse that over plain HTTP outside localhost).

Needs a domain that resolves to the machine, and ports 80 and 443 reachable from the Internet. In .env:

Terminal window
OSTRAKON_SITE_ADDRESS=ostrakon.example.com
OSTRAKON_BIND_ADDRESS=0.0.0.0
OSTRAKON_HTTP_PORT=80
OSTRAKON_HTTPS_PORT=443
OSTRAKON_COOKIE_SECURE=true
OSTRAKON_ACME_EMAIL=you@example.com # optional, the CA writes there about expiry

Then docker compose up -d. Caddy gets and renews the certificate itself and keeps it in the caddy_data volume. Do this after the first account exists (see above).

Behind another reverse proxy instead, keep mode a on a port of your choice and point the proxy at it. Set OSTRAKON_TRUSTED_PROXIES to the proxy address so the real client IP reaches the API.

With plans off, no per-account rate limit applies (read, write, ingestion). Only the per-IP limiter of the public routes remains. If the instance is reachable from the Internet, put a rate limit in front of it (details).

Off by default: the stack starts and ingests events without any database. To add the country and city of events:

  1. Create a free account on the MaxMind website (GeoLite2) and download GeoLite2-City.mmdb. MaxMind's licence does not let this project redistribute it.
  2. Put the file in deploy/selfhost/geoip/ (mounted read-only as /data, ignored by git). Another folder: set OSTRAKON_GEOIP_DIR.
  3. Set OSTRAKON_GEOIP_ENABLED=true and run docker compose up -d.

If it is enabled but the file is missing or unreadable, the API logs a warning (geoip enrichment disabled) and runs without it.

Terminal window
docker compose logs -f api # API logs
docker compose ps # health
docker compose down # stop, keeps the data
docker compose down -v # stop and DELETE the data (database, certificates)

Retention: events keep the expires_at they got when stored. Details in editions.

  • Web app: Settings > About shows the version, commit and build date.

  • API: GET /api/v1/system/info needs an authenticated account (JWT or API key), it is not public. With an API key:

    Terminal window
    curl -H "X-API-Key: <key>" http://localhost:8080/api/v1/system/info

    The answer carries version, commit, build_date, environment, edition, plans_enabled, migration (applied, expected, dirty) and timescaledb_version (details). Pulled images report the release tag (v0.9.2), dev / unknown means an image built without the APP_* variables.

Back up first: docker compose exec postgres pg_dump -U ostrakon ostrakon > backup.sql, and keep the JWT secret and the pepper of .env. Migrations run when the API starts, there is nothing else to apply.

Pulled images (the default): set the new tag in .env, then

Terminal window
docker compose pull
docker compose up -d

Images built from the clone: git pull, refill the APP_* variables (see Install), then

Terminal window
docker compose build
docker compose up -d

Check the result with the version check above and docker compose ps.

The ostra CLI lives in ostrakon-app/ostra (install: see the CLI guide). Point it at your instance:

Terminal window
ostra config set endpoint http://localhost:8080/api/v1
ostra login --osp <your OSP>
ostra triggers create my-first-trigger # prints the trigger id
ostra events send <trigger id>

An exported OSTRA_API_KEY takes precedence over the login: unset it if the CLI answers invalid API key. You can also use curl with an API key, see the getting started guide.

  • required variable ... is missing a value: a secret of .env is empty, or there is no .env.
  • The api container never gets healthy: read docker compose logs api, then see below.

The entrypoint of the api image checks the configuration first, then waits for the database. The last lines of docker compose logs api tell which one failed.

  • Error: invalid configuration: ...: the configuration is refused and the container exits at once, no waiting. The message names the key at fault, never its value. For example auth.jwt_secret is a placeholder, set a real secret or ... must be at least 32 bytes: fix the matching variable in .env, then docker compose up -d. Unknown OSTRAKON_* variables are only reported as warnings, check their spelling.
  • waiting for database... then database not reachable after 60s: ...: the configuration is fine but PostgreSQL did not answer in time. The text after the colon is the last connection error (host and port included, never the password). Check that the postgres container is healthy (docker compose ps), that OSTRAKON_DATABASE_HOST and the port point at it, and that the credentials match the ones the database was created with.
  • The wait lasts 60 seconds by default. Set OSTRAKON_DB_WAIT_TIMEOUT (seconds) on the api service for a slower database. Once it expires the container exits with an error and the restart policy tries again.
File Role
compose.yaml The stack
compose.build.yaml Optional: builds the images from the clone instead of pulling them
.env.example The configuration, copy to .env
Caddyfile Caddy config of the web container, replaces the image's default (docker/Caddyfile)
geoip/ Where the optional MaxMind database goes