Self-hosting is by agreement. The container images (
ghcr.io/trustivan/*)
and the source repository are private: they are provided to customers who run
TRUSTIVAN on their own infrastructure. To evaluate TRUSTIVAN, use the hosted
service from the quickstart, or contact
us about self-hosting.ENV=development, and brings up PostgreSQL, Redis, the API and a scan worker.
To deploy, use the other one. See
Production Compose.
The four core services
Both
postgres and redis declare healthchecks, and the two application
services depend_on them with condition: service_healthy. That is what stops
the API racing its own database on a cold start: it does not begin until
pg_isready and redis-cli ping both succeed.
The API and the worker are built from the same image. Two images would have
identical dependencies and identical build steps, and would drift the first time
only one of them was rebuilt, so the binary is selected by the command instead.
The same file also starts the NHI Security services (nhi-postgres,
nhi-migrate, nhi-api and nhi-web), with its own database. They are on by
default and built from nhi/.
Why the split is the default
backend runs with SCAN_WORKER_ENABLED=false; worker runs the same image as
/app/worker.
The API can run the worker in-process (that is the default when you set
nothing), and a single binary with a PostgreSQL and a Redis is a complete
TRUSTIVAN. The compose file nevertheless splits them, deliberately:
If the two can only run together, “a scan survives a worker restart” is a story rather than a property, and nobody discovers otherwise until production.Splitting them in the default configuration means the durability path is exercised every time anyone runs the stack, rather than the first time someone needs it. It also matches the workload’s actual shape: requests are milliseconds, scans are minutes, so the two want to scale independently.
The worker needs no Docker socket
Note what is absent from theworker service: there is no
/var/run/docker.sock mount and no privileged flag.
The scanner resolves images from remote registries only. Mounting a runtime
socket into the process that handles untrusted input would be root on the host,
and consulting a local image store would let a caller-supplied reference resolve
to another tenant’s image. Neither is a trade TRUSTIVAN makes.
Volumes
scanner_cache is mounted at /cache in the worker and is the one worth
understanding. It holds the vulnerability database and the image blob cache.
Persisting it is the difference between a scan taking seconds and taking
minutes, because without it every worker restart re-downloads roughly 50 MB
before it can match anything.
It is also safely disposable: discarding it costs one slow scan, not any data.
See Upgrades.
Secrets are not in the compose file
The compose file carries noJWT_SECRET and no TOKEN_ENCRYPTION_KEY, and this
is not an omission.
JWT_SECRET was once hardcoded here as a published literal that was also the
config layer’s default, so anyone who read the repository could forge a token
for any user. That was a real security finding. In development the backend now
generates an ephemeral random key per process and logs that it did so; in any
deployed environment it refuses to start without one.
For anything beyond local development, supply real values through a .env file
or your orchestrator’s secret mechanism:
Adapting it for a deployment
The shipped file targets local development:ENV=development, PostgreSQL with
postgres/postgres credentials, sslmode=disable, and both database ports
published to the host. Before deploying it anywhere real, change at minimum:
ENV is a security control rather than a label. Anything that is not
development, an unset ENV included, is treated as deployed and validated
strictly, so a typo such as prodction fails closed rather than open.
Outside development the backend refuses to start as a superuser or a
BYPASSRLS role (which the postgres user is), and a worker refuses to start
without a job-plane role, because on the application role it would never see a
queued scan. infra/docker/docker-compose.prod.yml is the production-shaped
file that does all of this for you, including creating both login roles. See
Production Compose.
Remove the ports: mappings on postgres and redis unless you genuinely need
to reach them from the host; inside the compose network the services address
each other by name regardless.
Checking it came up
/ready checks the database and Redis and returns 503 while either is
unavailable. /health is a liveness probe and deliberately checks nothing. See
Health and metrics for why conflating the two
is harmful.
Database migrations run automatically as the API starts, so there is no separate
setup step. Database migrations
explains what that involves and how to run them by hand.
The make wrappers
make docker-up, docker-down, docker-logs and docker-rebuild run
docker compose against this development file from the repository root. They
never start the production file in infra/docker/, which demands real secrets
and pinned images and is started with its own command.
Next
- Production Compose: the deployment stack.
- Configuration overview: the settings model.
- Deployment topology: what to run, and where.
- Quickstart: a first scan; set
TRUSTIVAN_URLto this stack’s address.