Deploy to Render free tier with a preview per PR #233
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
spec
wayfinder:grilling
wayfinder:map
wayfinder:prototype
wayfinder:research
wayfinder:task
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
amaurycoudr/chess-project#233
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Problem Statement
The app has no deployment. Nobody can play it without cloning the repo, and a PR can't be tried in a browser before it merges.
Solution
Deploy to a single free Render web service, with automatic PR previews. The Node API serves the built front as well as
/rpc, so both share one origin, asapps/front/src/room/api/client.tsassumes. Render is configured by a committedrender.yamlblueprint. A one-off wizard script walks the owner through the dashboard setup.Why Render free over the alternatives (benchmarked in the session that produced this spec):
User Stories
/room/ABC123load the SPA too.mainis green.scripts/setup-render.shonce and it walks me through the Render dashboard, then smoke-tests the deploy.Seams
serveFront(app, { root }), tested by callingapp.fetchagainst a temporary directory fixture. It is wired inapps/api/src/index.tsonly, socreateAppstays I/O-free (ADR 0009).loadConfig(apps/api/src/config.ts) gains an optional front directory (e.g.FRONT_DIST_DIR). Unset means no static serving, so dev and e2e are unchanged.Implementation Decisions
serveStaticfrom@hono/node-server/serve-staticfor files under the front dir.GETthat is not under/rpcreturnsindex.html./rpc/*behaviour is untouched, including the origin guard and the 404 for unmatched procedures.render.yamlat the repo root, one web service:name: chess-project,runtime: node,plan: free,region: frankfurt.buildCommand: corepack enable && pnpm install --frozen-lockfile && pnpm build. Node comes from.nvmrc(24).startCommandrunsnode apps/api/dist/index.jsdirectly, notpnpm start. That way theapps/api/.env.localwritten bypostinstall(env:sync) cannot apply.ORIGIN_ALLOWLISTdefaults to Render's per-serviceRENDER_EXTERNAL_URL, which previews also get, with the preview's own URL. For example:ORIGIN_ALLOWLIST=${ORIGIN_ALLOWLIST:-$RENDER_EXTERNAL_URL} node apps/api/dist/index.js.FRONT_DIST_DIR=apps/front/dist.PORTis injected by Render.previews.generation: automatic,autoDeployTrigger: checksPass,healthCheckPath: /.scripts/setup-render.shis built from.claude/skills/wizard/template.sh, with the library above the STAGES marker untouched. Its 7 stages:render.yamlis onorigin/main.gh repo edit --homepage(behindconfirm)./, a client route, and/rpcwith an allowed origin vs a foreign one (403).confirm).Testing Decisions
serveFrontseam:/rpcpath returnsindex.html;/rpc/*is never shadowed (a foreign origin still gets 403, an unknown procedure still 404).loadConfigtests cover the new optional key.render.yamlare checked withbash -n/shellcheck and a static trace. They are not run in CI.CONTRIBUTING.md.Out of Scope
Further Notes
Unverified until the first deploy:
startCommandruns through a shell, which the${...:-...}expansion needs.The wizard's smoke test (stage 6) is what proves both. Render's docs say PR previews are "billed at the same rate as your base service", which is free for a free service. They count against the 750 free instance-hours per month.
mentioned in issue #240
mentioned in commit
3bc0188c69mentioned in commit
2bb8339615mentioned in commit
fdb3090cfementioned in commit
35887424fementioned in commit
7d8c70ce67mentioned in commit
e4afbb77f3mentioned in commit
f54b6521c5mentioned in commit
e8267d55d5mentioned in commit
5a3f7d9a6dmentioned in commit
a7d5df0d86mentioned in commit
57eeef21bcmentioned in commit
658d7acb8dmentioned in commit
32f3f5474amentioned in commit
d525aeca96mentioned in commit
033490386dmentioned in commit
859853ff40