Deploy compose: shared DB bind mount, models on NFS

- deploy/compose.yaml: KANAME_DATA_DIR bind mount (SQLite) for web and
  worker, NFSv4 volume for models (worker only), configured via .env
- entrypoint fails fast with a chown hint if /data or /models isn't writable
- .env.example and README document the server storage layout

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Pascal LinxweilerandClaude Opus 5.5 committed 2026-10-05 17:34:44 +02:00
1 parent fbcdcf2e2d
commit e73b019492
5 files changed
+51 -6

No files matched your search

+10
View File
@@ -20,3 +20,13 @@ OIDC_CLIENT_ID=
OIDC_CLIENT_SECRET=
# Optional, comma-separated. If set, only members of these groups (from the `groups` claim) can log in.
OIDC_ALLOWED_GROUPS=
# --- deploy/compose.yaml only -------------------------------------------------
# Image tag to run (default: latest)
KANAME_VERSION=
# Host folder for the SQLite DB, shared by web and worker. Local disk, not NFS. Owner uid 1000.
KANAME_DATA_DIR=./data
WEB_PORT=3000
# NFS export for the models (NFSv4, writable by uid 1000)
NFS_SERVER=truenas.lan
NFS_EXPORT=/mnt/tank/models
+3
View File
@@ -14,6 +14,9 @@ step 1 (Hugging Face downloader) is released as a minor version.
20 lines: the image now has an entrypoint with roles (`web`/`worker`), runs migrations itself
under a file lock (no start-order dependency between the services) and has a built-in
healthcheck.
- Server storage: SQLite on a shared host folder (`KANAME_DATA_DIR`, bind mount for web and worker),
models on an NFSv4 volume (`NFS_SERVER`, `NFS_EXPORT`) mounted only by the worker.
- The container stops with a clear message if `/data` (or `/models` for the worker) isn't writable.
- The app version is shown next to the app name (`APP_VERSION`, set at image build time).
### Changed
+9
View File
@@ -39,9 +39,18 @@ On the server you only need `deploy/compose.yaml` and a filled-in `.env` (from `
one folder; no source code, no Dockerfile:
```bash
mkdir -p data && sudo chown 1000:1000 data # SQLite DB, shared by web and worker (local disk!)
docker compose pull && docker compose up -d
```
Storage layout on the server:
- `KANAME_DATA_DIR` (default `./data`): bind mount for the SQLite DB, mounted by both services.
Must be on local disk (SQLite breaks on NFS) and owned by uid 1000.
- `models`: NFS volume from `NFS_SERVER`/`NFS_EXPORT`, mounted only by the worker. Use NFSv4
(hf needs file locks) and make the dataset writable for uid 1000 (owner 1000, or TrueNAS
*Mapall User/Group*). After changing NFS settings: `docker compose down && docker volume rm kaname_models`.
Pin a version with `KANAME_VERSION=0.4.0` in `.env`; the running version is shown next to the app
name in the header.
+19 -5
View File
@@ -1,20 +1,34 @@
# Server setup: put this file and a filled-in .env (from .env.example) in a folder, then
# mkdir -p data && sudo chown 1000:1000 data
# docker compose pull && docker compose up -d
name: kaname
services:
worker:
image: git.linxweiler.xyz/pascallinxweiler/kaname:${KANAME_VERSION:-latest}
command: worker
env_file: .env
volumes: [data:/data, models:/models]
volumes:
- ${KANAME_DATA_DIR:-./data}:/data
- models:/models
restart: unless-stopped
web:
image: git.linxweiler.xyz/pascallinxweiler/kaname:${KANAME_VERSION:-latest}
env_file: .env
ports: ["3000:3000"]
volumes: [data:/data]
ports: ["${WEB_PORT:-3000}:3000"]
volumes:
- ${KANAME_DATA_DIR:-./data}:/data
restart: unless-stopped
volumes:
data: # SQLite + hf home: keep on local disk
models: # downloaded models (later: NFS from TrueNAS)
# Downloaded models on the NAS (only the worker mounts it). NFSv4 because hf uses file locks;
# "hard" makes writes wait while the NAS is unreachable instead of failing half-written.
# Docker keeps these options once the volume exists: after changing them, run
# `docker compose down && docker volume rm kaname_models` (files on the NAS are not touched).
models:
driver: local
driver_opts:
type: nfs
o: "addr=${NFS_SERVER:?set NFS_SERVER in .env},nfsvers=4.1,rw,hard,noatime"
device: ":${NFS_EXPORT:?set NFS_EXPORT in .env}"
+10 -1
View File
@@ -4,11 +4,20 @@ set -e
role="${1:-web}"
require_writable() {
if ! touch "$1/.write-test" 2>/dev/null; then
echo "ERROR: $1 is not writable by uid $(id -u). On the host: chown -R $(id -u):$(id -g) <folder mounted at $1>" >&2
exit 1
fi
rm -f "$1/.write-test"
}
case "$role" in
web|worker)
echo "$role" > /tmp/kaname-role
require_writable /data
if [ "$role" = worker ]; then require_writable "${MODELS_DIR:-/models}"; fi
# web and worker usually start together; the lock makes sure only one runs the migrations.
mkdir -p /data
flock /data/.migrate.lock node dist/migrate.mjs
;;
esac