Entrivia
Self-hosting

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.com for the portal, visit.example.com for the guest UI and files.example.com for 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.
  • openssl to 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. 1

    Copy the files

    Filesdeploy/compose/compose.ymldeploy/compose/.env.example

    Put compose.yml and .env.example into one directory on the host, for example /opt/entrivia, and create your .env from the template. All later commands run in this directory.

    sh
    mkdir -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. 2

    Choose the images

    Filesdeploy/compose/.env.example

    The images are named once, in .env: ENTRIVIA_IMAGE_PREFIX and ENTRIVIA_VERSION make <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:

    sh
    docker 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:

    .env
    ENTRIVIA_IMAGE_PREFIX=localhost/entrivia
    ENTRIVIA_VERSION=local

    Build on the host itself, or move the images there with docker save and docker load. Do not pass VITE_API_BASE to the portal and guest builds; this install relies on same-origin API calls.

  3. 3

    Set the public URLs

    Filesdeploy/compose/.env.example

    In .env, set the three origins, with https:// and without a trailing slash:

    .env
    PORTAL_URL=https://visitors.example.com
    GUEST_URL=https://visit.example.com
    S3_ENDPOINT=https://files.example.com

    Every emailed link is built from PORTAL_URL and GUEST_URL. Choose PORTAL_URL for good before anyone signs in: passkeys are bound to its host name, and changing it later makes every registered passkey unusable.

  4. 4

    Generate the secrets

    Filesdeploy/compose/.env.example

    Generate each value and paste it into .env:

    sh
    openssl 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_KEY

    S3_ACCESS_KEY may stay entrivia. Keep a copy of .env somewhere safe: without ENCRYPTION_KEY, stored connector credentials cannot be decrypted, and without POSTGRES_PASSWORD the database cannot be opened. To replace ENCRYPTION_KEY later, see “Rotate the encryption key” below.

  5. 5

    Configure email

    Filesdeploy/compose/.env.example

    Set your relay in .env:

    .env
    SMTP_HOST=smtp.example.com
    SMTP_PORT=587
    SMTP_USER=...
    SMTP_PASSWORD=...
    SMTP_FROM=no-reply@example.com

    Leave SMTP_USER and SMTP_PASSWORD empty for a relay without authentication. Port 465 means implicit TLS; set SMTP_SECURE=true for implicit TLS on another port.

    CONNECTORS stays empty unless you use integrations (Slack, Teams, calendars). Every other variable is described in docs/env-reference.md; to set one, add a line to .env.

  6. 6

    Configure the reverse proxy

    Route the three names to the host ports the containers publish on 127.0.0.1 (defaults in .env: API 8080, portal 8081, guest UI 8082, object store 8083):

    HostPathForward to
    visitors.example.comPortal/auth/*/graphql/v1/*/g/*/webhooks/*127.0.0.1:8080API
    visitors.example.comPortaleverything else127.0.0.1:8081Portal
    visit.example.comGuest UI/graphql/v1/*/g/*127.0.0.1:8080API
    visit.example.comGuest UIeverything else127.0.0.1:8082Guest UI
    files.example.comFileseverything127.0.0.1:8083Object store

    The proxy must

    • Pass WebSocket upgrades on /graphql (live updates).
    • Send X-Forwarded-For and X-Forwarded-Proto. The API trusts them only from private and loopback addresses, which is where the proxy connects from.
    • Keep the original Host header 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 · Caddyfile
    visitors.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.

  7. 7

    Start

    Filesdeploy/compose/compose.yml

    sh
    docker compose up -d

    Compose 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:

    sh
    docker 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 answer

    If the API exits right away, docker compose logs api names the missing or invalid variable.

  8. 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:

    sh
    docker 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

    --locale is en-US, de-DE or fr-FR; --time-zone an IANA zone; --site-country a two-letter ISO code. Instead of flags, the command also reads WORKSPACE_NAME, WORKSPACE_LOCALE, WORKSPACE_TIME_ZONE, WORKSPACE_SITE_NAME, WORKSPACE_SITE_COUNTRY and WORKSPACE_OWNER_EMAIL from .env; flags win.

    Exit codes: 0 done, 1 a workspace already exists (nothing changed), 2 invalid input, 3 any other failure (nothing written, run it again).

  9. 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):

    sh
    docker 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.

VariableRequiredValue or how to generatePurpose
ENTRIVIA_IMAGE_PREFIXRequiredghcr.io/entriviaRegistry path of the three images. localhost/entrivia when built from source.
ENTRIVIA_VERSIONRequired0.1.0Image tag. local when built from source.
PORTAL_URLRequiredhttps://visitors.example.comPublic origin of the portal; staff emails link here. Passkeys are bound to its host name.
GUEST_URLRequiredhttps://visit.example.comPublic origin of the guest UI; visitor emails link here.
S3_ENDPOINTRequiredhttps://files.example.comPublic HTTPS origin of the object store; browsers and kiosks upload through presigned URLs on it.
POSTGRES_PASSWORDRequiredopenssl rand -hex 32Password of the bundled PostgreSQL. Hex is safe inside DATABASE_URL.
JWT_SECRETRequiredopenssl rand -hex 64Signs access and refresh tokens. The API refuses to boot with the placeholder value.
ENCRYPTION_KEYRequiredopenssl rand -hex 32Encrypts connector credentials, webhook signing secrets and the links in queued emails at rest. Losing it makes them unreadable.
ENCRYPTION_KEY_PREVIOUSOptionalSet 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_KEYRequiredentriviaAccess key of the object store; RustFS’s root user in this install.
S3_SECRET_KEYRequiredopenssl rand -hex 32Secret key of the object store, at least 8 characters.
SMTP_HOSTRequiredsmtp.example.comYour SMTP relay.
SMTP_PORTOptional587Relay port. 465 means implicit TLS.
SMTP_USEROptionalRelay username; empty means no authentication.
SMTP_PASSWORDOptionalRelay password.
SMTP_FROMRequiredno-reply@example.comSender address, on a domain you control.
CONNECTORSRequiredConnector assemblies to load, comma-separated, e.g. Entrivia.Connectors.Slack. Empty loads none.
METRICS_TOKENOptionalopenssl rand -hex 32Turns on GET /metrics for a scraper holding this token, at least 32 characters.
TELEMETRY_ENABLEDOptionalfalsefalse switches the weekly anonymous install report off for good.

Upgrade

  1. Read the release notes of the new version.
  2. Back up (below).
  3. Set the new ENTRIVIA_VERSION in .env, or rebuild the images from the new checkout.
  4. Pull and restart:
sh
docker compose pull
docker compose up -d

migrate 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.

sh
docker compose exec -T postgres pg_dump -U entrivia -Fc entrivia > entrivia.dump

Rotate 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:

  1. Back up (above) and keep the current .env with that backup: the backup stays readable only with the current key.

  2. Generate a new key with openssl rand -hex 32. In .env, set ENCRYPTION_KEY_PREVIOUS to the current key and ENCRYPTION_KEY to the new one, then run docker compose up -d. Everything keeps working: stored values open with either key, and new ones are encrypted with the new key.

  3. Encrypt every stored value again with the new key:

    sh
    docker compose run --rm api encryption:rotate

    The command prints how many values it rewrote of each kind and records encryption.rotated in the audit log. It is safe to run while Entrivia is in use, and safe to run again; a second run reports zeros.

  4. Exit code 0: delete ENCRYPTION_KEY_PREVIOUS from .env and run docker compose up -d again. Exit code 1: some values open with neither key and were left as they are; keep ENCRYPTION_KEY_PREVIOUS and check that it is the key the install used before. Exit code 2 means invalid input, 3 any 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_TOKEN set, scrape http://127.0.0.1:8080/metrics with Authorization: Bearer <token>. The proxy routes above do not expose it.
  • Stop without losing data: docker compose down. docker compose down -v deletes 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.
/readyz answers 503
The API cannot reach Postgres or Valkey. The response body names which one is unreachable (db, redis).
migrate exits 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 its https:// address through the proxy.
Photo uploads or images fail
S3_ENDPOINT must be the public https:// origin of the files host, the proxy must keep the Host header, 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 api for SMTP errors. Mail is sent by a background job, so the API keeps running.