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).
Read this first
Section titled “Read this first”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:
- Start it bound to
127.0.0.1(the default), register your account, save your OSP. - Only then expose it (mode b below).
- Optionally close registrations: set
OSTRAKON_SIGNUP_ENABLED=falsein.env, thendocker compose up -d.POST /api/v1/auth/registeranswers403 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.
Requirements
Section titled “Requirements”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.
Install
Section titled “Install”git clone https://github.com/ostrakon-app/ostrakon.gitcd ostrakon/deploy/selfhostcp .env.example .envFill the three secrets of .env. They are empty on purpose, and Compose refuses to start while
one is empty:
openssl rand -base64 48 # OSTRAKON_AUTH_JWT_SECRETopenssl rand -base64 48 # OSTRAKON_AUTH_OSP_PEPPERopenssl rand -hex 24 # OSTRAKON_DATABASE_PASSWORDThen:
docker compose up -d # pulls the images, then starts the stackTo 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:
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.
Configuration: one file, .env
Section titled “Configuration: one file, .env”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.
Mode a: try it locally over HTTP
Section titled “Mode a: try it locally over HTTP”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).
Mode b: your own domain, automatic HTTPS
Section titled “Mode b: your own domain, automatic HTTPS”Needs a domain that resolves to the machine, and ports 80 and 443 reachable from the Internet.
In .env:
OSTRAKON_SITE_ADDRESS=ostrakon.example.comOSTRAKON_BIND_ADDRESS=0.0.0.0OSTRAKON_HTTP_PORT=80OSTRAKON_HTTPS_PORT=443OSTRAKON_COOKIE_SECURE=trueOSTRAKON_ACME_EMAIL=you@example.com # optional, the CA writes there about expiryThen 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.
No rate limit per account
Section titled “No rate limit per account”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).
GeoIP (optional)
Section titled “GeoIP (optional)”Off by default: the stack starts and ingests events without any database. To add the country and city of events:
- Create a free account on the MaxMind website (GeoLite2) and download
GeoLite2-City.mmdb. MaxMind's licence does not let this project redistribute it. - Put the file in
deploy/selfhost/geoip/(mounted read-only as/data, ignored by git). Another folder: setOSTRAKON_GEOIP_DIR. - Set
OSTRAKON_GEOIP_ENABLED=trueand rundocker 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.
Operate
Section titled “Operate”docker compose logs -f api # API logsdocker compose ps # healthdocker compose down # stop, keeps the datadocker compose down -v # stop and DELETE the data (database, certificates)Retention: events keep the expires_at they got when stored. Details in
editions.
Check the deployed version
Section titled “Check the deployed version”-
Web app: Settings > About shows the version, commit and build date.
-
API:
GET /api/v1/system/infoneeds 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/infoThe answer carries
version,commit,build_date,environment,edition,plans_enabled,migration(applied,expected,dirty) andtimescaledb_version(details). Pulled images report the release tag (v0.9.2),dev/unknownmeans an image built without theAPP_*variables.
Update
Section titled “Update”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
docker compose pulldocker compose up -dImages built from the clone: git pull, refill the APP_* variables (see Install), then
docker compose builddocker compose up -dCheck the result with the version check above and docker compose ps.
Send a first event
Section titled “Send a first event”The ostra CLI lives in ostrakon-app/ostra (install: see the CLI guide).
Point it at your instance:
ostra config set endpoint http://localhost:8080/api/v1ostra login --osp <your OSP>ostra triggers create my-first-trigger # prints the trigger idostra 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.
Troubleshooting
Section titled “Troubleshooting”required variable ... is missing a value: a secret of.envis empty, or there is no.env.- The
apicontainer never gets healthy: readdocker compose logs api, then see below.
The container keeps restarting
Section titled “The container keeps restarting”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 exampleauth.jwt_secret is a placeholder, set a real secretor... must be at least 32 bytes: fix the matching variable in.env, thendocker compose up -d. UnknownOSTRAKON_*variables are only reported as warnings, check their spelling.waiting for database...thendatabase 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 thepostgrescontainer is healthy (docker compose ps), thatOSTRAKON_DATABASE_HOSTand 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 theapiservice 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 |