I recently decided to switch my Rails hosting platform. I started Rails using a shared hosting solution from domainFACTORY. That solution did not quite fill my needs so i decided to give Heroku a try.
Switching to Heroku is an easy taks, at least if you know what you’re doing…
The heroku documentation is pretty decent. You will find almost everything very well explained.
So I provide just a little wrapup of the steps I went through for integrating an existing Rails application:
# install heroku gem
gem install heroku
# go to your rails folder
# skip git initialization if your app is already under versioncontrol
git add .
git commit -m "new app"
# create a heroku app with the name of your app unless you already have one
# the first call to heroku automatically prompts for your ssh public key
# enter your heroku and ssh credentials
# heroku will automatically add heroku git repository as a remote
heroku create yourappname
# check that heroku is added
# add heroku remote manually if it's missing
git remote add heroku email@example.com:yourappname.git
# push your changes to heroku and automatically start your app with this
git push heroku master
# check logs
# if the app crashes, most of the times
# it is a missing .gems file that heroku uses for gem-management
Configuring the domain
Once the app is up and running, the next step is to get the custom domain working with Heroku. Heroku provides serveral solutions for this task. The most flexible way seems to be the Heroku-Zerigo integration.
You only have to add the Zerigo name servers to your domain as an NS (name server) naming entry. For my domain www.phoet.de this looks like this:
www.phoet.de NS a.ns.zerigo.net
www.phoet.de NS b.ns.zerigo.net
www.phoet.de NS c.ns.zerigo.net
www.phoet.de NS d.ns.zerigo.net
www.phoet.de NS e.ns.zerigo.net
It takes some time until the changes are propagated through all the name servers. You can check it using the host command:
# www.phoet.de is an alias for proxy.heroku.com.
# proxy.heroku.com has address 18.104.22.168
# proxy.heroku.com has address 22.214.171.124
# proxy.heroku.com has address 126.96.36.199
The Heroku addons take care of the rest, no setup or whatever:
# add the custom-domain addon
heroku addons:add custom_domains:basic
# add the zerigo-dns addon
heroku addons:add zerigo_dns
# add your domain to heroku
heroku domains:add www.yourdomain.com
I write these lines, because I did not manage to do this withouth the fast Heroku support.