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
| Service | Image | Port (host → container) | Data | Health check |
|---|---|---|---|---|
postgres | pgvector/pgvector:pg18 | 127.0.0.1:5432 → 5432 | pgdata18 volume | pg_isready |
migrator | ghcr.io/hubstruct/migrator | Runs once, exits 0 | ||
storage | dxflrs/garage | ${MEDIA_DIR}/storage/{meta,data} | ||
models | ghcr.io/hubstruct/models | 127.0.0.1:8090 → 8080 | models volume | /health |
vision | ghcr.io/hubstruct/vision | 127.0.0.1:8092 → 8092 | /health | |
api | ghcr.io/hubstruct/api | 127.0.0.1:3000 → 3000 | /health/ready | |
worker | ghcr.io/hubstruct/worker | |||
console | ghcr.io/hubstruct/console | 4173 → 3000 | ||
otel-lgtm | grafana/otel-lgtm | 127.0.0.1:3001 → 3000, 127.0.0.1:4318 → 4318 | otel_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:
postgres, until it's healthy.migrator, which applies any new database migrations and exits. Everything that uses the database waits for it to finish successfully.models-download(once: it downloads the models, then exits), thenstorage,models,vision.api, once the migrator is done and storage has started.worker, likewise. The vision service is optional for it: the steps that need them wait while they're down.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:
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.