Reference
Environment variables
Every setting in .env and the Compose file, what it does, and its default.
Hubstruct's self-hosted settings live in .env, next to the Compose file. Compose reads it on every up and passes each value to the services that need it. Change a value, then docker compose up -d to apply it; only the affected services restart.
Settings you change while Hubstruct runs, such as step concurrency, NSFW, sign-in and each library's settings, live in the app, in Settings, not here.
| Variable | Means |
|---|
POSTGRES_PASSWORD | The database's password. Also the source of the app secret, if APP_SECRET is unset. |
S3_RPC_SECRET | The storage service's internal secret: 64 hex characters. |
S3_ACCESS_KEY | The storage access key: GK and 24 hex characters. |
S3_SECRET_KEY | The storage secret key: 64 hex characters. |
Generate them as in Quick start. Don't change the storage keys after the first start.
| Variable | Default | Means |
|---|
POSTGRES_USER | tagging | The database user |
POSTGRES_DB | mediadb | The database's name |
POSTGRES_SHARED_BUFFERS | 2GB | What Postgres caches itself. About a quarter of the machine's memory; halve these four on a machine under 16 GB |
POSTGRES_EFFECTIVE_CACHE_SIZE | 8GB | What Postgres may assume the system caches besides, for planning |
POSTGRES_WORK_MEM | 32MB | Memory per sort or hash before it spills to disk |
POSTGRES_MAINTENANCE_WORK_MEM | 512MB | Memory for building indexes and vacuuming |
| Variable | Default | Means |
|---|
APP_SECRET | Derived from POSTGRES_PASSWORD | Encrypts secrets kept in the database. Set it to a long random value to keep it independent of the database password. Changing it makes the stored secrets unreadable: enter them again. |
APP_ORIGINS | Empty | Other origins allowed to call the API with a session cookie, comma-separated. See HTTPS and a domain. |
| Variable | Default | Means |
|---|
APP_PORT | 4173 | Where the app is published on the host |
API_PORT | 3000 | Where the API is published on the machine itself (127.0.0.1) |
GRAFANA_PORT | 3001 | Where Grafana is published on the machine itself (127.0.0.1). See Telemetry. |
| Variable | Default | Means |
|---|
MEDIA_DIR | ./data | The host folder for storage's files: storage/meta and storage/data under it |
S3_BUCKET | hubstruct | The bucket's name |
See Storage.
| Variable | Default | Means |
|---|
WORKER_ROLES | all | What the worker runs. See Worker roles. |
DOWNLOAD_DELAY_MS | 500 | A pause after each picture a step downloads |
| Variable | Default | Means |
|---|
LOG_LEVEL | info | How much the API, worker, vision service and migrator log: trace, debug, info, warn or error. Logs are JSON, one event per line. |
| Variable | Default | Means |
|---|
OTEL_SDK_DISABLED | false | true turns telemetry off: nothing is recorded or sent. |
OTEL_EXPORTER_OTLP_ENDPOINT | http://otel-lgtm:4318 | Where traces, metrics and logs are sent, over OTLP/HTTP. The default is the bundled Grafana stack. |
OTEL_METRIC_EXPORT_INTERVAL | 15000 | How often metrics are sent, in milliseconds |
See Telemetry.
| Variable | Default | Means |
|---|
HUBSTRUCT_VERSION | latest | The version of Hubstruct's images to run. Pin it to update only when you choose. See Updating. |
Each service's most CPU cores. See Scaling.
| Variable | Default |
|---|
POSTGRES_CPUS | 6 |
MODELS_CPUS | 6 |
VISION_CPUS | 8 |
OTEL_LGTM_CPUS | 2 |
WORKER_CPUS | 6 |
API_CPUS | 3 |
WEB_CPUS | 2 |
STORAGE_CPUS | 2 |
MIGRATOR_CPUS | 2 |
| Variable | Default | Means |
|---|
VISION_CONCURRENCY | 1 | Requests the vision service handles at once |
VISION_TEXT_DEVICE | cuda | Run the text detector on cuda or cpu |
VISION_FACES_DEVICE | cuda | Run the face models on cuda or cpu |
VISION_IDLE_MS | 600000 (10 min) | Close the models after this long without a request, giving their GPU memory back (0: never) |
So a stuck model can't hold a worker forever, each call has a time limit. To change one, add it to the worker's environment: in the Compose file.
| Variable | Default | Limits |
|---|
DESCRIBE_TIMEOUT_MS | 300000 (5 min) | A description or title |
EMBED_TIMEOUT_MS | 120000 (2 min) | An embedding |
DECISION_TIMEOUT_MS | 300000 (5 min) | A tagging or NSFW request |
STEP_DEADLINE_MS | 1200000 (20 min) | One step's whole run |
These connect the services to each other. You don't need to change them unless you move a service elsewhere:
| Variable | Set to | On |
|---|
POSTGRES_HOST | postgres | api, worker, migrator |
MODELS_URL | http://models:8080 | api, worker |
VISION_URL | http://vision:8092 | api, worker |
S3_ENDPOINT | http://storage:3900 | api, worker |
S3_REGION | garage | api, worker |
NUXT_API_URL | http://api:3000 | console |
NUXT_TRUST_PROXY | false | console: behind a reverse proxy, true takes each browser's address from the X-Forwarded-For the proxy adds (for the sign-in limits) |
MIGRATIONS_DIR | /migrations | migrator |
SERVICE_NAME | The service's name | api, worker, migrator |