Self-host on Coolify (Vultr VPS) #330
No reviewers
Labels
No labels
accessibility
area:accounts
area:ai-evals
area:look
area:maps
area:platform
area:rides-progress
area:riding
area:today-plan-coach
area:ui-shell
bot:blocked
bot:failed
bot:pr
bot:waiting
bot:working
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
later
now
owner-check
parked
question
ready
session
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
ckreidl/trainer!330
Loading…
Reference in a new issue
No description provided.
Delete branch "chore/self-host"
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?
Moves production off Vercel + Prisma Postgres onto the owner's VPS under Coolify.
What changed
Dockerfile(oven/bun:1.4, Nitrobunpreset): runsprisma migrate deploy, thenbun .output/server/index.mjs. Health check on/api/build. SetsNODE_ENV=production,MAP_TILE_DIR=/data/map-tiles,MAP_TILES_BESIDE_DB=1,SERVER_SHUTDOWN_TIMEOUT=60.runInBackground(src/server/background.ts) replaceswaitUntilin all six callers.nitro-shutdown.tswaits up to about 59 s on SIGTERM for that work to finish. Work that runs longer (a long re-plan) is cut off and recovers the way a dead worker already does.@vercel/blobare gone.map:fillandmap:refreshrun inside the container. Against a remote database they refuse to write unlessMAP_TILES_BESIDE_DB=1.scripts/cron.ts <name>calls the existing/api/cron/*routes withCRON_SECRET. It's meant for Coolify scheduled tasks.auth-originsno longer readsVERCEL_*. Production (NODE_ENV) withoutBETTER_AUTH_URLthrows.vercel.json,build:vercel,check-vercel-runtime.tsand@vercel/functions. Updated docs: architecture → Hosting, requirements, CLAUDE.md, PROGRESS, decisions, history.How it was checked
bun test: 1565 pass, 1 fail. The failure also happens onmainbecause it depends on the date (#328).bun run auditfails onmaintoo, from a new cross-spawn advisory (#329), so CI's audit step will be red.docker buildsucceeds. I ran the image against an empty Postgres database:/api/buildreturned 200, the container reported healthy, and the security headers were present.cron.ts missed-sessionsreturned 200. A wrong secret was refused.fill-map-tiles --dry-runran in the container.docker stopshut the server down gracefully.Cutover (owner, in Coolify)
Merging this does not deploy anywhere until Coolify is set up. Vercel keeps auto-deploying
mainuntil you disconnect it, and those builds fail now thatvercel.jsonis gone, so production stays on the last good deploy.main, build pack Dockerfile, port 3000.DATABASE_URL(the Postgres internal URL),BETTER_AUTH_SECRET,BETTER_AUTH_URL=https://trainer.kreidl.org,ANTHROPIC_API_KEY(a new key, since the old one expired),CRON_SECRET,STRAVA_CLIENT_ID,STRAVA_CLIENT_SECRET,TOKEN_ENCRYPTION_KEY. Copy every value except the API key from Vercel, and keepBETTER_AUTH_SECRETandTOKEN_ENCRYPTION_KEYexactly as they are, or sessions and Strava tokens stop working./data.!docs/**,!prompts/**,!**/*.md.pg_dump -Fc --no-owner --exclude-table-data='"MapTile"' --exclude-table-data='"MapTileClaim"'from Prisma Postgres (tile rows left out: they describe Blob's files, and a row without its file blocks the fill), thenpg_restore --no-ownerinto the new database (an SSH tunnel to the VPS works). Then deploy.bun scripts/fill-map-tiles.ts(no tile rows came over, so it fetches every ride's tiles).0 9 * * *bun scripts/cron.ts missed-sessions,10 9 * * *… strava-uploads,20 9 * * *… map-tiles.trainer.kreidl.orgat the VPS and set it as the app's domain (Coolify issues the TLS certificate). Sign in with a passkey to check.🤖 Generated with Claude Code
The latest updates on your projects. Learn more about Vercel for GitHub.