Self-hosting · Docker Compose
Install Entrivia with Docker Compose.
A reference install of one workspace on a single Linux host: the API, the portal, the guest UI, PostgreSQL 16, Valkey 8 and RustFS, all in one compose.yml. One way to run Entrivia, not the only one; adapt it to how you operate servers.
Not included, because they are yours to choose: the reverse proxy that terminates TLS, the SMTP relay that delivers mail, DNS and backups.
What you need
- A Linux host with Docker Engine and the Compose plugin (or Podman with
podman compose), with disk space for the database and the uploads. - Three DNS names pointing at the host. This guide uses
visitors.example.comfor the portal,visit.example.comfor the guest UI andfiles.example.comfor the object store. - Any reverse proxy that terminates TLS for those three names and forwards to ports on
127.0.0.1. - An SMTP relay that accepts mail from the host, with a sender address on a domain you control.
opensslto generate secrets.
How the pieces fit
The portal and guest images serve static files and call the API on their own origin: /auth, /graphql and /v1 from the portal, /graphql, /g and /v1 from the guest UI. Same-origin calls keep the sign-in cookies first-party, so the reverse proxy routes those paths to the API on each host. That is why compose.yml sets API_BASE_URL to PORTAL_URL.
Uploads never pass through the API: it hands out short-lived presigned URLs on S3_ENDPOINT, and the browser or kiosk talks to the store directly. That is why the store needs its own public HTTPS name. The API reaches the store at that same address, so the host must be able to reach its own public names.
Install
Nine steps to the first sign-in.
- 1
Copy the files
Filesdeploy/compose/compose.ymldeploy/compose/.env.example
Put
compose.ymland.env.exampleinto one directory on the host, for example/opt/entrivia, and create your.envfrom the template. All later commands run in this directory.shmkdir -p /opt/entrivia && cd /opt/entrivia # copy compose.yml and .env.example from deploy/compose/ in the repository cp .env.example .env chmod 600 .env - 2
Choose the images
Filesdeploy/compose/.env.example
The images are named once, in
.env:ENTRIVIA_IMAGE_PREFIXandENTRIVIA_VERSIONmake<prefix>/api:<version>,<prefix>/portal:<version>and<prefix>/guest:<version>.Published images are not available yet. Until they are, build the three images from a checkout of the repository, from its root directory:
shdocker build -f apps/api/Dockerfile -t localhost/entrivia/api:local . docker build -f apps/portal/Dockerfile -t localhost/entrivia/portal:local . docker build -f apps/guest/Dockerfile -t localhost/entrivia/guest:local .Then set in
.env:.envENTRIVIA_IMAGE_PREFIX=localhost/entrivia ENTRIVIA_VERSION=localBuild on the host itself, or move the images there with
docker saveanddocker load. Do not passVITE_API_BASEto the portal and guest builds; this install relies on same-origin API calls. - 3
Set the public URLs
Filesdeploy/compose/.env.example
In
.env, set the three origins, withhttps://and without a trailing slash:.envPORTAL_URL=https://visitors.example.com GUEST_URL=https://visit.example.com S3_ENDPOINT=https://files.example.comEvery emailed link is built from
PORTAL_URLandGUEST_URL. ChoosePORTAL_URLfor good before anyone signs in: passkeys are bound to its host name, and changing it later makes every registered passkey unusable. - 4
Generate the secrets
Filesdeploy/compose/.env.example
Generate each value and paste it into
.env:shopenssl rand -hex 32 # POSTGRES_PASSWORD openssl rand -hex 64 # JWT_SECRET (replace the placeholder; the API refuses to boot with it) openssl rand -hex 32 # ENCRYPTION_KEY openssl rand -hex 32 # S3_SECRET_KEYS3_ACCESS_KEYmay stayentrivia. Keep a copy of.envsomewhere safe: withoutENCRYPTION_KEY, stored connector credentials cannot be decrypted, and withoutPOSTGRES_PASSWORDthe database cannot be opened. To replaceENCRYPTION_KEYlater, see “Rotate the encryption key” below. - 5
Configure email
Filesdeploy/compose/.env.example
Set your relay in
.env:.envSMTP_HOST=smtp.example.com SMTP_PORT=587 SMTP_USER=... SMTP_PASSWORD=... SMTP_FROM=no-reply@example.comLeave
SMTP_USERandSMTP_PASSWORDempty for a relay without authentication. Port 465 means implicit TLS; setSMTP_SECURE=truefor implicit TLS on another port.CONNECTORSstays empty unless you use integrations (Slack, Teams, calendars). Every other variable is described indocs/env-reference.md; to set one, add a line to.env. - 6
Configure the reverse proxy
Route the three names to the host ports the containers publish on
127.0.0.1(defaults in.env: API8080, portal8081, guest UI8082, object store8083):Host Path Forward to visitors.example.comPortal /auth/*/graphql/v1/*/g/*/webhooks/*127.0.0.1:8080API visitors.example.comPortal everything else 127.0.0.1:8081Portal visit.example.comGuest UI /graphql/v1/*/g/*127.0.0.1:8080API visit.example.comGuest UI everything else 127.0.0.1:8082Guest UI files.example.comFiles everything 127.0.0.1:8083Object store The proxy must
- Pass WebSocket upgrades on
/graphql(live updates). - Send
X-Forwarded-ForandX-Forwarded-Proto. The API trusts them only from private and loopback addresses, which is where the proxy connects from. - Keep the original
Hostheader for the object store; presigned URLs are signed for it. - Accept request bodies of at least 25 MB on the files host (the largest upload).
Example only: the same routing as a Caddyfile
Example · Caddyfilevisitors.example.com { @api path /auth/* /graphql /graphql/* /v1/* /g/* /webhooks/* handle @api { reverse_proxy 127.0.0.1:8080 } handle { reverse_proxy 127.0.0.1:8081 } } visit.example.com { @api path /graphql /graphql/* /v1/* /g/* handle @api { reverse_proxy 127.0.0.1:8080 } handle { reverse_proxy 127.0.0.1:8082 } } files.example.com { reverse_proxy 127.0.0.1:8083 }Caddy obtains the certificates itself. Any other proxy works as well.
- Pass WebSocket upgrades on
- 7
Start
Filesdeploy/compose/compose.yml
shdocker compose up -dCompose starts PostgreSQL, Valkey and RustFS, creates the bucket (
rustfs-init), applies the database migrations (migrate), and starts the API, portal and guest UI only after both finished successfully. Check:shdocker compose ps -a # migrate and rustfs-init: exited (0); the rest: running docker compose logs migrate # "Applied n migration(s)" or "The database is up to date." curl -fsS http://127.0.0.1:8080/readyz # {"status":"ok",...} once Postgres and Valkey answerIf the API exits right away,
docker compose logs apinames the missing or invalid variable. - 8
Create the workspace
Filesdeploy/compose/.env.example
A new install has no workspace; the portal shows “not set up yet” until one exists. Create it and invite the first owner:
shdocker compose run --rm api workspace:setup \ --name "Example GmbH" \ --locale de-DE \ --time-zone Europe/Berlin \ --site-name "Berlin HQ" \ --site-country DE \ --owner-email owner@example.com--localeisen-US,de-DEorfr-FR;--time-zonean IANA zone;--site-countrya two-letter ISO code. Instead of flags, the command also readsWORKSPACE_NAME,WORKSPACE_LOCALE,WORKSPACE_TIME_ZONE,WORKSPACE_SITE_NAME,WORKSPACE_SITE_COUNTRYandWORKSPACE_OWNER_EMAILfrom.env; flags win.Exit codes:
0done,1a workspace already exists (nothing changed),2invalid input,3any other failure (nothing written, run it again). - 9
First sign-in
The command prints an accept link, valid for 24 hours, and emails it to the owner. Whoever opens the link first becomes the owner, so keep it out of shared chats and logs. The owner opens it, sets a password and lands in the portal, where onboarding continues.
If the link expires or gets lost before it is accepted, issue a new one (the old one stops working):
shdocker compose run --rm api workspace:reissue-owner
Variables
Every value in .env.
The variables the template asks you to set. Everything else has a default; docs/env-reference.md describes all of them, and a line in .env reaches the API.
| Variable | Required | Value or how to generate | Purpose |
|---|---|---|---|
ENTRIVIA_IMAGE_PREFIX | Required | ghcr.io/entrivia | Registry path of the three images. localhost/entrivia when built from source. |
ENTRIVIA_VERSION | Required | 0.1.0 | Image tag. local when built from source. |
PORTAL_URL | Required | https://visitors.example.com | Public origin of the portal; staff emails link here. Passkeys are bound to its host name. |
GUEST_URL | Required | https://visit.example.com | Public origin of the guest UI; visitor emails link here. |
S3_ENDPOINT | Required | https://files.example.com | Public HTTPS origin of the object store; browsers and kiosks upload through presigned URLs on it. |
POSTGRES_PASSWORD | Required | openssl rand -hex 32 | Password of the bundled PostgreSQL. Hex is safe inside DATABASE_URL. |
JWT_SECRET | Required | openssl rand -hex 64 | Signs access and refresh tokens. The API refuses to boot with the placeholder value. |
ENCRYPTION_KEY | Required | openssl rand -hex 32 | Encrypts connector credentials, webhook signing secrets and the links in queued emails at rest. Losing it makes them unreadable. |
ENCRYPTION_KEY_PREVIOUS | Optional | Set only while you rotate ENCRYPTION_KEY: the key it replaced. Values encrypted with it still open until encryption:rotate has rewritten them; then remove it. | |
S3_ACCESS_KEY | Required | entrivia | Access key of the object store; RustFS’s root user in this install. |
S3_SECRET_KEY | Required | openssl rand -hex 32 | Secret key of the object store, at least 8 characters. |
SMTP_HOST | Required | smtp.example.com | Your SMTP relay. |
SMTP_PORT | Optional | 587 | Relay port. 465 means implicit TLS. |
SMTP_USER | Optional | Relay username; empty means no authentication. | |
SMTP_PASSWORD | Optional | Relay password. | |
SMTP_FROM | Required | no-reply@example.com | Sender address, on a domain you control. |
CONNECTORS | Required | Connector assemblies to load, comma-separated, e.g. Entrivia.Connectors.Slack. Empty loads none. | |
METRICS_TOKEN | Optional | openssl rand -hex 32 | Turns on GET /metrics for a scraper holding this token, at least 32 characters. |
TELEMETRY_ENABLED | Optional | false | false switches the weekly anonymous install report off for good. |
Upgrade
- Read the release notes of the new version.
- Back up (below).
- Set the new
ENTRIVIA_VERSIONin.env, or rebuild the images from the new checkout. - Pull and restart:
docker compose pull
docker compose up -dmigrate runs again before the new API starts and applies only what is pending. Migrations are forward-only: going back to an older version needs the backup taken before the upgrade.
Back up
Back up two things: the database, with a logical dump, and the contents of the entrivia bucket, with any S3 tool (for example rclone sync) or by backing up the rustfs-data volume while RustFS is stopped. Keep .env with them. Schedule, retention, encryption and where the copies go are your decisions.
docker compose exec -T postgres pg_dump -U entrivia -Fc entrivia > entrivia.dumpRotate the encryption key
ENCRYPTION_KEY encrypts the stored connector credentials, webhook signing secrets and the links in queued emails, and sanctions screening uses it for the hashes by which it recognises a visitor it has checked before. To replace the key without losing any of them:
Back up (above) and keep the current
.envwith that backup: the backup stays readable only with the current key.Generate a new key with
openssl rand -hex 32. In.env, setENCRYPTION_KEY_PREVIOUSto the current key andENCRYPTION_KEYto the new one, then rundocker compose up -d. Everything keeps working: stored values open with either key, and new ones are encrypted with the new key.Encrypt every stored value again with the new key:
shdocker compose run --rm api encryption:rotateThe command prints how many values it rewrote of each kind and records
encryption.rotatedin the audit log. It is safe to run while Entrivia is in use, and safe to run again; a second run reports zeros.Exit code
0: deleteENCRYPTION_KEY_PREVIOUSfrom.envand rundocker compose up -dagain. Exit code1: some values open with neither key and were left as they are; keepENCRYPTION_KEY_PREVIOUSand check that it is the key the install used before. Exit code2means invalid input,3any other failure; run it again.
Two things in sanctions screening cannot move to the new key: a check whose guest details changed after it ran, and a false positive whose checks were already deleted at the end of their retention period. Once the previous key is gone, the next screening of that visitor asks the screening service again, and a reviewer may have to clear the same match once more. The details are in docs/env-reference.md.
Operate
- Logs:
docker compose logs -f api, structured JSON on stdout. - Probes:
http://127.0.0.1:8080/healthz(liveness) and/readyz(readiness: Postgres and Valkey). - Metrics: with
METRICS_TOKENset, scrapehttp://127.0.0.1:8080/metricswithAuthorization: Bearer <token>. The proxy routes above do not expose it. - Stop without losing data:
docker compose down.docker compose down -vdeletes the database and every upload.
Troubleshooting
- The API exits with “… must be set in production”
- The named variable is missing from
.env. “JWT_SECRET is a public development secret” means the placeholder was not replaced. /readyzanswers 503- The API cannot reach Postgres or Valkey. The response body names which one is unreachable (
db,redis). migrateexits with code 1- The database has Entrivia tables but no migration history. Nothing was changed; this install expects the empty database Compose created on its first start.
- Sign-in does not stick
- In production the auth cookies are
Secure, and browsers keep them only over HTTPS. Open the portal at itshttps://address through the proxy. - Photo uploads or images fail
S3_ENDPOINTmust be the publichttps://origin of the files host, the proxy must keep theHostheader, and the API container must reach that address (docker compose exec api getent hosts files.example.com).- Live updates in the portal do not arrive
- The proxy drops WebSocket upgrades on
/graphql. - No email arrives
- Check
docker compose logs apifor SMTP errors. Mail is sent by a background job, so the API keeps running.