Archilyzer · Source

archilyzer

Archilyzer
git clone https://archilyzer.pages.dev/source/archilyzer.git
Log | Files | Refs | README | LICENSE

commit ec99f6aa6262acf968a3f5e0d4938ce67ce755f5
parent 7cfcbbabf88986f5b143d903ece057fc67abe028
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Fri, 16 Oct 2026 17:21:20 -0400

docker: every feature in the image — a runtime-umtool target (trixie: ImageMagick 7 with Pango, rsvg-convert, qrencode, zbarimg, chromium, the pinned hyperframes and its headless shell) that the umtool service runs; gallery-dl (pinned), Playwright's headless Chromium and espeak-ng in every editor target; an ollama profile (GPU through the vulkan/gpu overlays); a reports volume; TTS installs, their cache and the generation ledger kept in volumes; overlays for the Claude API key file (a read-only mount, never env) and the host's Firefox cookies; node-datachannel's prebuilt fetched before the install (prebuild-install gave up and the source build failed it)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Diffstat:
M.env.example | 17+++++++++++++++++
M.gitignore | 3+++
MDockerfile | 145+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----
Mcommon/lib/envVars.ts | 3+++
Mcommon/publish/buildImage.test.ts | 42+++++++++++++++++++++++++++++++++++++++++-
Adocker-compose.anthropic.yml | 39+++++++++++++++++++++++++++++++++++++++
Adocker-compose.browser.yml | 45+++++++++++++++++++++++++++++++++++++++++++++
Mdocker-compose.gpu.yml | 19+++++++++++++------
Mdocker-compose.vulkan.yml | 21+++++++++++++--------
Mdocker-compose.yml | 56++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mdocker/entrypoint.sh | 7++++++-
11 files changed, 375 insertions(+), 22 deletions(-)

