commit 524eb712dee154e3084aa2f505cb231559962b44 Author: Pascal Linxweiler Date: Mon Oct 5 19:53:08 2026 +0200 Add Home, Configuration and NAS pages diff --git a/Configuration.md b/Configuration.md new file mode 100644 index 0000000..68266d0 --- /dev/null +++ b/Configuration.md @@ -0,0 +1,121 @@ +# Configuration + +Kaname is configured entirely through environment variables. With the provided +[`compose.yaml`](https://git.linxweiler.xyz/pascallinxweiler/Kaname/src/branch/main/deploy/compose.yaml) +they all go into the `.env` file next to it; start from +[`.env.example`](https://git.linxweiler.xyz/pascallinxweiler/Kaname/src/branch/main/.env.example). + +After changing `.env`, apply it with `docker compose up -d` (the containers are recreated). + +- [Login (OIDC)](#login-oidc) +- [Hugging Face](#hugging-face) +- [Folders and ports (Docker host)](#folders-and-ports-docker-host) +- [Downloads](#downloads) +- [Advanced](#advanced) + +## Login (OIDC) + +Kaname has no local accounts. Everyone signs in through your OIDC provider (tested with +[Pocket ID](https://pocket-id.org)) using the authorization code flow with PKCE. + +| Variable | Required | Default | Description | +| --- | --- | --- | --- | +| `AUTH_URL` | yes | | The URL you open Kaname at, e.g. `http://192.168.1.10:3000` or `https://models.example.com`. Used to build the OIDC redirect URI. | +| `AUTH_SECRET` | yes | | Random secret that encrypts the session cookie. Generate one with `openssl rand -base64 33`. Changing it signs everyone out. | +| `OIDC_ISSUER` | yes | | Issuer URL of your provider, e.g. `https://auth.example.com`. Kaname reads `/.well-known/openid-configuration` from it. | +| `OIDC_CLIENT_ID` | yes | | Client ID of the OIDC client you created for Kaname. | +| `OIDC_CLIENT_SECRET` | yes | | Client secret of that client. | +| `OIDC_ALLOWED_GROUPS` | no | *(everyone who can log in)* | Comma-separated group names, e.g. `admin,llm`. If set, Kaname requests the `groups` scope and only lets users in who are in at least one of these groups. Users without a `groups` claim are rejected. | + +**Setting up the OIDC client** (e.g. in Pocket ID): + +- Callback / redirect URI: `/api/auth/callback/pocket-id`, for example + `https://models.example.com/api/auth/callback/pocket-id`. It must match `AUTH_URL` exactly, + including `http`/`https` and the port. +- PKCE: enabled. +- For `OIDC_ALLOWED_GROUPS`, the provider must put a `groups` claim into the ID token (Pocket ID + does this for the `groups` scope). + +Sessions last 7 days. Group membership is checked when you sign in, so removing someone from a +group takes effect on their next login. + +## Hugging Face + +| Variable | Required | Default | Description | +| --- | --- | --- | --- | +| `HF_TOKEN` | recommended | | Hugging Face access token. Needed for gated and private repos; for public repos it gives you higher rate limits. | + +**Which token?** Read access is all Kaname needs. Best is a *fine-grained* token with: + +- *Read access to contents of all public gated repos you can access* (for models like Llama or Gemma) +- *Read access to contents of all repos under your personal namespace* (only for your own private repos) + +For gated models you also have to accept the terms on the model's Hugging Face page with the same +account. The token stays on the server: it is passed to the `hf` CLI through its environment, never +on the command line, and is never sent to the browser or written to logs. + +## Folders and ports (Docker host) + +These are read by `compose.yaml` on the Docker host, not by the app itself. + +| Variable | Default | Description | +| --- | --- | --- | +| `KANAME_DATA_DIR` | `./data` | Folder for the SQLite database, shared by the `web` and `worker` containers. **Must be on local disk**: SQLite does not work reliably over NFS/SMB. | +| `KANAME_MODELS_DIR` | `./models` | Folder where models are downloaded to, as `//…`. Can be a NAS share mounted on the host, see [[Storing models on a NAS]]. | +| `WEB_PORT` | `3000` | Port on the host where the web UI is published. | +| `KANAME_VERSION` | `latest` | Image tag to run, e.g. `0.4.0`. Pin it if you only want to update deliberately. | + +Both folders must be writable by uid/gid **1000** (the user inside the container): + +```bash +sudo chown 1000:1000 data models +``` + +If one isn't, the container stops at startup with a message telling you which folder. + +## Downloads + +| Variable | Default | Description | +| --- | --- | --- | +| `MAX_CONCURRENT_DOWNLOADS` | `1` | How many downloads run at the same time. Further downloads wait in the queue. Two downloads of the same model never run in parallel. | +| `HF_HUB_DISABLE_XET` | `1` | `1`: the `hf` CLI downloads over plain HTTP, which lets Kaname show accurate progress, speed and ETA. `0`: use Hugging Face's Xet transfer protocol (can download only changed chunks when a model is updated), but the progress bar then only moves in large jumps. | +| `UPDATE_CHECK_INTERVAL_HOURS` | `12` | How often to check the Hub for newer commits of your models; `0` disables it. *(Update checks are not released yet; the setting is reserved.)* | + +Notes: + +- Before a download starts, Kaname checks that enough space is free in the models folder. +- If a download is interrupted, the `hf` CLI restarts unfinished files from the beginning (it can't + resume partial files); finished files are kept. + +## Advanced + +You normally don't set these: the image's defaults match the paths in `compose.yaml`. + +| Variable | Default (in the image) | Description | +| --- | --- | --- | +| `DATABASE_URL` | `file:/data/app.db` | SQLite database location *inside the container*. A relative path like `file:./data/app.db` puts the database inside the container, where it is lost on recreate and not shared between web and worker. | +| `MODELS_DIR` | `/models` | Models folder *inside the container* (mount your host folder there instead of changing this). | +| `HF_HOME` | `/data/hf-home` | Home directory of the `hf` CLI (logs and caches; no models). | +| `HF_ENDPOINT` | `https://huggingface.co` | Alternative Hub endpoint (e.g. a mirror); passed to the `hf` CLI. Metadata lookups still use huggingface.co. | +| `HTTP_PROXY`, `HTTPS_PROXY`, `NO_PROXY` | | Proxy settings, passed to the `hf` CLI. | +| `PORT` | `3000` | Port the web server listens on inside the container. | + +## Example + +```bash +AUTH_URL=https://models.example.com +AUTH_SECRET=change-me-openssl-rand-base64-33 +OIDC_ISSUER=https://auth.example.com +OIDC_CLIENT_ID=0b5e… +OIDC_CLIENT_SECRET=… +OIDC_ALLOWED_GROUPS=admin + +HF_TOKEN=hf_… + +KANAME_DATA_DIR=./data +KANAME_MODELS_DIR=/mnt/nas/models +WEB_PORT=3000 +KANAME_VERSION=0.4.0 + +MAX_CONCURRENT_DOWNLOADS=2 +``` diff --git a/Home.md b/Home.md new file mode 100644 index 0000000..e808465 --- /dev/null +++ b/Home.md @@ -0,0 +1,9 @@ +# Kaname wiki + +Kaname is a self-hosted web app for downloading and managing local LLMs from Hugging Face. +Installation is described in the [README](https://git.linxweiler.xyz/pascallinxweiler/Kaname). + +## Pages + +- [[Configuration]]: every setting in `.env`, with defaults and examples +- [[Storing models on a NAS]]: keep models on an NFS share (e.g. TrueNAS) diff --git a/Storing-models-on-a-NAS.md b/Storing-models-on-a-NAS.md new file mode 100644 index 0000000..516f5e9 --- /dev/null +++ b/Storing-models-on-a-NAS.md @@ -0,0 +1,48 @@ +# Storing models on a NAS + +Models can live on a NAS (e.g. TrueNAS) while Kaname runs on another machine. Mount the share on +the Docker host and point `KANAME_MODELS_DIR` at the mount. + +## 1. Mount the share on the Docker host + +Add a line to `/etc/fstab` (adjust host, export and mount point): + +``` +truenas.lan:/mnt/tank/models /mnt/nas/models nfs4 rw,hard,noatime,_netdev 0 0 +``` + +Then mount it: + +```bash +sudo mkdir -p /mnt/nas/models +sudo systemctl daemon-reload +sudo mount -a -v +findmnt /mnt/nas/models # should show your NAS and type nfs4 +``` + +## 2. Point Kaname at it + +```bash +# .env +KANAME_MODELS_DIR=/mnt/nas/models +``` + +```bash +docker compose up -d --force-recreate worker +docker compose exec worker ls -la /models # should list the share's contents +``` + +## Requirements + +- **NFSv4.** The `hf` CLI uses file locks, which aren't reliable with NFSv3 or `nolock`. +- **Writable for uid 1000.** The container runs as uid/gid 1000. On TrueNAS either make 1000 the + owner of the dataset or set *Mapall User/Group* on the NFS share to a user with uid 1000. +- **Mounted before Docker starts.** `_netdev` makes the mount wait for the network. If the share + isn't mounted when the worker starts, Docker uses the empty local folder and models end up on the + host's disk. After mounting later, recreate the worker (`docker compose up -d --force-recreate worker`). +- **`hard` mount.** If the NAS is unreachable, downloads wait instead of writing broken files. + +## What not to put on the NAS + +Keep `KANAME_DATA_DIR` (the SQLite database) on the Docker host's local disk. SQLite relies on file +locking and shared memory that don't work reliably over NFS or SMB. diff --git a/_Sidebar.md b/_Sidebar.md new file mode 100644 index 0000000..7197105 --- /dev/null +++ b/_Sidebar.md @@ -0,0 +1,4 @@ +- [[Home]] +- [[Configuration]] +- [[Storing models on a NAS]] +- [README / Install](https://git.linxweiler.xyz/pascallinxweiler/Kaname)