The Convex backend and its Node actions ran as root. Only the web server dropped privileges.
.dockerignore only excluded .env* files at the context root, so apps/web/.env.local and packages/convex/.env.local were copied into the build. Next.js inlines NEXT_PUBLIC_* values, and the Convex CLI reads .env.local on deploy.
env get JWKS ... || true treated any CLI failure as "no keys yet", so a transient error regenerated the signing keys and signed every user out.
Fix
New convex system user runs run_backend.sh, generate_admin_key.sh and the Convex CLI. On boot the entrypoint chowns anything in /convex/data not owned by convex, so volumes from older root-run images upgrade in place (without this, read_credentials.sh would mint a new instance secret). convex is in the otunes group, and /tmp/otunes is setgid and group-writable so the HLS cleanup cron can still delete the web server's streams.
.dockerignore now uses **/.env and **/.env.* (with !**/.env.example).
Keys are generated only when env get JWKS exits 0 with empty output. Any failure stops the container with an error.
Verification
Full docker build of main and this branch (all stages).
With canary .env.local files in both workspaces: main's build context includes them, this branch's does not; no canary in the image.
Upgrade: ran main's image on a fresh volume, signed up, then started this image on the same volume. Data volume re-owned by convex, instance secret unchanged, no key regeneration, old access token still valid, refresh token works. ps shows backend as convex, web as otunes; only tini and the entrypoint supervisor stay root.
Fresh volume generates keys once; restart keeps the session.
Forcing env get to fail (bad admin key) exits 1 with "Could not read Convex Auth signing keys"; the next normal boot still accepts the existing session.
Changes made by Claude Opus 5.5 in Claude Code (via T3 Code).
Three problems in the Docker image:
- The Convex backend and its Node actions ran as root. Only the web server dropped privileges.
- `.dockerignore` only excluded `.env*` files at the context root, so `apps/web/.env.local` and `packages/convex/.env.local` were copied into the build. Next.js inlines `NEXT_PUBLIC_*` values, and the Convex CLI reads `.env.local` on deploy.
- `env get JWKS ... || true` treated any CLI failure as "no keys yet", so a transient error regenerated the signing keys and signed every user out.
## Fix
- New `convex` system user runs `run_backend.sh`, `generate_admin_key.sh` and the Convex CLI. On boot the entrypoint chowns anything in `/convex/data` not owned by `convex`, so volumes from older root-run images upgrade in place (without this, `read_credentials.sh` would mint a new instance secret). `convex` is in the `otunes` group, and `/tmp/otunes` is setgid and group-writable so the HLS cleanup cron can still delete the web server's streams.
- `.dockerignore` now uses `**/.env` and `**/.env.*` (with `!**/.env.example`).
- Keys are generated only when `env get JWKS` exits 0 with empty output. Any failure stops the container with an error.
## Verification
- Full `docker build` of main and this branch (all stages).
- With canary `.env.local` files in both workspaces: main's build context includes them, this branch's does not; no canary in the image.
- Upgrade: ran main's image on a fresh volume, signed up, then started this image on the same volume. Data volume re-owned by `convex`, instance secret unchanged, no key regeneration, old access token still valid, refresh token works. `ps` shows backend as `convex`, web as `otunes`; only tini and the entrypoint supervisor stay root.
- Fresh volume generates keys once; restart keeps the session.
- Forcing `env get` to fail (bad admin key) exits 1 with "Could not read Convex Auth signing keys"; the next normal boot still accepts the existing session.
Changes made by Claude Opus 5.5 in Claude Code (via T3 Code).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
- Run the Convex backend, admin key generation and CLI as a dedicated convex
user; chown volumes left root-owned by older images on boot.
- Exclude .env files in every workspace from the build context.
- Only generate Convex Auth keys when 'env get JWKS' succeeds and is empty;
fail startup on any other error instead of signing everyone out.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Three problems in the Docker image:
.dockerignoreonly excluded.env*files at the context root, soapps/web/.env.localandpackages/convex/.env.localwere copied into the build. Next.js inlinesNEXT_PUBLIC_*values, and the Convex CLI reads.env.localon deploy.env get JWKS ... || truetreated any CLI failure as "no keys yet", so a transient error regenerated the signing keys and signed every user out.Fix
convexsystem user runsrun_backend.sh,generate_admin_key.shand the Convex CLI. On boot the entrypoint chowns anything in/convex/datanot owned byconvex, so volumes from older root-run images upgrade in place (without this,read_credentials.shwould mint a new instance secret).convexis in theotunesgroup, and/tmp/otunesis setgid and group-writable so the HLS cleanup cron can still delete the web server's streams..dockerignorenow uses**/.envand**/.env.*(with!**/.env.example).env get JWKSexits 0 with empty output. Any failure stops the container with an error.Verification
docker buildof main and this branch (all stages)..env.localfiles in both workspaces: main's build context includes them, this branch's does not; no canary in the image.convex, instance secret unchanged, no key regeneration, old access token still valid, refresh token works.psshows backend asconvex, web asotunes; only tini and the entrypoint supervisor stay root.env getto fail (bad admin key) exits 1 with "Could not read Convex Auth signing keys"; the next normal boot still accepts the existing session.Changes made by Claude Opus 5.5 in Claude Code (via T3 Code).
🤖 Generated with Claude Code