Self-hosting

Architecture

Every container in a self-hosted install, its ports, volumes, health checks and what depends on what.

A self-hosted Hubstruct is one Compose project, named hubstruct, with these services. How it works explains what they do together; this page is the operator's view.

Services

ServiceImagePort (host → container)DataHealth check
postgrespgvector/pgvector:pg18127.0.0.1:5432 → 5432pgdata18 volumepg_isready
migratorghcr.io/hubstruct/migratorRuns once, exits 0
storagedxflrs/garage${MEDIA_DIR}/storage/{meta,data}
modelsghcr.io/hubstruct/models127.0.0.1:8090 → 8080models volume/health
visionghcr.io/hubstruct/vision127.0.0.1:8092 → 8092/health
apighcr.io/hubstruct/api127.0.0.1:3000 → 3000/health/ready
workerghcr.io/hubstruct/worker
consoleghcr.io/hubstruct/console4173 → 3000
otel-lgtmgrafana/otel-lgtm127.0.0.1:3001 → 3000, 127.0.0.1:4318 → 4318otel_lgtm volume

Which ports need to be open

Only console, port 4173, is for people. The others are published for convenience, most of them only on the machine itself (127.0.0.1), and can be removed:

  • 3000 (the API), on the machine itself only, is handy for scripts there and for the API reference at /reference. The app doesn't need it: it reaches the API over Compose's network. Keep it off the network: the API believes the address the app passes on for each browser, and its sign-in limits go by it. From elsewhere, use the API through the app, at /api.
  • 5432 (PostgreSQL) is handy for backups and inspection from the host.
  • 8090 (the models server) shows llama-swap's page of running models, and their logs, from the host.
  • 8092 is for checking the vision service, which has no authentication.
  • 3001 is Grafana, for telemetry, and 4318 takes telemetry from a service run outside Compose. Both on the machine itself only.

Start order

Compose starts things in dependency order:

  1. postgres, until it's healthy.
  2. migrator, which applies any new database migrations and exits. Everything that uses the database waits for it to finish successfully.
  3. models-download (once: it downloads the models, then exits), then storage, models, vision.
  4. api, once the migrator is done and storage has started.
  5. worker, likewise. The vision service is optional for it: the steps that need them wait while they're down.
  6. console, once the API is healthy.

Health

The API's /health/live answers whenever the process is up. /health/ready checks each dependency with a short timeout:

  • ok: everything is up.
  • degraded: an optional dependency is down, such as the models server or the vision service. The API still serves, and the steps that need it wait.
  • down (HTTP 503): the database is down.

Both answer without signing in, and say only what's needed, with no addresses or error text. The dashboard's service health shows the same.

CPU limits

Every service has a CPU limit from .env (API_CPUS, WORKER_CPUS and so on), so a busy one, such as the worker after a big upload, leaves the machine usable. See Scaling and the environment reference.

Logs

The API, worker and migrator write structured JSON logs to standard output, one event per line, with the service's name and a request id for API calls. Read them with:

Terminal
docker compose logs -f api worker

LOG_LEVEL sets how much they say: trace, debug, info (default), warn or error.

Networks

Everything is on the project's default network, where services reach each other by name: http://api:3000, http://models:8080, http://storage:3900. Nothing else needs to be reachable from outside.