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.

Required

VariableMeans
POSTGRES_PASSWORDThe database's password. Also the source of the app secret, if APP_SECRET is unset.
S3_RPC_SECRETThe storage service's internal secret: 64 hex characters.
S3_ACCESS_KEYThe storage access key: GK and 24 hex characters.
S3_SECRET_KEYThe storage secret key: 64 hex characters.

Generate them as in Quick start. Don't change the storage keys after the first start.

The database

VariableDefaultMeans
POSTGRES_USERtaggingThe database user
POSTGRES_DBmediadbThe database's name
POSTGRES_SHARED_BUFFERS2GBWhat Postgres caches itself. About a quarter of the machine's memory; halve these four on a machine under 16 GB
POSTGRES_EFFECTIVE_CACHE_SIZE8GBWhat Postgres may assume the system caches besides, for planning
POSTGRES_WORK_MEM32MBMemory per sort or hash before it spills to disk
POSTGRES_MAINTENANCE_WORK_MEM512MBMemory for building indexes and vacuuming

Security

VariableDefaultMeans
APP_SECRETDerived from POSTGRES_PASSWORDEncrypts 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_ORIGINSEmptyOther origins allowed to call the API with a session cookie, comma-separated. See HTTPS and a domain.

Ports

VariableDefaultMeans
APP_PORT4173Where the app is published on the host
API_PORT3000Where the API is published on the machine itself (127.0.0.1)
GRAFANA_PORT3001Where Grafana is published on the machine itself (127.0.0.1). See Telemetry.

Storage

VariableDefaultMeans
MEDIA_DIR./dataThe host folder for storage's files: storage/meta and storage/data under it
S3_BUCKEThubstructThe bucket's name

See Storage.

The worker

VariableDefaultMeans
WORKER_ROLESallWhat the worker runs. See Worker roles.
DOWNLOAD_DELAY_MS500A pause after each picture a step downloads

Logging

VariableDefaultMeans
LOG_LEVELinfoHow much the API, worker, vision service and migrator log: trace, debug, info, warn or error. Logs are JSON, one event per line.

Telemetry

VariableDefaultMeans
OTEL_SDK_DISABLEDfalsetrue turns telemetry off: nothing is recorded or sent.
OTEL_EXPORTER_OTLP_ENDPOINThttp://otel-lgtm:4318Where traces, metrics and logs are sent, over OTLP/HTTP. The default is the bundled Grafana stack.
OTEL_METRIC_EXPORT_INTERVAL15000How often metrics are sent, in milliseconds

See Telemetry.

Versions

VariableDefaultMeans
HUBSTRUCT_VERSIONlatestThe version of Hubstruct's images to run. Pin it to update only when you choose. See Updating.

CPU limits

Each service's most CPU cores. See Scaling.

VariableDefault
POSTGRES_CPUS6
MODELS_CPUS6
VISION_CPUS8
OTEL_LGTM_CPUS2
WORKER_CPUS6
API_CPUS3
WEB_CPUS2
STORAGE_CPUS2
MIGRATOR_CPUS2

The models

VariableDefaultMeans
VISION_CONCURRENCY1Requests the vision service handles at once
VISION_TEXT_DEVICEcudaRun the text detector on cuda or cpu
VISION_FACES_DEVICEcudaRun the face models on cuda or cpu
VISION_IDLE_MS600000 (10 min)Close the models after this long without a request, giving their GPU memory back (0: never)

Timeouts

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.

VariableDefaultLimits
DESCRIBE_TIMEOUT_MS300000 (5 min)A description or title
EMBED_TIMEOUT_MS120000 (2 min)An embedding
DECISION_TIMEOUT_MS300000 (5 min)A tagging or NSFW request
STEP_DEADLINE_MS1200000 (20 min)One step's whole run

Set by the Compose file

These connect the services to each other. You don't need to change them unless you move a service elsewhere:

VariableSet toOn
POSTGRES_HOSTpostgresapi, worker, migrator
MODELS_URLhttp://models:8080api, worker
VISION_URLhttp://vision:8092api, worker
S3_ENDPOINThttp://storage:3900api, worker
S3_REGIONgarageapi, worker
NUXT_API_URLhttp://api:3000console
NUXT_TRUST_PROXYfalseconsole: 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/migrationsmigrator
SERVICE_NAMEThe service's nameapi, worker, migrator