T24: self-hosting guide + bun run setup #23
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "t24-self-hosting"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
T24: Self-hosting guide +
bun run setupStacked on #22 (
t23-account) → … → #1. Merge those first.bun run setup(never contacts Cloudflare).dev.varsfrom the template with generated 32-byteTOKEN_ENCRYPTION_KEYandBETTER_AUTH_SECRET. On an existing file, every line is kept verbatim: setup only fills generated secrets that are present but empty, and appends template keys that are missing. The parser understands CRLF,export, spaces around=and quotes, so an existing key is never overwritten. The file is set tochmod 600, even if it already existed with 644. Then it applies local D1 migrations and warns ifFIT_AUTH_CLIENT_*are empty.--d1-id <uuid> --kv-id <hex32>: validates the IDs and writes them intowrangler.jsonc. TheDB/OAUTH_KVbinding objects are found structurally (a brace scanner that skips strings and comments, so property order doesn't matter), and it fails if a binding or key is missing. Then it regeneratesworker-configuration.d.ts.--production: prints the deploy checklist (create D1/KV, secrets, remote migrations, deploy) for the self-hoster to run..dev.vars.exampledocumentsALLOWED_USERS.docs/self-hosting.mdPrerequisites and quick start, then:
<PUBLIC_URL>/auth/callback, the exact scopes (and nevercourse-restricted), and the lesson from T7 that Usermap, Sirius, Grades and Marast must be enabled as services/resources, not just scopes.The README now links all docs, documents
setup,mcp:smokeandfixtures:record, and the quick start usesbun run setup.Verified
bun run lint && bun run typecheck && bun run test: 271 tests, 12 of them for setup..dev.varshandling: new file, never overwriting, unknown keys kept, idempotent, CRLF/export/spaces/quotes kept verbatim, quoted-empty counts as empty.database_idbinding and a comment containing a brace; loud failures; malformed IDs; the realwrangler.jsonc; the production checklist never says--local.bun run setupon the real dev.dev.vars: byte-identical afterwards, mode 600, local D1 migrated.--productionprints the checklist, and an invalid--d1-idis rejected before any write.Astra review (gpt-6-astra)
Fixed:
export, spaces) wasn't recognised, so setup could overwrite an existing encryption key and strand stored tokens → existing files are kept verbatim with a full dotenv parser. Tests added..dev.varsstayed world-readable after secrets were written → explicitchmod 600.🤖 Generated with Claude Code