Heroku Pro Tips 1 – Running your app in various environments

Awesome Heroku platform is Awesome. We are starting a new series of blog posts today about Ruby and Heroku Pro tips. Discover tips from Tquila Labs Team to leverage the power of Ruby and Heroku.

FormStorm.co is a SaaS application to build marketing micro-sites and Salesforce-connected forms. Last week we launched the private beta and you’re invited to take part! FormStorm is hosted on Heroku and generates consumer-facing Heroku apps on the fly. During the development process Heroku has been used to host the TEST ENV then, when ready, both STAGING and PRODUCTION ENV. Here are some tips we’ve discovered along the way.

Running your app on various ENV:

A classical approach to maintaining any app is to have 3 or 4 different environments. Each environment is backed up by a specific Git Branch and you usually end up with something like :

  • development env and branch, for local use and local work
  • staging env and branch, for Production-like test
  • Production env and branch, for the live app

This approach is common but it is not immediately obvious how to implement this on Heroku. By default you are in Production mode and only the master branch can be deployed. Here is how to recreate your various ENV on Heroku.

  • First create your apps for staging and production ENV:
heroku create --remote staging
heroku create --remote production
  • Run your app with the correct ENV

Ruby Heroku apps respect the RACK_ENV variable value. Rails apps use the RAILS_ENV variable. To change them, run this in you terminal:

heroku config:add RACK_ENV=staging --remote staging
heroku config:add RAILS_ENV=staging --remote staging
  • Deploy your branches

After that, to push your staging or production branches to Heroku do (respectively):

git push staging staging:master
git push production production:master

That command will push and merge either your staging/production branches on the corresponding remote master.

Next Pro tips on Ruby and Heroku:

  • Ruby – Testing with databasedotcoom gem
  • Heroku – Useful commands
  • Ruby – Extending your SF objects
  • Heroku – Use Thor to handle your VARS
  • Ruby – Performance boost
  • Heroku – Adding a SSL Certificate
Tagged , , , , , ,

One thought on “Heroku Pro Tips 1 – Running your app in various environments

  1. tpearce says:

    This is great thanks. More tips!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: