Deploy to Render
Render is a unified cloud to build and run all your apps and websites with free SSL, a global CDN, private networks and auto-deploys from Git, including databases!
Render tl;dr Deploy
If you simply want to experience the Render deployment process, including a Postgres or SQLite database, you can do the following:
- create a new Cedar project:
yarn create cedar-app ./render-deploy - after your "render-deploy" project installation is complete, init git, commit, and add it as a new repo to GitHub or GitLab
- run the command
yarn cedar setup deploy render, use the flag--databaseto select frompostgresql,sqliteornoneto proceed without a database [default :postgresql]. Note:sqlitestores its database file on a persistent disk, which Render's free plan doesn't support — the setup command will prompt you to confirm putting theapiservice on a paid plan before generatingrender.yaml.postgresqlandnonestay on the free plan. - commit the generated
render.yaml, then create a new Blueprint from your repo at https://dashboard.render.com/iacs - after the first deploy, replace the
destinationplaceholder inrender.yaml's rewrite rule with your api service's URL, then commit and push it.
For a more detailed walkthrough, see
Render's Deploying Redwood guide. It
predates the Cedar fork and uses rw naming throughout, but it's still the most
thorough deploy walkthrough available for this setup. Everywhere it says
yarn rw, use yarn cedar instead, and the rest applies as written.
Database Migrations
The generated render.yaml runs prisma migrate deploy as part of the api
service's startCommand (yarn cedar deploy render api, see
renderHandler.ts), right before the server starts accepting traffic. That's
intentional, and not a stand-in for a missing feature: Render has a native
pre-deploy command
(preDeployCommand in the Blueprint spec) for exactly this kind of task, but
it has two limitations that rule it out as the default here:
- Paid instances only — the pre-deploy command isn't available on Render's
free plan, but Cedar's generated
apiservice defaults toplan: free(see the tl;dr walkthrough above). - No persistent disk access — it "executes on a separate instance from
your running service" and can't reach an attached persistent disk, so it
couldn't run migrations against the
sqlitedeploy option's database file, which lives on one.
If you're on a paid plan and using Postgres (i.e. not the sqlite deploy
option), you can switch to preDeployCommand instead: move the
prisma migrate deploy call out of startCommand and into a
preDeployCommand entry on the api service in render.yaml.