diff --git a/.env.example b/.env.example @@ -167,6 +167,23 @@ #PARAKEET_DEVICE=Vulkan0 # --------------------------------------------------------------------------- +# Local models, the Claude API, browser cookies +# --------------------------------------------------------------------------- +# The digest lanes and generation routed to "local" ask an ollama. Default: the +# `ollama` service (`--profile ollama`), pinned by OLLAMA_TAG. A host's own: +#OLLAMA_URL=http://host.docker.internal:11434 +#OLLAMA_TAG=0.40.5 +# +# The Claude API key file the anthropic overlay mounts (docker-compose.anthropic.yml; +# `archilyzer service install` adds it when the file exists). Never put the key +# itself in this file. +#ARCHILYZER_ANTHROPIC_ENV_FILE=/home/you/.config/archilyzer/anthropic.env +# +# The Firefox profiles the browser overlay mounts read-only, for +# cookiesFromBrowser = firefox:/data/browser/firefox (docker-compose.browser.yml). +#ARCHILYZER_FIREFOX_PROFILES=/home/you/.mozilla/firefox + +# --------------------------------------------------------------------------- # Image # --------------------------------------------------------------------------- #ARCHILYZER_TAG=local diff --git a/.gitignore b/.gitignore @@ -211,3 +211,6 @@ umtool/.next/ # Cost an e2e run's worth of confusing red to find. umtool/.next-*/ umtool/test-results/ + +# `archilyzer service storage-overlay` writes it for THIS machine's drives. +/docker-compose.storage.yml diff --git a/Dockerfile b/Dockerfile @@ -7,8 +7,10 @@ # Dockerfile.test — the sharded playwright e2e route. # Both keep working exactly as they did; nothing here touches them. # -# Three published targets, all built from the same app code: +# Four published targets, all built from the same app code: # runtime CPU whisper.cpp. The default. (docker-compose.yml) +# runtime-umtool umtool + the report → video toolchain (ImageMagick 7 with +# Pango, chromium, hyperframes). (docker-compose.yml, umtool) # runtime-vulkan parakeet.cpp on Vulkan. Any GPU with a Vulkan driver — # AMD/RADV, Intel, NVIDIA. (docker-compose.vulkan.yml) # runtime-cuda whisper.cpp on CUDA. NVIDIA only. (docker-compose.gpu.yml) @@ -260,6 +262,27 @@ COPY mcp/package.json mcp/package.json COPY umtool/report-to-video/package.json umtool/report-to-video/package.json COPY umtool/package.json umtool/package.json +# node-datachannel (the seeder's WebRTC, release 21) installs a PREBUILT binary +# from its GitHub release through prebuild-install, which gives up within +# seconds on a slow asset download (measured: ~11 s for its 3.4 MB from a build +# container) and then falls back to compiling it from source, which fails — +# and with it the whole install. So fetch it first, with no such deadline (node: +# the slim base has no curl), into the cache prebuild-install looks in +# (~/.npm/_prebuilds/<sha512(url)[:6]>-<file>). +# The version is the lockfile's; buildImage.test.ts holds the two equal. +ARG NODE_DATACHANNEL_VERSION=0.32.3 +ARG TARGETARCH=amd64 +RUN set -eux; \ + case "${TARGETARCH}" in amd64) arch=x64 ;; arm64) arch=arm64 ;; *) arch="${TARGETARCH}" ;; esac; \ + v="${NODE_DATACHANNEL_VERSION}"; \ + file="node-datachannel-v${v}-napi-v8-linux-${arch}.tar.gz"; \ + url="https://github.com/murat-dogan/node-datachannel/releases/download/v${v}/${file}"; \ + digest="$(node -e 'process.stdout.write(require("crypto").createHash("sha512").update(process.argv[1]).digest("hex").slice(0,6))' "${url}")"; \ + mkdir -p /root/.npm/_prebuilds; \ + node -e 'const [u, f] = process.argv.slice(1); (async () => { for (let i = 1; i <= 3; i++) { try { const r = await fetch(u); if (!r.ok) throw new Error(`HTTP ${r.status}`); require("fs").writeFileSync(f, Buffer.from(await r.arrayBuffer())); return; } catch (e) { console.error(`attempt ${i}: ${e.message}`); await new Promise((d) => setTimeout(d, 2000 * i)); } } process.exit(1); })()' \ + "${url}" "/root/.npm/_prebuilds/${digest}-${file}"; \ + ls -l /root/.npm/_prebuilds + # `allowBuilds` / `onlyBuiltDependencies` in pnpm-workspace.yaml rebuild the # native modules (lmdb, msgpackr-extract, esbuild) for THIS image's arch. RUN pnpm install --frozen-lockfile @@ -316,12 +339,16 @@ FROM ${RUNTIME_IMAGE} AS runtime-base # binary with its own python — for /usr/local/bin/yt-dlp-from-source, which # runs a yt-dlp SOURCE tree mounted at run time (docker-compose.ytdlp.yml). # pipx (+ python3-venv, which it needs to make a venv): installs git-filter-repo -# below, which the homepage's source mirror runs. +# and gallery-dl below. python3-venv is also what `archilyzer tts setup +# --engine kokoro` makes the Kokoro venv with (no uv in the image). +# espeak-ng: the zero-install text-to-speech engine (common/lib/ttsApps.ts), and +# a voice that works with no model download at all. RUN apt-get update \ && apt-get install -y --no-install-recommends \ ffmpeg aria2 zip unzip tar xz-utils gzip rsync curl ca-certificates git procps \ python3 python3-venv pipx python3-certifi python3-brotli python3-websockets \ python3-mutagen python3-pycryptodome python3-requests \ + espeak-ng \ && rm -rf /var/lib/apt/lists/* # git-filter-repo, PINNED, for `archilyzer source publish` (the homepage's @@ -333,6 +360,14 @@ RUN apt-get update \ RUN PIPX_HOME=/opt/pipx PIPX_BIN_DIR=/usr/local/bin pipx install git-filter-repo==2.47.0 \ && git filter-repo --version +# gallery-dl, PINNED: the X/Twitter post fetcher (fetch-posts, capture-posts, +# the X channels). GALLERY_DL_BIN below names it. A pin, not "latest": a +# gallery-dl that changes its output shape changes what the fetcher parses, and +# that should arrive with a rebuild you chose. common/publish/buildImage.test.ts +# holds every target to the same pin (GALLERY_DL_PIPX_SPEC). +RUN PIPX_HOME=/opt/pipx PIPX_BIN_DIR=/usr/local/bin pipx install gallery-dl==1.32.9 \ + && gallery-dl --version + # yt-dlp as the standalone release binary (it bundles its own python), installed # writable so `yt-dlp -U` works — see YTDLP_AUTO_UPDATE in docker/entrypoint.sh. # A pinned yt-dlp goes stale fast, and a stale yt-dlp is the single most common @@ -386,6 +421,19 @@ COPY --from=build /repo /repo # docker-compose.ytdlp.yml. RUN ln -s /repo/docker/yt-dlp-from-source.sh /usr/local/bin/yt-dlp-from-source +# Playwright's headless Chromium, at the version the workspace pins +# (@playwright/test → playwright-core), and the system libraries it needs +# (--with-deps: apt, per distro — bookworm, trixie and ubuntu 24.04 alike). The +# editor launches it headless for the report PDF/print exports, Bluesky post +# capture, the Nitter and Playwright X fetchers and forum (XenForo) sessions; +# umtool's shoot-page.mjs for post screenshots. A fixed path, so every process +# finds it whatever its HOME. Headed launches ("Connect X account") need a +# display, which a container has not — RUNNING_IN_DOCKER.md, the feature matrix. +ENV PLAYWRIGHT_BROWSERS_PATH=/opt/ms-playwright +RUN cd /repo/editor \ + && ./node_modules/.bin/playwright install --with-deps --only-shell chromium \ + && rm -rf /var/lib/apt/lists/* + # Data lives in volumes, never in the image. See docker-compose.yml. # YTDLP_BIN is the one the app runs; ARCHILYZER_IMAGE_YTDLP is the one this # image ships, so the entrypoint and `archilyzer doctor` can say "override". @@ -397,8 +445,20 @@ ENV NODE_ENV=production \ ARCHILYZER_IMAGE_YTDLP=/usr/local/bin/yt-dlp \ EXPORT_INDEX_DIR=/data/builds/.export-index \ EXPORT_BUILDS_DIR=/data/builds/.export-builds \ - ARCHILYZER_SITE_OUT=/data/builds/site -RUN mkdir -p /data/transcripts /data/config /data/models /data/builds + ARCHILYZER_SITE_OUT=/data/builds/site \ + GALLERY_DL_BIN=/usr/local/bin/gallery-dl \ + REPORTS_DIR=/data/reports +RUN mkdir -p /data/transcripts /data/config /data/models /data/builds /data/reports +# Three things paths.ts keeps beside the checkout or in $HOME, which is the +# container's writable layer and gone on every recreate: the text-to-speech +# engines (~/.local/share/archilyzer/tts), their synthesis cache (/repo/.tts) +# and the generation ledger the daily caps count (/repo/.generation). Linked into +# the volumes, so a Kokoro installed once (`archilyzer tts setup`) and today's +# spend both survive `docker compose up`. +RUN mkdir -p /root/.local/share/archilyzer \ + && ln -s /data/models/tts /root/.local/share/archilyzer/tts \ + && rm -rf /repo/.tts && ln -s /data/builds/tts /repo/.tts \ + && rm -rf /repo/.generation && ln -s /data/config/generation /repo/.generation ENTRYPOINT ["/repo/docker/entrypoint.sh"] CMD ["editor"] @@ -422,6 +482,65 @@ ENV ARCHILYZER_COMMIT=${ARCHILYZER_COMMIT} \ ARCHILYZER_BRANCH=${ARCHILYZER_BRANCH} # --------------------------------------------------------------------------- +# runtime-umtool — umtool with everything report → video needs. The `umtool` +# service (docker-compose.yml) runs this target; the editor's image stays lean. +# +# Built on TRIXIE (compose passes RUNTIME_IMAGE=node:22-trixie-slim for it, as +# the Vulkan overlay does for the editor): the renderer calls ImageMagick 7's +# `magick`, and bookworm ships ImageMagick 6 (`convert`, no `magick`). The +# workspace is still built on bookworm — glibc only goes forward (top of file). +# +# What a render shells out to, and why each is here: +# magick + the "extra" coders cards, the timeline, every `pango:` text +# render (the Pango coder is in +# libmagickcore-…-extra, a Recommends that +# --no-install-recommends would drop) +# rsvg-convert (librsvg2-bin) the brand preset's SVG cards +# qrencode / zbarimg the QR codes, and their verification +# chromium compose-chrome's review still (CHROME) +# hyperframes + its headless the chrome frames (deck, posts, teaser): +# shell HYPERFRAMES_BIN, so a render never runs +# `npx --yes` against the registry +# Playwright's headless shell shoot-page.mjs (post screenshots) — +# installed in runtime-base, the editor +# uses it too +# fonts DejaVu as the fallback face, Noto emoji; +# the preset's own faces are vendored in +# report-to-video/fonts (FONTCONFIG_FILE) +# Fira Sans (the unbranded cards' face) is not packaged by Debian; an +# unbranded card falls back to DejaVu Sans here. The Archilyzer Media preset is +# unaffected — its faces ship in the repo. +# --------------------------------------------------------------------------- +FROM runtime-base AS runtime-umtool +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + imagemagick libmagickcore-7.q16-10-extra librsvg2-bin qrencode zbar-tools \ + chromium fontconfig fonts-dejavu-core fonts-noto-color-emoji \ + && rm -rf /var/lib/apt/lists/* +# Fail the build, not the first render, when the Pango coder is missing. +RUN set -eux; \ + magick -version | head -n 1; \ + magick -list format | grep -qi 'pango' || { echo "FATAL: ImageMagick has no Pango coder" >&2; exit 1; }; \ + rsvg-convert --version; qrencode --version 2>&1 | head -n 1; zbarimg --version; \ + chromium --version +# The hyperframes CLI, PINNED to the version deck.mjs names +# (HYPERFRAMES_PKG_DEFAULT; the drift test holds the two equal), and the +# chrome-headless-shell it renders with, fetched once here into root's cache. +ARG HYPERFRAMES_VERSION=0.8.24 +RUN set -eux; \ + npm install -g "hyperframes@${HYPERFRAMES_VERSION}"; \ + hyperframes --version; \ + hyperframes browser ensure +ENV HYPERFRAMES_BIN=/usr/local/bin/hyperframes \ + CHROME=/usr/bin/chromium +CMD ["umtool"] + +ARG ARCHILYZER_COMMIT= +ARG ARCHILYZER_BRANCH= +ENV ARCHILYZER_COMMIT=${ARCHILYZER_COMMIT} \ + ARCHILYZER_BRANCH=${ARCHILYZER_BRANCH} + +# --------------------------------------------------------------------------- # runtime-vulkan — parakeet.cpp on any Vulkan GPU. docker-compose.vulkan.yml. # # Ships whisper-cli too: the GPU is for parakeet, but a CPU whisper worker is a @@ -471,11 +590,14 @@ RUN apt-get update \ ffmpeg aria2 zip unzip tar xz-utils gzip rsync curl ca-certificates git gnupg procps \ python3 python3-venv pipx python3-certifi python3-brotli python3-websockets \ python3-mutagen python3-pycryptodome python3-requests \ + espeak-ng \ && curl -fsSL "https://deb.nodesource.com/setup_${NODE_MAJOR}.x" | bash - \ && apt-get install -y --no-install-recommends nodejs \ && rm -rf /var/lib/apt/lists/* RUN PIPX_HOME=/opt/pipx PIPX_BIN_DIR=/usr/local/bin pipx install git-filter-repo==2.47.0 \ && git filter-repo --version +RUN PIPX_HOME=/opt/pipx PIPX_BIN_DIR=/usr/local/bin pipx install gallery-dl==1.32.9 \ + && gallery-dl --version ARG TARGETARCH=amd64 RUN set -eux; \ @@ -521,6 +643,11 @@ RUN ldconfig WORKDIR /repo COPY --from=build /repo /repo RUN ln -s /repo/docker/yt-dlp-from-source.sh /usr/local/bin/yt-dlp-from-source +# Playwright's headless Chromium, as in runtime-base (read its comment). +ENV PLAYWRIGHT_BROWSERS_PATH=/opt/ms-playwright +RUN cd /repo/editor \ + && ./node_modules/.bin/playwright install --with-deps --only-shell chromium \ + && rm -rf /var/lib/apt/lists/* ENV NODE_ENV=production \ NEXT_TELEMETRY_DISABLED=1 \ @@ -533,8 +660,14 @@ ENV NODE_ENV=production \ ARCHILYZER_IMAGE_YTDLP=/usr/local/bin/yt-dlp \ EXPORT_INDEX_DIR=/data/builds/.export-index \ EXPORT_BUILDS_DIR=/data/builds/.export-builds \ - ARCHILYZER_SITE_OUT=/data/builds/site -RUN mkdir -p /data/transcripts /data/config /data/models /data/builds + ARCHILYZER_SITE_OUT=/data/builds/site \ + GALLERY_DL_BIN=/usr/local/bin/gallery-dl \ + REPORTS_DIR=/data/reports +RUN mkdir -p /data/transcripts /data/config /data/models /data/builds /data/reports +RUN mkdir -p /root/.local/share/archilyzer \ + && ln -s /data/models/tts /root/.local/share/archilyzer/tts \ + && rm -rf /repo/.tts && ln -s /data/builds/tts /repo/.tts \ + && rm -rf /repo/.generation && ln -s /data/config/generation /repo/.generation ENTRYPOINT ["/repo/docker/entrypoint.sh"] CMD ["editor"] diff --git a/common/lib/envVars.ts b/common/lib/envVars.ts @@ -188,6 +188,9 @@ const DECLARED: EnvVarDecl[] = [ { name: "ARCHILYZER_FORWARD_AUTH_UPSTREAM", audience: "docker", default: "—", readBy: "docker/Caddyfile", doc: "Forward-auth server (Authelia, tinyauth, …), `host:port`." }, { name: "ARCHILYZER_FORWARD_AUTH_URI", audience: "docker", default: "`/api/auth/caddy`", readBy: "docker/Caddyfile", doc: "The forward-auth server's verify path." }, { name: "ARCHILYZER_TAG", audience: "docker", default: "`local`", readBy: "docker-compose*.yml", doc: "The image tag the compose files build and run." }, + { name: "ARCHILYZER_ANTHROPIC_ENV_FILE", audience: "docker", default: "`~/.config/archilyzer/anthropic.env`", readBy: "docker-compose.anthropic.yml, common/bin/service.ts", doc: "The host's Claude API key file (one line `ANTHROPIC_API_KEY=…`, mode 600), bind-mounted read-only into the editor and umtool by the anthropic overlay; `archilyzer service install` adds that overlay when the file exists (it never opens it)." }, + { name: "ARCHILYZER_FIREFOX_PROFILES", audience: "docker", default: "`~/.mozilla/firefox`", readBy: "docker-compose.browser.yml", doc: "The host's Firefox profiles directory, mounted read-only at `/data/browser/firefox` by the browser overlay, for `cookiesFromBrowser = firefox:/data/browser/firefox`." }, + { name: "OLLAMA_TAG", audience: "docker", default: "`0.40.5`", readBy: "docker-compose.yml", doc: "The `ollama/ollama` image tag the `ollama` profile runs." }, // ── test: harnesses, fakes and test-mode branches ────────────────────── { name: "E2E_TEST_ROUTES", audience: "test", default: "off", readBy: "editor/app/api/test/_guard.ts, editor/instrumentation.ts", doc: "`1` opens the editor's `/api/test/*` routes and marks a test server at boot. Set by `editor/playwright.config.ts` on its test server, and by nothing else." }, diff --git a/common/publish/buildImage.test.ts b/common/publish/buildImage.test.ts @@ -100,7 +100,7 @@ test("build-site.sh's asset sync ships a changed svg, drops a removed one, and t // nobody asked for, or a mirror rewritten by a version nobody tested. test("the runtime image installs the git-filter-repo that source publish names, in every target", () => { const dockerfile = readFileSync(path.join(REPO, "Dockerfile"), "utf8"); - const installs = [...dockerfile.matchAll(/pipx install (\S+)/g)].map((m) => m[1]); + const installs = [...dockerfile.matchAll(/pipx install (git-filter-repo\S*)/g)].map((m) => m[1]); // runtime-base (runtime + runtime-vulkan) and runtime-cuda, which repeats it. assert.equal(installs.length, 2, `expected two \`pipx install\` lines, found ${installs.length}`); for (const spec of installs) { @@ -112,6 +112,46 @@ test("the runtime image installs the git-filter-repo that source publish names, } }); +// gallery-dl (the X post fetcher) is pinned, and the editor's targets agree on +// the pin: runtime-base (runtime, runtime-vulkan, runtime-umtool) and +// runtime-cuda, which repeats it. GALLERY_DL_BIN names the installed one. +test("every runtime target installs the same pinned gallery-dl and names it in GALLERY_DL_BIN", () => { + const dockerfile = readFileSync(path.join(REPO, "Dockerfile"), "utf8"); + const installs = [...dockerfile.matchAll(/pipx install (gallery-dl\S*)/g)].map((m) => m[1]); + assert.equal(installs.length, 2, `expected two gallery-dl installs, found ${installs.length}`); + assert.match(installs[0], /^gallery-dl==\d+\.\d+\.\d+$/, "gallery-dl is pinned to an exact version"); + assert.equal(installs[1], installs[0], "runtime-base and runtime-cuda pin the same gallery-dl"); + const bins = [...dockerfile.matchAll(/^\s+GALLERY_DL_BIN=(\S+)/gm)].map((m) => m[1]); + assert.deepEqual(bins, ["/usr/local/bin/gallery-dl", "/usr/local/bin/gallery-dl"]); +}); + +// The umtool image renders with the hyperframes CLI it installs, never `npx +// --yes` at render time: the pin is the one deck.mjs names, and +// HYPERFRAMES_BIN points at it. +test("the umtool image installs the hyperframes deck.mjs pins and points HYPERFRAMES_BIN at it", async () => { + const dockerfile = readFileSync(path.join(REPO, "Dockerfile"), "utf8"); + const pinned = /^ARG HYPERFRAMES_VERSION=(\S+)$/m.exec(dockerfile)?.[1]; + assert.ok(pinned, "the Dockerfile pins HYPERFRAMES_VERSION"); + const deck = readFileSync(path.join(REPO, "umtool", "report-to-video", "deck.mjs"), "utf8"); + const named = /export const HYPERFRAMES_PKG_DEFAULT = "hyperframes@([^"]+)";/.exec(deck)?.[1]; + assert.equal(pinned, named, `the image installs hyperframes@${pinned}, deck.mjs renders with hyperframes@${named}`); + assert.match(dockerfile, /^ENV HYPERFRAMES_BIN=\/usr\/local\/bin\/hyperframes /m); + assert.match(dockerfile, /^FROM runtime-base AS runtime-umtool$/m); +}); + +// The deps stage pre-fetches node-datachannel's prebuilt binary into +// prebuild-install's cache (its own download gives up too soon from a build +// container); the version it fetches must be the one the lockfile installs, or +// the cache misses and the install falls back to a source build that fails. +test("the deps stage pre-fetches the node-datachannel prebuilt the lockfile installs", () => { + const dockerfile = readFileSync(path.join(REPO, "Dockerfile"), "utf8"); + const pinned = /^ARG NODE_DATACHANNEL_VERSION=(\S+)$/m.exec(dockerfile)?.[1]; + assert.ok(pinned, "the Dockerfile pins NODE_DATACHANNEL_VERSION"); + const lock = readFileSync(path.join(REPO, "pnpm-lock.yaml"), "utf8"); + const locked = [...new Set([...lock.matchAll(/^ {2}node-datachannel@(\d+\.\d+\.\d+):$/gm)].map((m) => m[1]))]; + assert.deepEqual(locked, [pinned], `the lockfile installs node-datachannel ${locked.join(", ")}; the Dockerfile pre-fetches ${pinned}`); +}); + // The yt-dlp substitution hook: the image ships its own yt-dlp as // ARCHILYZER_IMAGE_YTDLP beside YTDLP_BIN (the entrypoint and the doctor tell an // override by the difference), and links the from-source wrapper — in every diff --git a/docker-compose.anthropic.yml b/docker-compose.anthropic.yml @@ -0,0 +1,39 @@ +# Claude API overlay: the features that call the Claude API (frame scan, +# generation routed to "api") read the same one-line key file a host install +# does — ANTHROPIC_API_KEY=…, mode 600. +# +# docker compose -f docker-compose.yml -f docker-compose.anthropic.yml up -d +# +# (`archilyzer service install` adds this overlay by itself when the file +# exists.) +# +# The file is bind-mounted READ-ONLY at the path the app's default +# `generation.apiKeyFile` names (~/.config/archilyzer/anthropic.env, root's home +# in the container), so no setting changes. A mount, not an env_file and not a +# variable: its value never appears in `docker compose config`, in +# `docker inspect`, or in .env. The app refuses a key file that group or others +# can read — `chmod 600` it on the host; a bind mount keeps the host's mode. +# +# Not there? `up` refuses with "bind source path does not exist" rather than +# creating an empty directory where the file should be. Leave the overlay out +# and those features say "no API key"; every other feature works without it. +# +# Another path: ARCHILYZER_ANTHROPIC_ENV_FILE in .env. + +services: + editor: + volumes: + - type: bind + source: ${ARCHILYZER_ANTHROPIC_ENV_FILE:-${HOME:-.}/.config/archilyzer/anthropic.env} + target: /root/.config/archilyzer/anthropic.env + read_only: true + bind: + create_host_path: false + umtool: + volumes: + - type: bind + source: ${ARCHILYZER_ANTHROPIC_ENV_FILE:-${HOME:-.}/.config/archilyzer/anthropic.env} + target: /root/.config/archilyzer/anthropic.env + read_only: true + bind: + create_host_path: false diff --git a/docker-compose.browser.yml b/docker-compose.browser.yml @@ -0,0 +1,45 @@ +# Browser cookies overlay: yt-dlp's `--cookies-from-browser` (Settings → +# cookiesFromBrowser, a channel's own value, and cookieMode) and gallery-dl's +# read a browser's cookie store. In a container there is no browser, so the +# host's Firefox profiles are mounted READ-ONLY and the setting names the path: +# +# docker compose -f docker-compose.yml -f docker-compose.browser.yml up -d +# +# then, in Settings (or a channel's Configure form): +# +# cookiesFromBrowser = firefox:/data/browser/firefox +# +# yt-dlp takes a path as the profile and reads the newest cookies.sqlite under +# it (one profile dir — firefox:/data/browser/firefox/<xxxx.default-release> — +# pins one). It copies the database before reading, so read-only is enough, and +# Firefox may stay open on the host. +# +# What works from here: +# Firefox YouTube, Rumble (cf_clearance — the app pins the User-Agent that +# cookie was issued to), Odysee, X via gallery-dl. Its cookies are +# not encrypted on Linux. +# Chrome / NOT from a container: on Linux their cookies are encrypted with a +# Chromium key held by the desktop keyring (GNOME Keyring, KWallet), which a +# container cannot reach. Export a cookies.txt (Netscape format) +# instead, copy it into the config volume and name it with file:: +# docker compose cp cookies.txt editor:/data/config/cookies.txt +# cookiesFromBrowser = file:/data/config/cookies.txt +# (no overlay needed for that one; a cookies.txt goes stale as the +# site rotates its cookies — re-export when fetches start failing). +# +# Where your profiles are: +# ~/.mozilla/firefox the classic place (the default here) +# ~/.config/mozilla/firefox a newer Firefox's XDG location +# ~/snap/firefox/common/.mozilla/firefox Ubuntu's snap +# ~/.var/app/org.mozilla.firefox/.mozilla/firefox flatpak +# Set ARCHILYZER_FIREFOX_PROFILES in .env when yours is not the first. + +services: + editor: + volumes: + - type: bind + source: ${ARCHILYZER_FIREFOX_PROFILES:-${HOME:-.}/.mozilla/firefox} + target: /data/browser/firefox + read_only: true + bind: + create_host_path: false diff --git a/docker-compose.gpu.yml b/docker-compose.gpu.yml @@ -28,8 +28,9 @@ services: count: all capabilities: [gpu] - # The other three run the same image so `docker compose ... up` never rebuilds - # a second variant behind your back. None of them touches the GPU. + # site and homepage run the same image so `docker compose ... up` never + # rebuilds a second variant behind your back. Neither touches the GPU. + # umtool keeps its own image (runtime-umtool). site: build: target: runtime-cuda @@ -38,7 +39,13 @@ services: build: target: runtime-cuda image: archilyzer:${ARCHILYZER_TAG:-local}-cuda - umtool: - build: - target: runtime-cuda - image: archilyzer:${ARCHILYZER_TAG:-local}-cuda + + # ollama (profile `ollama`) on the NVIDIA GPU too. + ollama: + deploy: + resources: + reservations: + devices: + - driver: nvidia + count: all + capabilities: [gpu] diff --git a/docker-compose.vulkan.yml b/docker-compose.vulkan.yml @@ -53,8 +53,9 @@ services: # measure what the GPU is buying you. Unset — the default — lets # parakeet.cpp choose. - # The other three run the same image so `up` never builds a second variant - # behind your back. None of them touches the GPU. + # site and homepage run the same image so `up` never builds a second + # variant behind your back. Neither touches the GPU. umtool keeps its own + # image (runtime-umtool) — the renderer needs no GPU. site: build: target: runtime-vulkan @@ -67,9 +68,13 @@ services: args: RUNTIME_IMAGE: node:22-trixie-slim image: archilyzer:${ARCHILYZER_TAG:-local}-vulkan - umtool: - build: - target: runtime-vulkan - args: - RUNTIME_IMAGE: node:22-trixie-slim - image: archilyzer:${ARCHILYZER_TAG:-local}-vulkan + + # ollama (profile `ollama`) on the same render node. Its Vulkan backend is + # opt-in upstream (OLLAMA_VULKAN=1) and newer than its CUDA/ROCm ones: check + # `docker compose logs ollama` for the device it found, and compare a + # generation's speed with the variable unset if in doubt. + ollama: + devices: + - /dev/dri:/dev/dri + environment: + OLLAMA_VULKAN: "1" diff --git a/docker-compose.yml b/docker-compose.yml @@ -8,6 +8,11 @@ # docker compose --profile site up -d + the published archive # docker compose --profile site --profile homepage up -d # docker compose --profile umtool up -d +# docker compose --profile ollama up -d + a local model server +# +# Or as a service that starts at boot: `pnpm archilyzer service install` +# (a systemd user unit running this file; RUNNING_IN_DOCKER.md, "Run it as a +# service"). # # THE EXPOSURE MODEL, which is the load-bearing part of this file: # @@ -83,6 +88,13 @@ x-app-env: &app-env # are on the caddy service below. EDITOR_PORT: "3001" UMTOOL_PORT: "3050" + # umtool's projects (report → video), in the reports volume. + REPORTS_DIR: /data/reports + # Local models: the `ollama` service (profile `ollama`) by default. A host's + # own ollama instead: OLLAMA_URL=http://host.docker.internal:11434 in .env. + OLLAMA_URL: ${OLLAMA_URL:-http://ollama:11434} + # How umtool (and an MCP run inside a container) reaches the editor. + ARCHILYZER_EDITOR_URL: http://editor:3001 services: # ------------------------------------------------------------------------- @@ -116,6 +128,10 @@ services: editor: <<: *app command: ["editor"] + # host.docker.internal resolves on Linux too (Docker Desktop has it built + # in): a host's ollama, or another service on the host, at that name. + extra_hosts: + - "host.docker.internal:host-gateway" environment: <<: *app-env # The publish lock's host identity (common/publish/stageLock.ts). Its @@ -130,6 +146,7 @@ services: - config:/data/config - models:/data/models - builds:/data/builds + - reports:/data/reports healthcheck: # /api/pulse answers from in-memory state plus two stat() calls — it is # built to be polled forever, which is exactly what a healthcheck does. @@ -182,12 +199,46 @@ services: <<: *app profiles: [umtool] command: ["umtool"] + # Its own image: the runtime-umtool target adds what report → video + # renders shell out to (ImageMagick 7 with Pango, rsvg-convert, qrencode, + # zbarimg, chromium, hyperframes and its headless shell). On trixie, for + # ImageMagick 7 — the Dockerfile says why. + build: + context: . + target: runtime-umtool + args: + RUNTIME_IMAGE: node:22-trixie-slim + ARCHILYZER_COMMIT: ${ARCHILYZER_COMMIT:-} + ARCHILYZER_BRANCH: ${ARCHILYZER_BRANCH:-} + image: archilyzer:${ARCHILYZER_TAG:-local}-umtool + extra_hosts: + - "host.docker.internal:host-gateway" environment: <<: *app-env + UMTOOL_CACHE_DIR: /data/builds/umtool-cache volumes: - corpus:/data/transcripts - config:/data/config - builds:/data/builds + - reports:/data/reports + # A render runs ffmpeg and a headless browser in here; give its children + # time to stop. + stop_grace_period: 30s + + # ------------------------------------------------------------------------- + # Local models: ollama, for the digest lanes and generation routed to + # "local". Internal only (no port); the apps reach it at http://ollama:11434. + # Pull a model once: + # docker compose exec ollama ollama pull qwen3:8b + # GPU: the vulkan and gpu overlays give it the same device as the editor. + # ------------------------------------------------------------------------- + ollama: + image: ollama/ollama:${OLLAMA_TAG:-0.40.5} + profiles: [ollama] + restart: unless-stopped + networks: [archilyzer] + volumes: + - ollama:/root/.ollama networks: archilyzer: @@ -210,5 +261,10 @@ volumes: # the locally deployed site and homepage. Reproducible; losing it costs a # rebuild, not data. builds: + # umtool's projects: manifests, takes, renders. Real work — back it up with + # the corpus. + reports: + # ollama's models (profile `ollama`). Re-downloadable. + ollama: caddy-data: caddy-config: diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh @@ -45,7 +45,12 @@ mkdir -p \ "${MODELS_DIR}" \ "${BUILDS_DIR}" \ "${SITE_OUT}" \ - "${HOMEPAGE_OUT}" + "${HOMEPAGE_OUT}" \ + "${REPORTS_DIR:-/data/reports}" +# The targets of the image's three state links (Dockerfile, runtime-base): the +# TTS engines, the TTS cache and the generation ledger. Fixed paths, as the +# links are. +mkdir -p /data/models/tts /data/builds/tts /data/config/generation # The operator's private config dir (compose sets it inside the config volume), # made so `docker compose cp` has somewhere to put the source mirror's rules. # Only made, never filled: what goes in it is the operator's.