Checklist for deploying your Rails app to production on Heroku
Last updated on December 20, 2021
Ever since I started working with my client, I had to deploy to staging and then production. On staging, even if I deploy a breaking change or I mess up something in during deployment, I have time to fix it, as nobody but me and my client will see the mess I have created.
But production is different - I have to be sure that things are going to work after I deploy. So I decided to create a quick checklist which I can follow every time I deploy my Rails app to production. Take notes.
I will assume that you are doing database migrations.
It is not necessary to do this if you are not doing any database migrations.
But if you are, you don't want any information to be lost during the deployment process. It is easy to turn maintenance mode on - head over Heroku -> Settings -> Maintenance Mode -> Switch ON.
Go to your production project on Heroku -> Resources -> Postgres database -> Durability -> Create a manual backup -> Download
This will ensure you that you have the latest version of your database after you have turned maintenance mode on. Even if you do something terribly wrong, you can go back and upload the latest stable version of your database. Then you can try again!
First checkout to master
1git checkout master
and then merge from develop to master:
1git merge develop
1git push heroku master
If you have multiple heroku apps (for example, staging and production), you will need to specify the name of the app using --app app_name.
To get a list of your heroku apps and their names, run
1heroku run rake db:migrate
1heroku run rake my_namespace:task_name
Now that you have pushed your commits, migrated and run your tasks, you can go in your settings panel on Heroku, press <mark>Reveal Config Vars</mark> and add any new environment variables that you might have added since your last deployment.
Now that everything is ready, you can go in your settings panel and turn the maintenance mode off in the same way you turned it on.
Everything should be up and running. But I always like to go and test the app is working as expected.
That's it! You can now push to deployment with confidence!
Level up your web development skills
Get articles, guides and interviews right in your inbox. Join a community of fellow developers.
No spam. Unsubscribe at any time.