How to deploy a Rails 7 app to Render

Deploying to Render


Heroku no longer has a free tier. This blog post lists the reasons why.
Heroku used to be my go-to service for experimenting with new frameworks. I would generate the starter app, and then deploy it to Heroku.
Then I would continue to incrementally build on what had been deployed.

I searched for options and came across Render and
I was particularly interested in a service that could host a Ruby on Rails app and a PostgreSQL database.
I decided to experiment with Render.

Adding the necessary files

The following files are necessary as a prerequisite to make the deployment possible;

  1. render.yaml


render.yaml is added to the root

   - name: rumblr
     databaseName: rumblr
     user: root
     plan: free

   - type: web
     name: rumblr
     runtime: ruby
     plan: free
     buildCommand: "./bin/"
     # preDeployCommand: "./bin/rails db:migrate" # preDeployCommand only available on paid instance types
     startCommand: "./bin/rails server"
       - key: DATABASE_URL
           name: rumblr
           property: connectionString
       - key: RAILS_MASTER_KEY
         sync: false
       - key: WEB_CONCURRENCY
         value: 2 # sensible default is added to bin directory

 #!/usr/bin/env bash
 # exit on error
 set -o errexit

 bundle install
 ./bin/rails assets:precompile
 ./bin/rails assets:clean
 ./bin/rails db:migrate


Sign in with GitHub

An account is required to access Render services.
I created one using Github.

Create an instance

In the Render Dashboard;

  1. Click on Blueprints

  2. Then click on the New Blueprint instance

  3. Select your repository

Deploy the app

In the deploy window;

  1. Set the value of RAILS_MASTER_KEY to the contents of config/master.key

  2. Then click, Approve

  3. Give the deployment process some time to complete

  4. The deployed app should be accessible via:


What I liked about Render

  1. The ease of connecting easily to GitHub and selecting the target repo

  2. The fact that new changes to the repo are detected and deployment takes place automatically is awesome.

What I didn't like about Render

  1. The official render tutorial for deployment didn't specify that we needed to add bin/rails db:migrate to the bin/ script.

  2. They were not clear on how to handle the Postgres database after the trial period other than stating that I had to upgrade.

  3. Sometimes, I forgot to click sync when new changes were pushed to the GitHub repo, resulting in the deployment not happening automatically.

Shout out to Silumesii for the pairing sessions to make this happen and for the idea for this blog post.