Heroku CLI Deployment of Ruby on Rails APIs powered by PostgreSQL with MacOS

Image for post
Image for post

For Girls in Tech COVID-19 hackathon project, my other three teammates and I, decided to create a finding volunteers application for children, called Help@Home, which connects children who need help with their homework and mental health with adult volunteers. I was responsible for implementing a RoR API. To make database accessible for my teammates from all over the world, I chose to deploy it using Heroku.

Before getting into the deploying part, the brief introduction of how the Help@Home backend was designed is needed. It was created with Ruby on Rails powered by PostgreSQL using self referential relationship (for more information about self referential association check out my blog here), one table for users (client & volunteer) and one join table for appointments, from which the client and the volunteer are connected. For security management, JWT, Bcrypt and dotenv are applied.

Now let’s talk about how to deploy.

  1. A free Heroku account (https://signup.heroku.com/dc)
  2. MacOS homebrew installation in command shell

( https://devcenter.heroku.com/articles/getting-started-with-ruby#set-up)

3. Once installed, we can use Heroku CLI to login to our account

4. Open the api backend folder and create Heroku repository

5. Create Procfile, which is needed for setting up the environment for Heroku (Procfile should be in the main folder, in the same folder with Gemfile)

6. Paste the following line into Procfile

7. Now we need to commit and push the changes to the repository

At this point, Heroku starts deploying the app.

8. Add token signing key/value pair in ‘.env’ file into Heroku app → settings → Config Vars

9. Run the migration

10. Now open the url to check it out (the app might take a few minutes to open. )

Ta-da! 🤩

I hope this will help you! ;)


Written by

Multi-human-lingual and multi-programming-lingual | https://www.gaierken.com/

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store