diff --git a/.env.example b/.env.example index c446cd6..90f5c6f 100644 --- a/.env.example +++ b/.env.example @@ -1,64 +1,26 @@ -# Kaname settings. Copy to .env next to compose.yaml and fill in the "Required" part; everything -# else has working defaults. Full reference: https://git.linxweiler.xyz/pascallinxweiler/Kaname/wiki/Configuration +# Kaname settings: copy to .env next to compose.yaml and fill in. +# All options: https://git.linxweiler.xyz/pascallinxweiler/Kaname/wiki/Configuration -# --------------------------------------------------------------------------- -# Required -# --------------------------------------------------------------------------- +# Read-only Hugging Face token (needed for gated repos, higher rate limits) +HF_TOKEN= +MAX_CONCURRENT_DOWNLOADS=1 +UPDATE_CHECK_INTERVAL_HOURS=12 -# The address you open Kaname at in the browser (no trailing slash). The OIDC redirect URI to -# register with your provider is /api/auth/callback/pocket-id +# Login. AUTH_URL is the address you open Kaname at; register +# /api/auth/callback/pocket-id as redirect URI with your OIDC provider. +# AUTH_SECRET: any random string (openssl rand -base64 32); empty = generated on first start. +AUTH_SECRET= AUTH_URL=http://localhost:3000 - -# OIDC provider (e.g. Pocket ID): authorization code flow with PKCE OIDC_ISSUER=https://auth.example.com OIDC_CLIENT_ID= OIDC_CLIENT_SECRET= - -# --------------------------------------------------------------------------- -# Recommended -# --------------------------------------------------------------------------- - -# Hugging Face token: read-only is enough. Needed for gated/private repos, recommended anyway -# (higher rate limits). Stays on the server; never sent to the browser or written to logs. -HF_TOKEN= - -# Optional, comma-separated: only members of these groups (`groups` claim) can log in. +# Optional, comma-separated: only these groups may log in OIDC_ALLOWED_GROUPS= -# --------------------------------------------------------------------------- -# Folders, port and image (deploy/compose.yaml) -# --------------------------------------------------------------------------- - -# SQLite database and benchmark results. Must be on local disk, not NFS. -KANAME_DATA_DIR=./data -# Downloaded models. Can be a NAS share mounted on the host, e.g. /mnt/nas/models. -KANAME_MODELS_DIR=./models -# Host port of the web UI -WEB_PORT=3000 -# The user Kaname runs as (and owns the files it writes). Set these to the owner of your models -# folder, e.g. the uid/gid of a NAS share (`ls -ln /mnt/nas/models`). New, empty folders are set up -# for this user automatically. -PUID=1000 -PGID=1000 -# Image tag, e.g. 0.16.0 (default: latest). KANAME_IMAGE replaces the registry/name if you build or -# mirror the image yourself. -KANAME_VERSION= -KANAME_IMAGE= - -# --------------------------------------------------------------------------- -# Optional -# --------------------------------------------------------------------------- - -# Random secret for session cookies. Empty: generated on first start and kept in the data folder. -AUTH_SECRET= - -# launch80.com publish token (comes with the launch80 Supporter role). Lets you publish a benchmark -# run as a public launch80 page, after a preview and an explicit confirmation. Stays on the server. -L80_TOKEN= - -MAX_CONCURRENT_DOWNLOADS=1 -# How often the worker checks every model on the Hub (still there? newer commit?); 0 disables it -UPDATE_CHECK_INTERVAL_HOURS=12 -# 1 (default): hf downloads over plain HTTP, so progress can be measured from bytes on disk. -# 0: use Xet (chunk-level dedup on updates). Files over 50 GB always use Xet. -HF_HUB_DISABLE_XET=1 +# Optional: pin an image version (default: latest) +# KANAME_VERSION=0.22.0 +# Optional: user/group Kaname runs as (default 1000); set to the owner of your models folder +# PUID=1000 +# PGID=1000 +# Optional: launch80.com publish token, to publish benchmark runs +# L80_TOKEN= diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d6b8d6..8fa15f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,15 @@ step 1 (Hugging Face downloader) is released as a minor version. ## [Unreleased] +**Upgrading:** `deploy/compose.yaml` and `.env.example` are simpler: folders, port and image are +written straight into `compose.yaml` (`./data`, `./models`, `3000`). `KANAME_DATA_DIR`, +`KANAME_MODELS_DIR`, `WEB_PORT` and `KANAME_IMAGE` are gone; if you set them, put those values into +`compose.yaml` instead. `KANAME_VERSION`, `PUID` and `PGID` still work. + +### Changed + +- Simpler `deploy/compose.yaml` (no YAML anchors or variables) and a short `.env.example`. + ## [0.22.0] - 2026-11-11 The API for AI agents is back, for models: a token-authenticated `/api/v1` lets an agent look up diff --git a/README.md b/README.md index 7dee581..a6f5b96 100644 --- a/README.md +++ b/README.md @@ -42,9 +42,21 @@ curl -fsSLo .env https://git.linxweiler.xyz/pascallinxweiler/Kaname/raw/branch/m restrict access by group. **3. Fill in `.env`:** `AUTH_URL` (the address you open in the browser), `OIDC_ISSUER`, -`OIDC_CLIENT_ID`, `OIDC_CLIENT_SECRET`, and ideally a read-only `HF_TOKEN`. Everything else has -defaults. Models go to `./models` and the database to `./data` next to the compose file; point -`KANAME_MODELS_DIR` at another folder (e.g. a NAS share mounted on the host) if you like. +`OIDC_CLIENT_ID`, `OIDC_CLIENT_SECRET`, and ideally a read-only `HF_TOKEN`. That's all; the rest +has defaults: + +```env +HF_TOKEN=hf_... +AUTH_URL=http://192.168.1.10:3000 +OIDC_ISSUER=https://auth.example.com +OIDC_CLIENT_ID=... +OIDC_CLIENT_SECRET=... +OIDC_ALLOWED_GROUPS=admin +``` + +The database goes to `./data` and models to `./models` next to the compose file. To keep models +somewhere else (e.g. a NAS share mounted on the host), change the worker's `./models:/models` line +in `compose.yaml`, e.g. to `/mnt/models:/models`. The port is the `"3000:3000"` line. **4. Start** @@ -56,11 +68,11 @@ Open your `AUTH_URL`, sign in, click **Add model**. That's it. Kaname creates and takes over `./data` itself, and an empty models folder too. It runs as uid/gid 1000 by default; if your models folder already holds files that belong to another user (common for -NAS shares), set `PUID`/`PGID` in `.env` to that owner (`ls -ln /path/to/models`). Kaname never +NAS shares), add `PUID`/`PGID` to `.env` for that owner (`ls -ln /path/to/models`). Kaname never changes the ownership of a models folder that has files in it. **Updating:** `docker compose pull && docker compose up -d`. To stay on a version, set e.g. -`KANAME_VERSION=0.16.0` in `.env`. The running version is shown next to the app name. Read the +`KANAME_VERSION=0.22.0` in `.env`. The running version is shown next to the app name. Read the [changelog](CHANGELOG.md) before jumping minor versions: it says when the compose file changed. ### The image @@ -70,8 +82,8 @@ changes the ownership of a models folder that has files in it. | Tag | What it is | | --- | --- | | `latest` | the newest release | -| `0.16` | the newest 0.16.x release | -| `0.16.0` | exactly that release | +| `0.22` | the newest 0.22.x release | +| `0.22.0` | exactly that release | It is built for x86-64 (`linux/amd64`). One image serves all three services (`web`, `worker`, `sandbox`); the compose file picks the role. To build it yourself (e.g. for ARM) from this @@ -82,7 +94,7 @@ git clone https://git.linxweiler.xyz/pascallinxweiler/Kaname.git && cd Kaname docker build -t kaname:mine --build-arg APP_VERSION=$(git describe --tags) . ``` -and set `KANAME_IMAGE=kaname` and `KANAME_VERSION=mine` in `.env`. +and change the three `image:` lines in `compose.yaml` to `kaname:mine`. ## Configuration diff --git a/compose.yaml b/compose.yaml index 5830bc4..d5c32e3 100644 --- a/compose.yaml +++ b/compose.yaml @@ -1,50 +1,51 @@ # Builds the image from this checkout. For the server use deploy/compose.yaml (released image). name: kaname -x-app: &app - image: kaname:local - build: . - env_file: .env - # Container paths win over local-dev paths in .env. - environment: - DATABASE_URL: file:/data/app.db - MODELS_DIR: /models - HF_HOME: /data/hf-home - restart: unless-stopped - services: + web: + build: . + image: kaname:local + env_file: .env + environment: + DATABASE_URL: file:/data/app.db # container paths win over local-dev paths in .env + MODELS_DIR: /models + ports: + - "3000:3000" + volumes: + - data:/data + restart: unless-stopped + worker: - <<: *app + image: kaname:local command: worker + env_file: .env environment: DATABASE_URL: file:/data/app.db MODELS_DIR: /models - HF_HOME: /data/hf-home SANDBOX_DIR: /sandbox - volumes: [data:/data, models:/models, sandbox:/sandbox] + volumes: + - data:/data + - models:/models + - sandbox:/sandbox + depends_on: [web] + restart: unless-stopped - web: - <<: *app - ports: ["${WEB_PORT:-3000}:3000"] - volumes: [data:/data] - - # Runs the quality eval's coding answers (Python written by the model under test) with no - # network, a read-only root, no capabilities, small limits and an unprivileged user. It shares only - # the exchange folder with the worker. Optional: without it the quality eval skips coding. sandbox: image: kaname:local command: sandbox user: "65534:65534" - depends_on: [worker] network_mode: none read_only: true - tmpfs: ["/tmp:size=64m,mode=1777"] + tmpfs: + - /tmp:size=64m,mode=1777 cap_drop: [ALL] security_opt: ["no-new-privileges:true"] mem_limit: 512m pids_limit: 64 cpus: 1 - volumes: [sandbox:/sandbox] + volumes: + - sandbox:/sandbox + depends_on: [worker] restart: unless-stopped volumes: diff --git a/deploy/compose.yaml b/deploy/compose.yaml index 4edda9f..9fbf44b 100644 --- a/deploy/compose.yaml +++ b/deploy/compose.yaml @@ -1,49 +1,48 @@ # Kaname: put this file and a filled-in .env (from .env.example) in one folder, then # docker compose up -d -# The data and models folders are created next to this file unless .env points elsewhere. name: kaname -x-kaname: &kaname - # Public image, no login needed. Pin a version with KANAME_VERSION=0.15.2 in .env. - image: ${KANAME_IMAGE:-git.linxweiler.xyz/pascallinxweiler/kaname}:${KANAME_VERSION:-latest} - restart: unless-stopped - services: web: - <<: *kaname + image: git.linxweiler.xyz/pascallinxweiler/kaname:${KANAME_VERSION:-latest} env_file: .env - ports: ["${WEB_PORT:-3000}:3000"] + ports: + - "3000:3000" volumes: - - ${KANAME_DATA_DIR:-./data}:/data # SQLite database and results, shared with the worker (local disk, not NFS) + - ./data:/data + restart: unless-stopped worker: - <<: *kaname + image: git.linxweiler.xyz/pascallinxweiler/kaname:${KANAME_VERSION:-latest} command: worker env_file: .env environment: SANDBOX_DIR: /sandbox volumes: - - ${KANAME_DATA_DIR:-./data}:/data - - ${KANAME_MODELS_DIR:-./models}:/models # downloaded models (a NAS share mounted on the host works) - - sandbox:/sandbox # exchange folder with the code sandbox + - ./data:/data + - ./models:/models # where models are downloaded to, e.g. /mnt/models + - sandbox:/sandbox + restart: unless-stopped - # Runs the quality eval's coding answers (Python written by the model under test): no network, a - # read-only root, no capabilities, small limits, an unprivileged user, and only the exchange - # folder shared with the worker. No .env (no secrets). Optional: without it the eval skips coding. + # Runs the coding answers of the quality eval (Python written by the model under test), locked + # down: no network, no secrets, read-only. Optional: without it the eval skips the coding part. sandbox: - <<: *kaname + image: git.linxweiler.xyz/pascallinxweiler/kaname:${KANAME_VERSION:-latest} command: sandbox user: "65534:65534" - depends_on: [worker] network_mode: none read_only: true - tmpfs: ["/tmp:size=64m,mode=1777"] + tmpfs: + - /tmp:size=64m,mode=1777 cap_drop: [ALL] security_opt: ["no-new-privileges:true"] mem_limit: 512m pids_limit: 64 cpus: 1 - volumes: [sandbox:/sandbox] + volumes: + - sandbox:/sandbox + depends_on: [worker] + restart: unless-stopped volumes: sandbox: