Self-hosting
The config file
Set Hubstruct up from a file instead of by hand, from its settings and sign-in to its owner, API keys, libraries, tags and albums.
Everything you'd otherwise set up by clicking through the app can be written in one file instead: the processing settings, Google sign-in, the owner's account, API keys, and libraries with their fields, tags and albums. Start a new install with it and there's no first-run setup; keep it in version control and an install can be rebuilt the same way any time.
What the file sets can't be changed in the app. It's shown with a lock and Set by the config file, and you change it in the file instead.
Using it
The file is config/hubstruct.yaml in the folder you run Hubstruct from. Start from the example beside it:
cp config/hubstruct.example.yaml config/hubstruct.yaml
Keep what you want and delete the rest: every part is optional, and what the file leaves out is set in the app as usual. Then restart the api so it reads the file:
docker compose restart api
docker compose logs --tail 20 api
The log says what it changed (config file applied). Without a hubstruct.yaml there's nothing to apply, and the app is set up in the app.
To keep the file somewhere else, set CONFIG_DIR in .env to its folder.
Secrets
${NAME} anywhere in a value is replaced by the environment variable NAME, so a password or an API key needn't be in the file itself. Put them in config/secrets.env, beside it:
HUBSTRUCT_OWNER_PASSWORD=a long password
HUBSTRUCT_BACKUP_KEY=hs_…
Both hubstruct.yaml and secrets.env are left out of git by the repository's .gitignore.
When it's applied
Every time the api starts. Each thing it names is matched to what's already there by name (any case), and made, or changed to match the file, only if it isn't already. So applying the same file again changes nothing, and a change you made in the app before the file named it is put back.
What the file doesn't name is left alone. Taking a tag out of the file doesn't delete it: it stays in the library, and can be changed in the app again.
If the file is wrong (a misspelt key, a value out of range, an environment variable that isn't set), the api doesn't start, and its log lists each problem by where it is in the file:
the config file can't be applied
settings.nsfw: Unrecognized key: "enabeld"
Fix it and start it again.
What it can set
Settings
settings:
steps:
tagging: { workers: 3 }
description: { workers: 2, paused: true }
visionModel: gemma4:e4b
nsfw: { enabled: true, blur: true, threshold: 0.6 }
steps sets each processing step's pool: how many it works on at once (1 to 10), and whether it's paused. The steps are metadata, renditions, analysis, visual, duplicates, tagging, nsfw, text, faces, description, title and embedding. Only what you name is locked: a step the file doesn't mention can still be paused in the app.
Google sign-in
signIn:
google:
clientIds: [1234-abcd.apps.googleusercontent.com]
signup: domain
domains: [example.com]
The same as Settings → Sign-in (Users and sign-in). clientIds are the OAuth client IDs of the apps whose Google sign-ins are taken: the app's own (its GOOGLE_CLIENT_ID in .env, which holds its secret too), and any other app's. signup is who gets an account by signing in with Google: linked (only accounts that have linked Google), invite (invited emails too), or domain (also anyone at domains). Invites are still sent from the app.
The owner
owner:
username: admin
password: ${HUBSTRUCT_OWNER_PASSWORD}
firstName: Ada
lastName: Lovelace
With no accounts yet, this makes the owner's, and there's no first-run setup. After that the owner's username and password are kept as the file says (a new password signs them out everywhere); their name is theirs to change.
API keys
apiKeys:
- name: Backups
key: ${HUBSTRUCT_BACKUP_KEY}
API keys that act as the owner, with the key itself given rather than made for you, so a script can be set up before the app first starts. A key is hs_ and at least 32 more letters, numbers, - or _:
echo "hs_$(openssl rand -hex 24)"
Libraries, fields, tags and albums
libraries:
- name: Family
fields:
- { name: Event, type: choice, choices: [Wedding, Birthday] }
tags:
- { name: Beach, description: Sand and sea., smart: true, confidence: 0.6 }
albums:
- name: Summer at the beach
rules:
- { tags: [Beach], takenFrom: 2024-06-01, takenTo: 2024-08-31 }
A library that isn't there is made, keeping its files in Hubstruct's own storage. Its name can't be changed in the app, and it can't be removed there.
fields: fields of your own, each anameand atype(text,number,date,boolean,choiceorlink), and achoicefield'schoices. Taking a choice out clears it from the media set to it. A field's type can't be changed by the file: delete the field in the app first (its values go with it).tags: each aname, and optionally adescription, whether it'ssmart(applied by the AI tagger), and theconfidencethe tagger needs (0 to 1). Media are still tagged by hand as usual.albums: each aname, adescription, and itsrules. Leaverulesout to keep them in the app; given, they're set by the file. Media are still added to an album by hand as usual, and its color and cover are still set in the app.
An album rule picks the media that match all of what it says; the album holds what any of its rules picks:
| Key | Matches media |
|---|---|
search | like this text in meaning |
similarity | at least this alike to the search (0 to 1) |
types | of these kinds: image, gif, video |
tags / anyTags | with all of these tags / any of them |
extensions | with these file extensions |
favorites | that are favorites (true) or aren't (false) |
inAlbums / inAnyAlbum | in all of these albums / any of them |
people / allPeople | with any of these people / all of them |
takenFrom / takenTo | taken on or after / on or before this day (YYYY-MM-DD) |
nsfw | flagged NSFW (true) or not (false) |
enabled | false keeps the rule but matches nothing |
Albums and people are named. A person has to be in the library (found and named) before a rule can name them: until then that album's rules wait, and the api's log says so at each start.