Deploying
Three Vercel projects build from this repository, one per folder, in the Salitre team (#112). Each
folder’s vercel.json holds the commands, rewrites and headers, so the dashboard only needs the
root directory and the environment variables. Production is on homefelt.io (#104, “Custom
domains”); branch previews stay at the *.vercel.app addresses.
| Project | Root directory | Framework | Production | Preview | What it serves |
|---|---|---|---|---|---|
homefelt |
site |
Astro | https://homefelt.io |
https://homefelt.vercel.app |
the marketing site (docs/marketing-site.md), static |
homefelt-play |
web |
Vite | https://play.homefelt.io |
https://homefelt-play.vercel.app |
the game (web/README.md), static, with the engine in Wasm |
homefelt-docs |
docs-site |
Astro | https://docs.homefelt.io |
https://homefelt-docs.vercel.app |
these docs (“Docs site” below), static and private |
The game server runs on Fly.io at https://api.homefelt.io, with its Postgres on Neon (“Game
server” below, decision 0012): it must share
the registrable domain with play. for the SameSite=Strict refresh cookie.
Creating the projects
Merge the PR that adds web/vercel.json first: the first build runs from main.
For each project, at vercel.com/new in the Salitre team:
- Import Git Repository: pick
EdSancha/homefelt. If it is not listed, choose “Adjust GitHub App Permissions” and give the Vercel app access to that repository (only that one is enough). - Project Name:
homefelt, orhomefelt-play. The name becomes the address (homefelt.vercel.app); if Vercel adds a suffix because the name is taken, use the address it shows in the variables below. - Root Directory: Edit, then
site, orweb. - Framework Preset: Astro, or Vite (detected;
vercel.jsonsets it too). Leave Build, Output and Install settings alone:vercel.jsonoverrides them. - Environment Variables (all environments):
homefelt:PUBLIC_PLAY_URL=https://homefelt-play.vercel.app(the web app; every Play button opens a game under it, such as/canasta) andSITE_URL=https://homefelt.vercel.app(canonical URLs; without it they sayhomefelt.io). Production gets thehomefelt.iovalues once the domains are on (“Custom domains”).homefelt-play: none at first.VITE_SERVER_URLcomes once the game server answers (“Game server”, step 8).
- Deploy.
- Afterwards, in Settings, Build and Deployment, Root Directory: keep Include files outside the
root directory in the Build Step on (the default). The site imports
../design/screens, and the game builds the engine from../rustand../spec.
What the builds do
- homefelt:
npm install, thenastro buildintodist/.site/src/theme.generated.cssis committed, so the build needs no Python.site/vercel.jsoncaches/_astro/*(hashed) for a year. - homefelt-play: the install step is
cd .. && bin/vercel-install-web, which installs Rust (rustup, minimal profile, into the build’s home) with thewasm32-unknown-unknowntarget, wasm-bindgen-cli at the version inrust/Cargo.lock(the release binary, checked against its SHA-256;cargo installonly when there is none for the machine), runsbin/build-wasm, thennpm ciinweb/. The build step isnpm run buildintodist/.web/vercel.jsonanswers/canasta,/canasta/*,/online,/join/*and/table/*withindex.html, serves*.wasmasapplication/wasmand caches/assets/*(hashed) for a year. The script keeps tools already present, sobin/vercel-install-webruns the same on a dev machine.
After the first deploy
- homefelt-play: the build log shows
Installed wasm-bindgen …and thecanasta_wasm_bg.wasm: … bytesline.https://homefelt-play.vercel.appopens the Homefelt home, its Canasta card opens/canasta, and a solo game deals and plays there.curl -sIon the.wasmunder/assets/(its name is in the Network tab) showscontent-type: application/wasmandcache-control: public, max-age=31536000, immutable;/canasta,/online,/join/xand/table/xanswer 200 with the app, not Vercel’s 404. - homefelt:
https://homefelt.vercel.apploads in light and dark,/canastashows the screenshots, “Play in your browser” openshttps://homefelt-play.vercel.app/canasta, and the page source’s canonical link starts withhttps://homefelt.vercel.app. - Both projects’ production addresses are public; Vercel Authentication (the default deployment protection) asks for a Vercel login on branch previews only.
Online play needs the game server (“Game server” below). Until homefelt-play is built with
VITE_SERVER_URL, it offers solo and same-screen play only. The server lists the play address in
its HOMEFELT_WEB_ORIGINS (fly.toml sets https://play.homefelt.io), and both stay on the same
site, since the refresh cookie is SameSite=Strict (web/README.md “Online play”).
Custom domains
homefelt.io is the main domain and homefelt.co redirects to it (#104); both are registered at
Namecheap.
-
Vercel, project
homefelt, Settings, Domains:- add
homefelt.ioand keep it as the primary domain (no redirect); - add
www.homefelt.io,homefelt.coandwww.homefelt.co, each set to Redirect tohomefelt.iowith 308 Permanent Redirect.
- add
-
Vercel, project
homefelt-play, Settings, Domains: addplay.homefelt.io(no redirect). -
Namecheap, Domain List, Manage, Advanced DNS, for
homefelt.ioand forhomefelt.co: add the records each Vercel Domains page shows for that name, and remove Namecheap’s parking records (the defaultCNAME wwwtoparkingpage.namecheap.comand theURL Redirecton@). Typically:homefelt.io: anArecord, host@, to Vercel’s IP;CNAMErecords, hostswwwandplay, to Vercel’s DNS target;homefelt.co: anArecord, host@, to Vercel’s IP; aCNAMErecord, hostwww, to Vercel’s DNS target.
Copy the exact values from Vercel’s Domains page rather than from here: Vercel shows the IP and the target per project and may change them. Wait until each domain shows Valid Configuration in Vercel; Vercel issues the certificates itself.
-
Vercel, project
homefelt, Settings, Environment Variables, Production only:PUBLIC_PLAY_URL=https://play.homefelt.ioandSITE_URL=https://homefelt.io. Then Deployments, the latest production deployment, Redeploy: the values are read at build time. -
Keep the Preview environment at
PUBLIC_PLAY_URL=https://homefelt-play.vercel.appandSITE_URL=https://homefelt.vercel.app, so a branch preview never sends people to production. If those variables were created for all environments, edit each one so thehomefelt.iovalue applies to Production and thevercel.appvalue to Preview.
Check: https://homefelt.io loads, its canonical link starts with https://homefelt.io, and “Play
in your browser” opens https://play.homefelt.io/canasta; curl -sI https://homefelt.co,
https://www.homefelt.co and https://www.homefelt.io answer 308 with
location: https://homefelt.io/.
Docs site
docs-site/ is a Starlight site that renders docs/ in place, plus spec/README.md, the two
spec/protocol/ files and web/README.md as Reference pages, all read at build time (nothing is
copied into git). docs/architecture-map.html is served as it is, at /architecture-map.html. It is private: only members of the Vercel team can open it, production
included. docs-site/vercel.json sets the install (npm ci), build (npm run build) and output
(dist), and marks every page noindex.
- Vercel, at vercel.com/new in the Salitre team: Import Git Repository,
EdSancha/homefelt. Project Namehomefelt-docs. Root Directory: Edit, thendocs-site. Framework Preset: Astro. No environment variables. Deploy. - Settings, Build and Deployment, Root Directory: turn on Include files outside the root
directory in the Build Step. The build reads
../docs,../specand../web; without it the pages are missing. - Settings, Domains: add
docs.homefelt.io(no redirect). - Namecheap, Domain List,
homefelt.io, Manage, Advanced DNS: add aCNAMErecord, hostdocs, with the value Vercel’s Domains page shows fordocs.homefelt.io. Wait for Valid Configuration in Vercel. - Settings, Deployment Protection: Vercel Authentication on, for All Deployments. Standard Protection covers previews only and leaves production public, so pick the option that covers production too. Save.
Check, signed out of Vercel (a private window): https://docs.homefelt.io and
https://homefelt-docs.vercel.app both ask for a Vercel login instead of showing the docs. Signed
in: the front page loads, search finds “Postgres”, and Architecture shows its two diagrams.
Game server
The game server (rust/canasta-server, server.md) runs on Fly.io as the app
homefelt-api, from rust/canasta-server/Dockerfile and the repository’s fly.toml, and keeps
its data in a Neon Postgres project. Both are in US East. Why: decision
0012. The accounts, the payment and the
secrets are Eduardo’s (#133, section 9); the
commands below run from the repository root on a Mac signed in with fly auth login.
One machine, always. The tables live in the server’s memory. Never run fly scale count above
1, never deploy with --ha, and never switch [deploy] to bluegreen or canary: two machines
would run the same table twice (fly.toml says why).
The image
docker build -f rust/canasta-server/Dockerfile -t homefelt-api . from the repository root builds
it. It is a release build without the dev-auth feature (POST /auth/dev answers 404, and
HOMEFELT_DEV_AUTH stops it from starting), runs as a non-root user, holds spec/rulesets at
/app/spec and listens on 8080. .dockerignore keeps everything but rust/ and spec/rulesets/
out of the build. fly deploy builds the same image on Fly’s builders.
First deploy
-
Neon. A project
homefeltin AWS US East (N. Virginia), Postgres 17, databasehomefelt. Take the direct connection string (Connection details, with “Connection pooling” off): the server prepares every statement and runs its own migrations, which a transaction pooler breaks (server.md, “Postgres connection findings”). Setsslmode=verify-full(Neon showsrequire): the server then checks Neon’s certificate and host name as well as encrypting. Neon’s certificates chain to Let’s Encrypt’s ISRG Root X1 (Neon docs, connect securely), which is in the Mozilla roots sqlx builds in (webpki-roots), so the image needs no certificate file. Dropchannel_binding=requireif Neon adds it (sqlx ignores it with a warning). If the first deploy logs a certificate error instead ofdatabase connected, fall back tosslmode=requireand open an issue. Keep the string in 1Password (“Homefelt Neon DATABASE_URL”), nowhere else. -
The app.
fly apps create homefelt-api(any free name; then changeappinfly.toml). -
Secrets. They come from 1Password and go straight to Fly through standard input, so they never appear on a command line, in the shell history, in the repository or in a chat. Make the signing key, save it in 1Password (“Homefelt server token key”), and delete the local file:
openssl genpkey -algorithm EC -pkeyopt ec_paramgen_curve:P-256 -out /tmp/homefelt-token-key.pem, attach or paste it into the 1Password item, thenrm /tmp/homefelt-token-key.pem. Then, with the 1Password CLI signed in (op signin), and each item’s secret reference copied from 1Password (“Copy Secret Reference”):Terminal window {printf 'DATABASE_URL=%s\n' "$(op read 'op://Private/Homefelt Neon DATABASE_URL/credential')"printf 'HOMEFELT_TOKEN_KEY="""%s"""\n' "$(op read 'op://Private/Homefelt server token key/homefelt-token-key.pem')"} | fly secrets import --stageThe command line holds only the references;
printfruns inside the shell, so the values never show up inpseither. The triple quotes keep the key’s line breaks.--stagekeeps the secrets for the first deploy instead of starting a machine now, andfly secrets listshows their names and digests, never the values. Sign-in settings (#48) are added the same way later (server.md, “What Eduardo configures”). -
Deploy.
fly deploy --ha=false. Without--ha=falsethe first deploy makes two machines. Thenfly scale count 1andfly statusshow exactly one machine, iniad, with its health check passing. The log (fly logs) showsdatabase connected migrated=trueandlistening. -
Check.
curl https://homefelt-api.fly.dev/healthanswers{"ok":true}. -
Domain.
fly certs add api.homefelt.ioprints the records to add. At Namecheap, Advanced DNS forhomefelt.io: aCNAME, hostapi, tohomefelt-api.fly.dev(or theAandAAAArecords Fly shows, if it asks for them), plus the_acme-challengeCNAMEif Fly shows one.fly certs check api.homefelt.ioturns to “Ready” once Fly has the certificate. -
Check again.
curl https://api.homefelt.io/healthanswers{"ok":true}. -
The web client. Vercel, project
homefelt-play, Settings, Environment Variables, Production only:VITE_SERVER_URL=https://api.homefelt.io, then redeploy (it is read at build time). Previews stay without it, so a branch preview never signs into production. Online play signs in once #48’s Apple and Google settings are on both sides.
Later deploys, logs and rollback
- Deploy:
fly deployfrom an up-to-datemain. The rolling strategy stops the machine, which saves every table and closes its players with 1001, then starts the new one: a few seconds offline. Players reconnect on their own. Migrations run as the new machine starts. - Logs:
fly logs(live) and the Fly dashboard’s Monitoring tab.RUST_LOGinfly.tomlsets the filter. - Rollback:
fly releases --imagelists the images;fly deploy --image <image>puts an older one back. A migration is never edited or undone (server.md, “Persistence”), so roll back only to an image whose migrations are a prefix of the database’s. - Settings: non-secret ones are
[env]infly.toml(deploy to apply); secrets arefly secrets set/fly secrets list(setting one restarts the machine). - Outdated apps:
HOMEFELT_MIN_CLIENT_VERSIONS(ios=YYYY.M.D,android=YYYY.M.D) turns away an app older than its platform’s minimum withupdateRequired(close 4426); the apps show their update message. Set it withfly secrets set, the day the feed’s required-update block goes out (docs/app-status.md, case 2). Unset, no app is turned away for its version; a hello from another protocol major or withoutclientis refused either way. After the first deploy, check it from the Mac with a hello naming an old version (#133, section 9b).- Setting it restarts the machine (a few seconds offline, every table saved first), and the
server checks the value at start-up: a malformed one (
ios=2027.04.1,mac=…, a platform twice) stops it from starting, for everyone. Check the value first with the local server:HOMEFELT_MIN_CLIENT_VERSIONS='ios=2027.4.1,android=2027.4.1' bin/devmust start (it prints the error and exits otherwise). If a bad value got through,fly secrets unset HOMEFELT_MIN_CLIENT_VERSIONSbrings the server back. - Deploy the web first. A web build that sends
clientworks against an older server, which ignores the field; a server that requiresclientrefuses an older web build. So when a change touches the hello, deploy Vercel production first and the server after. A server deployed first refuses every open tab until it reloads (the tab shows the update card with Reload). - Previews: a Vercel preview of a branch from before this rule sends no
client, so against the production server it shows the update card. Use a branch that includes it, or a local server.
- Setting it restarts the machine (a few seconds offline, every table saved first), and the
server checks the value at start-up: a malformed one (
- Client IPs: every per-IP limit reads
Fly-Client-IP(HOMEFELT_CLIENT_IP_HEADER).HOMEFELT_TRUST_PROXYstays off: on Fly the lastX-Forwarded-Forentry is the app’s own address, not the client’s. Fly’s proxy addsFly-Client-IPwith “the IP address of the client from the perspective of Fly Proxy” (Fly docs, request headers, read 25 November 2026). The docs do not say in so many words that it replaces a value the client sent, so the check below confirms it after the first deploy. Two limits:- The private network. The machine also listens on Fly’s private network
(
homefelt-api.internal), where requests skip the proxy. Anything in the same Fly organisation (another app,fly proxy, a WireGuard peer) can send anyFly-Client-IPthere. Keep the organisation for Homefelt only, with no other apps and no shared WireGuard peers. - The check. After the first deploy, send more than
HOMEFELT_AUTH_PER_MINUTE(20) requests in a minute with a forged header, from the Mac:for i in $(seq 1 25); do curl -s -o /dev/null -w '%{http_code} ' -X POST -H 'Fly-Client-IP: 9.9.9.9' https://api.homefelt.io/auth/refresh; done. The last ones answer429, andfly logsshowsauth request rate limitedwithip=the Mac’s public address (curl -s https://ifconfig.me), not9.9.9.9. If it shows9.9.9.9, Fly passes the client’s header through: unsetHOMEFELT_CLIENT_IP_HEADER(every client then shares the proxy’s address) and open an issue.
- The private network. The machine also listens on Fly’s private network
(
Backups and restore
Neon keeps a point-in-time history of the database (the window depends on the plan). To restore,
in the Neon console, Restore, pick a time and restore to a new branch, check it, then point
DATABASE_URL at it with fly secrets set (or restore the main branch in place). Before risky
work, a branch in the console is a free copy.
Cost
About $3–10 a month at family scale (checked 25 November 2026): the one shared-cpu-1x machine
with 512 MB is a few dollars, and Neon’s free plan (100 compute-hours a month per project, scaling
to zero when nobody plays) may cover the database; past it, Neon bills about $0.106 per
compute-hour. Fly’s dashboard and Neon’s Usage page show the real numbers.
Watching the server
The rule for growing past one machine, and the $25-a-month ceiling, are decision 0017.
Metrics. The server serves Prometheus metrics on port 9091 (src/metrics.rs), which Fly’s
managed Prometheus scrapes through fly.toml’s [metrics]. They never reach api.homefelt.io: the
public proxy routes only port 8080. In the Fly dashboard, the app’s Metrics page opens Grafana;
useful queries:
| What | Query |
|---|---|
| An evening’s peak connections | max_over_time(homefelt_connections_peak[6h]) over 18:00–24:00 your time |
| Connections now | homefelt_connections_open |
| Tables in memory | homefelt_tables_in_memory |
| Moves a minute | rate(homefelt_moves_total[5m]) * 60 |
| Refusals by code | sum by (code) (rate(homefelt_refusals_total[1h])) |
| Slowest moves (p95) | histogram_quantile(0.95, sum by (le) (rate(homefelt_move_seconds_bucket[5m]))) |
| Slowest saves (p95) | histogram_quantile(0.95, sum by (le) (rate(homefelt_save_seconds_bucket[5m]))) |
| Move log behind | homefelt_move_log_queue_depth and increase(homefelt_move_log_retries_total[1h]) |
homefelt_connections_peak is the most open at once since the previous scrape, so a burst between
two scrapes still counts. For the scaling rule, write down each evening whose peak passed 100.
Alerts on the phone (ntfy). Two senders post to one private ntfy topic:
- The server (
src/notify.rs), from inside:connectionsHigh(100 open connections),moveLogBehind,moveLogConflict,tableDamagedandinviteFailures, each at most once every 30 minutes. WithoutHOMEFELT_NTFY_TOPICit sends nothing. - The outside check (
site/api/health-check.ts), a Vercel Function in the marketing site’s project, so it still runs when Fly is down. It asks/health, tries again 20 seconds later on a failure, and sends “server down” after two failures in a row (again an hour later while it lasts) and “server back” when it recovers. It keeps no state of its own: the last notice on the topic says whether the server was last reported down.
The pinger. Vercel Hobby runs crons only once a day, so a free external pinger calls the
check every 5 minutes instead (Eduardo, 2026-11-26; site/vercel.json has no crons). On
cron-job.org:
- A free account; a new cron job with the URL
https://homefelt.io/api/health-check/(with the trailing slash: the site redirects paths without one), every 5 minutes, method GET. - Advanced, Headers:
Authorization=Bearerfollowed by theHEALTH_CHECK_SECRETvalue. - Notifications: off. ntfy does the alerting; the pinger only knocks.
- The function answers 401 without the secret, and
{"outcome":"up"}(orstillUp,down,stillDown,recovered) with it.
Setting it up is in #133, section 9b: install the ntfy app, subscribe to a long random topic,
fly secrets import the topic (HOMEFELT_NTFY_TOPIC), set HOMEFELT_NTFY_TOPIC and
HEALTH_CHECK_SECRET in the Vercel project of the marketing site, and create the pinger.
Testing an alert.
- From the Mac:
curl -d "test" "https://ntfy.sh/$(op read 'op://Private/Homefelt ntfy topic/password')"rings the phone. - The outside check:
curl -H "Authorization: Bearer $(op read 'op://Private/Homefelt health check secret/password')" https://homefelt.io/api/health-check/answers{"outcome":"up"}with the server up. Thenfly machine stopit (in a quiet moment): the pinger’s next call, within 5 minutes, sends “server down”;fly machine start, and the next one sends “server back”. cron-job.org’s “Run now” does the same without waiting. - The server’s own alerts:
HOMEFELT_ALERT_CONNECTIONSis an[env]value, so set it to 1 in fly.toml, deploy, open one game (the phone rings), then set it back to 100 and deploy again.
Spending. The ceiling is $25 a month across Fly, Neon and Vercel; nothing scales on its own, and none of the three has a hard cap that would do it for us:
- Vercel: the marketing site and the web game are on Hobby, which is never billed (Spend Management exists only on Pro).
- Neon: on the free plan nothing is billed. On Launch, Billing has spending notifications: an email to the organization’s admins at 80% and 100% of a monthly amount; they do not stop usage (Neon: spending notifications, opened 2026-11-26). Set it to $10.
- Fly: no spending limit; the billing dashboard shows the month’s running total on the preview invoice (Fly community: billing cap, opened 2026-11-26). Check it monthly; at about $3–10 expected, a figure past $15 means look.
Not yet
Deploys are run by hand from the Mac while GitHub Actions is down (#53). A deploy workflow on
merges to main is issue #225.