15 KiB
Milestone 6 change note (for QA)
Author: the developer. Scope: PLAN story 10 (self-hosting), DESIGN build-order step 6, and the
decisions-log entries for Nginx Proxy Manager, security headers and invisible users in voice.
Also adds the "no silent skips" rule from the decisions log (REQUIRE_LIVEKIT) and a 320/375 px pass over the
voice UI.
Deliverable
npm run packagebuildsdist/doghouse-<version>.zipand a.sha256file next to it. The zip's single top folder isdoghouse-<version>/. It holds:README.md,CHANGES-M6.mdanddeploy/.- The source the image is built from: root
package.json,package-lock.json,tsconfig.base.json,.dockerignore,packages/shared,apps/server,apps/web(sources, configs andpublic/). - Never included:
node_modules,dist,coverage,*.test.ts,e2e/,qa/, data,.env,.git.
- Building on the server: Justin runs
docker compose up -d --buildindeploy/. No prebuilt image and no registry. - Zip writer: written in Node, so packaging needs no zip tool. Unix permissions are kept, so
docker-entrypoint.shstays executable.
deploy/
| File | What |
|---|---|
Dockerfile |
Three stages on node:22-alpine. build: npm ci + npm run build. deps: npm ci --omit=dev --workspace=apps/server, so only the server's production deps are installed, as musl binaries. runtime: the compiled server, shared and web dist, and the prod node_modules. Runs as the node user, uses tini, and has a HEALTHCHECK (wget /api/health) |
docker-entrypoint.sh |
Starts as root only to chown a fresh ./data bind mount (Docker creates it root-owned), then su-exec node. The app never runs as root |
docker-compose.yml |
Project doghouse. doghouse-app is built from .., takes env_file: .env, mounts ./data:/data, and publishes no ports. doghouse-livekit uses the pinned livekit/livekit-server:v1.13.9 image (the version e2e tests against), mounts ./livekit.yaml read-only and publishes 7881/tcp, 50000-50100/udp and 3478/udp. Both containers are on the external network doghouse_net with restart: unless-stopped |
livekit.yaml |
Signal port 7880. RTC: TCP 7881, UDP 50000-50100, use_external_ip: true. TURN: enabled on UDP 3478, TLS off. Webhook to http://doghouse-app:3000/api/livekit/webhook. No keys in the file |
.env.example |
APP_NAME, PUBLIC_URL, LIVEKIT_PUBLIC_URL, LIVEKIT_TURN_DOMAIN, NODE_ENV=production, TRUST_PROXY_HOPS=1, MAX_UPLOAD_MB=25, PRESENCE_GRACE_MS, SESSION_TTL_DAYS, AUTH_RATE_LIMIT_MAX, LOG_LEVEL. LiveKit key and secret are empty, with the command to generate them |
npm-advanced.conf |
Pasted into NPM's Advanced tab: client_max_body_size 30m, and location /livekit/ to doghouse-livekit:7880 (prefix stripped, Upgrade/Connection headers, 86400 s timeouts) |
nginx-raw.conf |
Appendix for plain nginx. A full server block that overwrites X-Forwarded-For/X-Real-IP with $remote_addr and covers /, /ws and /livekit/ |
How keys reach LiveKit:
livekit.yamlcan't read env vars, but LiveKit takes every config field fromLIVEKIT_*env vars.- Compose sets
LIVEKIT_KEYS="${LIVEKIT_API_KEY}: ${LIVEKIT_API_SECRET}",LIVEKIT_WEBHOOK_API_KEY=${LIVEKIT_API_KEY}andLIVEKIT_TURN_DOMAINfrom.env. - With an empty key, compose refuses to start (
${LIVEKIT_API_SECRET:?…}), so there are no default keys (TESTPLAN 10).
NPM resolves LiveKit per request: the Advanced block proxies through a variable plus Docker's
resolver 127.0.0.11. So NPM still loads its config when doghouse-livekit doesn't exist yet,
and that route returns 502 until it does. A literal hostname would make nginx refuse to start.
X-Forwarded-For with NPM: NPM appends to it. With TRUST_PROXY_HOPS=1 the app uses the
rightmost entry, which NPM sets from the real connection. Verified (see "Verified here").
App changes
-
Security headers come from the app (
apps/server/src/lib/security.ts) and are sent on every response; attachments keep their stricter sandbox CSP. The policy:default-src 'self'; script-src 'self'(no inline, no eval).style-src 'self' 'unsafe-inline': Svelte style attributes and transitions. Styles can't run code.img-src 'self' data: blob:; media-src 'self' blob:; font-src 'self'.connect-src 'self'plus thewss://andhttps://origins ofPUBLIC_URLandLIVEKIT_PUBLIC_URL.worker-src 'self' blob:; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'none'.
Other headers:
X-Content-Type-Options: nosniff.Referrer-Policy: same-origin.Permissions-Policy: microphone=(self), display-capture=(self), fullscreen=(self), autoplay=(self), camera=(), geolocation=(), payment=(), usb=().X-Frame-Options: DENY.Cross-Origin-Opener-Policy: same-origin.
-
CSP fix: zod probed
new Function. Zod 4's JIT does this, and the browser logged it as a CSP violation (script-src blocked eval) on every page load. The e2e CSP guard caught it.packages/sharednow setsz.config({ jitless: true }). Theme boot was already an external file (/theme-boot.js), and a test assertsindex.htmlhas no inline scripts or handlers. -
MAX_UPLOAD_MB(new, default 25, range 1-1024) is both the default and the ceiling for the upload limit, so the proxy'sclient_max_body_sizealways fits.- Admins can lower it with
PATCH /api/admin/settings. A value above the ceiling gets 400 "at most N MB (MAX_UPLOAD_MB in .env)". - Migration
003drops the old seededmax_upload_mb=25row so the env value applies. - There's no admin UI for this setting; there wasn't one before either.
- Admins can lower it with
-
Invisible users in voice (decisions log):
- They show in that voice channel's participant list (channel list and voice view), which never had presence dots.
- The member list now keeps them in Offline, not in the "In voice" group. DMs and presence still show them as offline.
- They disappear from voice as soon as they leave.
- New test,
socket.test.ts, "invisible in voice": a server-mate getsvoice:statewith them and still no presence. A user in a different server with no DM gets no socket event mentioning them at all (onAnycapture), nothing in/api/presence, and 404 on that server's/voice. Leaving empties the channel at once.
-
Responsive fix (320 px): in the channel drawer, a long name next to the LIVE badge pushed the badge past the drawer edge, where it was clipped. The voice-people list now stays inside its row, the name truncates and the flags never shrink.
- Checked at 320×640 and 375×812 with 3 people in a call and a screen share: voice view, focused share, and the drawer with the voice bar.
scrollWidthequals the viewport width and no element extends past the right edge in any of them. Screenshots were reviewed.
Tests and "no silent skips" (decisions log)
npm test=scripts/test.mjs:- Runs Vitest per workspace, then prints a summary table (files, passed, failed, skipped per suite) and lists every skipped test by name.
- Prints whether
REQUIRE_LIVEKITwas set, and the server coverage figures.
- New
apps/server/test/livekit.integration.test.ts:- Starts the real
livekit-serverbinary. - Checks the app's real
RoomServiceClientcalls: the startup rebuild deletes rooms of unknown channels and keeps ours, and a stranger's join leads to aremoveParticipantwhose 404 is ignored. - Deleting a voice channel deletes its room.
- Starts the real
- Without the binary, it is skipped with a warning and listed in the summary.
- With
REQUIRE_LIVEKIT=1, it fails with "REQUIRE_LIVEKIT=1 but no livekit-server binary was found…". - e2e: with
REQUIRE_LIVEKIT=1and no binary,e2e/server.mjsexits with a clear error and the run fails. The voice spec also throws instead of skipping if voice turns out to be disabled. LIVEKIT_BIN, if set, is the only path tried. This makes "missing" testable.- e2e now runs the production configuration:
NODE_ENV=production(strict Origin check) with the full CSP. Every e2e page recordssecuritypolicyviolationevents and fails on any. This covers the smoke specs, the realtime spec, and voice with a screen share. npm run validate:deploy(part ofnpm run check):- Parses all the YAML.
- Validates
docker-compose.ymlagainst the official compose-spec JSON schema (vendored asscripts/compose-spec.json) after interpolating.env.example. - Enforces the decisions-log rules: container names, no app ports, pinned LiveKit image, exact
published ports, external network, volumes, restart policy, no keys in
livekit.yamland empty keys in.env.example,client_max_body_sizeaboveMAX_UPLOAD_MB,/livekit/rewrite plus upgrade headers, XFF overwrite in the raw appendix, and the Dockerfile basics. - Checked that it fails when the app publishes a port or the compose file has an unknown key.
Results (all on Node v20.19.2)
REQUIRE_LIVEKIT=1 npm run check at the M6 commit, copied from its summary:
┌─────────┬───────────────────┬───────┬────────┬────────┬─────────┐
│ (index) │ suite │ files │ passed │ failed │ skipped │
├─────────┼───────────────────┼───────┼────────┼────────┼─────────┤
│ 0 │ 'packages/shared' │ 3 │ 22 │ 0 │ 0 │
│ 1 │ 'apps/server' │ 14 │ 187 │ 0 │ 0 │
│ 2 │ 'apps/web' │ 7 │ 205 │ 0 │ 0 │
└─────────┴───────────────────┴───────┴────────┴────────┴─────────┘
Skipped tests: 0
REQUIRE_LIVEKIT=1
Server coverage: statements 98.12%, branches 92.35%, functions 99.29%, lines 99.19%
(The coverage line is Vitest's coverage-summary.json for apps/server, which is the same as
the "All files" row.)
About the M5 coverage figure (QA measured 96.6% statements, my M5 report said 97.6%):
- A fresh
cd apps/server && npx vitest run --coverageon a clean checkout of5c8f45bgivesAll files | 97.62 | 91.76 | 98.09 | 98.62(180 tests, 0 skipped). - At M5 no server test depended on LiveKit (they all used a fake), so skipping can't explain a
1-point gap then. I couldn't reproduce 96.6%. QA-REPORT records 181 server tests for
the QA run against 180 at
5c8f45b, so that tree had something extra (perhaps a local probe test), and that's the likeliest cause. A different Node version (V8 counts coverage slightly differently) is the other candidate. - From M6 on, skipping does matter. Without the binary
(
LIVEKIT_BIN=/nope npx vitest run --coverage) the run shows 186 passed, 1 skipped, andAll files | 97.66 | 91.84 | 98.12 | 98.65, becausedefaultLivekitApiinapp.ts(lines 65-72) is then never exercised. So quote coverage fromREQUIRE_LIVEKIT=1runs.
e2e: REQUIRE_LIVEKIT=1 npm run e2e, run twice in full: both times 10 passed, 4 skipped (the multi-user specs only run in the desktop project, by design, including voice), 0 failed.
LIVEKIT_BIN=/nope REQUIRE_LIVEKIT=1 fails as intended: [WebServer] e2e: REQUIRE_LIVEKIT=1 but no livekit-server binary was found …, then Process from config.webServer was not able to start. Exit code: 1.
Verified here (no Docker on this machine)
- Alpine/musl runtime, built from the zip. The zip was unpacked into an Alpine 3.22
root filesystem with Node 22.23.2 and npm 11 (the same musl/Node base as
node:22-alpine), run withbwrap. Inside it:- The Dockerfile's commands were repeated by hand:
npm ci+npm run build, thennpm ci --omit=dev --workspace=apps/server, giving 157 packages. sharploads its musl build (libvips 8.18.7),better-sqlite3uses its musl prebuild (SQLite 3.53.0) and@node-rs/argon2hashes with its musl binary. This closes QA's "sharp Alpine build" item, short of the real image.
- The Dockerfile's commands were repeated by hand:
- Production stack behind an NPM-like nginx. The production app from that tree (as a
non-root uid,
NODE_ENV=production) ran behind nginx 1.28 configured like an NPM proxy host (Websockets on, XFF appended, ournpm-advanced.confincluded). LiveKit 1.13.9 ran withdeploy/livekit.yaml, with keys, webhook key and TURN domain passed only through the env vars compose sets. Results:- The e2e realtime and voice specs pass through nginx: join, speaking, mute and deafen, screen share received, kick. Webhooks arrive signed with the env-provided key, and there were no CSP violations.
- Headers are present on every response.
- The QA-1 spoof check passes: 12 logins with forged
X-Forwarded-Forvalues still hit the per-IP limit (10 × 401, then 429). - A cross-origin POST gets 403.
- A 31 MB upload is rejected by nginx with 413 (
client_max_body_size 30m). /livekit/answersOKthrough the proxy, and 502 (nginx still running) while LiveKit is down.
nginx -tpasses fornginx-raw.conf(syntax OK; binding to 80/443 isn't possible here without root).- The zip passes
unzip -t. Its listing contains nonode_modules,dist, tests,.env, data or.git, anddocker-entrypoint.shkeeps mode 755.
Not verified (needs a machine with Docker; for QA's step 6)
docker compose configand a realdocker compose build/up. Checks to make there:- The image's
HEALTHCHECKturns healthy. - The entrypoint's
chown+su-execon a fresh./data. tinisignal handling (docker compose stopshould be quick).- Data survives
down && up.
- The image's
- The real
livekit/livekit-server:v1.13.9image. It was tested only as the same-version binary. Two things to confirm: its entrypoint accepts--configandgenerate-keys(README step 4), anduse_external_ip: truefinds the public IP. On this machine STUN is blocked, and LiveKit then hangs at startup without logging anything. The README's troubleshooting covers this: setnode_ipinstead. - Nginx Proxy Manager itself (only an equivalent nginx config was tested): the Advanced-tab
locationmerging, Let's Encrypt, Force SSL, HTTP/2 and HSTS. - TURN relaying from outside, router forwards, and real phones (iOS audio after tapping Join is still a manual item from M5).
- arm64 (e.g. a Raspberry Pi). Prebuilt musl arm64 packages exist for sharp and argon2, and the
Dockerfile includes
g++as a fallback for better-sqlite3, but none of this was tried.
Known gaps / notes
- The root
package.jsonversion is still0.1.0, so the zip isdoghouse-0.1.0.zip. Bump the version before the real release if wanted. - npm installs the glibc variants of sharp and argon2 alongside the musl ones. The deps stage
deletes them, saving about 19 MB. After that, sharp still encoded a JPEG and argon2 still
hashed in the Alpine root filesystem. The runtime
node_modulesis about 95 MB.