Skip to content

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:

  1. 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).
  2. Project Name: homefelt, or homefelt-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.
  3. Root Directory: Edit, then site, or web.
  4. Framework Preset: Astro, or Vite (detected; vercel.json sets it too). Leave Build, Output and Install settings alone: vercel.json overrides them.
  5. 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) and SITE_URL=https://homefelt.vercel.app (canonical URLs; without it they say homefelt.io). Production gets the homefelt.io values once the domains are on (“Custom domains”).
    • homefelt-play: none at first. VITE_SERVER_URL comes once the game server answers (“Game server”, step 8).
  6. Deploy.
  7. 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 ../rust and ../spec.

What the builds do

  • homefelt: npm install, then astro build into dist/. site/src/theme.generated.css is committed, so the build needs no Python. site/vercel.json caches /_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 the wasm32-unknown-unknown target, wasm-bindgen-cli at the version in rust/Cargo.lock (the release binary, checked against its SHA-256; cargo install only when there is none for the machine), runs bin/build-wasm, then npm ci in web/. The build step is npm run build into dist/. web/vercel.json answers /canasta, /canasta/*, /online, /join/* and /table/* with index.html, serves *.wasm as application/wasm and caches /assets/* (hashed) for a year. The script keeps tools already present, so bin/vercel-install-web runs the same on a dev machine.

After the first deploy

  • homefelt-play: the build log shows Installed wasm-bindgen … and the canasta_wasm_bg.wasm: … bytes line. https://homefelt-play.vercel.app opens the Homefelt home, its Canasta card opens /canasta, and a solo game deals and plays there. curl -sI on the .wasm under /assets/ (its name is in the Network tab) shows content-type: application/wasm and cache-control: public, max-age=31536000, immutable; /canasta, /online, /join/x and /table/x answer 200 with the app, not Vercel’s 404.
  • homefelt: https://homefelt.vercel.app loads in light and dark, /canasta shows the screenshots, “Play in your browser” opens https://homefelt-play.vercel.app/canasta, and the page source’s canonical link starts with https://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.

  1. Vercel, project homefelt, Settings, Domains:

    • add homefelt.io and keep it as the primary domain (no redirect);
    • add www.homefelt.io, homefelt.co and www.homefelt.co, each set to Redirect to homefelt.io with 308 Permanent Redirect.
  2. Vercel, project homefelt-play, Settings, Domains: add play.homefelt.io (no redirect).

  3. Namecheap, Domain List, Manage, Advanced DNS, for homefelt.io and for homefelt.co: add the records each Vercel Domains page shows for that name, and remove Namecheap’s parking records (the default CNAME www to parkingpage.namecheap.com and the URL Redirect on @). Typically:

    • homefelt.io: an A record, host @, to Vercel’s IP; CNAME records, hosts www and play, to Vercel’s DNS target;
    • homefelt.co: an A record, host @, to Vercel’s IP; a CNAME record, host www, 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.

  4. Vercel, project homefelt, Settings, Environment Variables, Production only: PUBLIC_PLAY_URL=https://play.homefelt.io and SITE_URL=https://homefelt.io. Then Deployments, the latest production deployment, Redeploy: the values are read at build time.

  5. Keep the Preview environment at PUBLIC_PLAY_URL=https://homefelt-play.vercel.app and SITE_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 the homefelt.io value applies to Production and the vercel.app value 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.

  1. Vercel, at vercel.com/new in the Salitre team: Import Git Repository, EdSancha/homefelt. Project Name homefelt-docs. Root Directory: Edit, then docs-site. Framework Preset: Astro. No environment variables. Deploy.
  2. Settings, Build and Deployment, Root Directory: turn on Include files outside the root directory in the Build Step. The build reads ../docs, ../spec and ../web; without it the pages are missing.
  3. Settings, Domains: add docs.homefelt.io (no redirect).
  4. Namecheap, Domain List, homefelt.io, Manage, Advanced DNS: add a CNAME record, host docs, with the value Vercel’s Domains page shows for docs.homefelt.io. Wait for Valid Configuration in Vercel.
  5. 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

  1. Neon. A project homefelt in AWS US East (N. Virginia), Postgres 17, database homefelt. 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”). Set sslmode=verify-full (Neon shows require): 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. Drop channel_binding=require if Neon adds it (sqlx ignores it with a warning). If the first deploy logs a certificate error instead of database connected, fall back to sslmode=require and open an issue. Keep the string in 1Password (“Homefelt Neon DATABASE_URL”), nowhere else.

  2. The app. fly apps create homefelt-api (any free name; then change app in fly.toml).

  3. 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, then rm /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 --stage

    The command line holds only the references; printf runs inside the shell, so the values never show up in ps either. The triple quotes keep the key’s line breaks. --stage keeps the secrets for the first deploy instead of starting a machine now, and fly secrets list shows their names and digests, never the values. Sign-in settings (#48) are added the same way later (server.md, “What Eduardo configures”).

  4. Deploy. fly deploy --ha=false. Without --ha=false the first deploy makes two machines. Then fly scale count 1 and fly status show exactly one machine, in iad, with its health check passing. The log (fly logs) shows database connected migrated=true and listening.

  5. Check. curl https://homefelt-api.fly.dev/health answers {"ok":true}.

  6. Domain. fly certs add api.homefelt.io prints the records to add. At Namecheap, Advanced DNS for homefelt.io: a CNAME, host api, to homefelt-api.fly.dev (or the A and AAAA records Fly shows, if it asks for them), plus the _acme-challenge CNAME if Fly shows one. fly certs check api.homefelt.io turns to “Ready” once Fly has the certificate.

  7. Check again. curl https://api.homefelt.io/health answers {"ok":true}.

  8. 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 deploy from an up-to-date main. 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_LOG in fly.toml sets the filter.
  • Rollback: fly releases --image lists 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] in fly.toml (deploy to apply); secrets are fly 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 with updateRequired (close 4426); the apps show their update message. Set it with fly 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 without client is 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/dev must start (it prints the error and exits otherwise). If a bad value got through, fly secrets unset HOMEFELT_MIN_CLIENT_VERSIONS brings the server back.
    • Deploy the web first. A web build that sends client works against an older server, which ignores the field; a server that requires client refuses 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.
  • Client IPs: every per-IP limit reads Fly-Client-IP (HOMEFELT_CLIENT_IP_HEADER). HOMEFELT_TRUST_PROXY stays off: on Fly the last X-Forwarded-For entry is the app’s own address, not the client’s. Fly’s proxy adds Fly-Client-IP with “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 any Fly-Client-IP there. 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 answer 429, and fly logs shows auth request rate limited with ip= the Mac’s public address (curl -s https://ifconfig.me), not 9.9.9.9. If it shows 9.9.9.9, Fly passes the client’s header through: unset HOMEFELT_CLIENT_IP_HEADER (every client then shares the proxy’s address) and open an issue.

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, tableDamaged and inviteFailures, each at most once every 30 minutes. Without HOMEFELT_NTFY_TOPIC it 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 = Bearer followed by the HEALTH_CHECK_SECRET value.
  • Notifications: off. ntfy does the alerting; the pinger only knocks.
  • The function answers 401 without the secret, and {"outcome":"up"} (or stillUp, 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. Then fly machine stop it (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_CONNECTIONS is 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.