Sunday, April 21, 2013

How to deploy a Rails app to Heroku on openSUSE 12.3


One of the most easy ways to deploy a Rails application for use by others is Heroku. They provide Rails on their platform as a service. Their most basic plan is free, but it usually is enough for development and use for testing. You can then scale up to production use by paying for additional services and capacity. You just push your code, and Heroku takes care of running all the services needed to actually serve the application.

They have an excellent guide about Getting Started with Rails 3.x on Heroku. If you follow these steps you'll quickly have your app running in the cloud. There are a few things which are specific to when you do it on openSUSE 12.3. Here is a quick summary.

Heroku uses PostgreSQL as database backend. To minimize problems caused by divergencies in environments it's a good idea to also use PostgreSQL on your local development system. I wrote a separate guide How to run Rails with PostgreSQL on openSUSE 12.3, which explains how to do that on openSUSE 12.3.

Heroku provides a client, which you can use to manage your apps. For openSUSE 12.3 you'll need the standalone version. Install it following the instructions. To make it accessible on the command line just as "heroku", create a symlink to your local bin directory:
sudo ln -s /usr/local/heroku/bin/heroku ~/bin/heroku
Login to Heroku with
heroku login
and follow the instructions from the Heroku guide.

If you already have the app created on Heroku, you can connect your local git checkout to it by doing
git remote add heroku git@heroku.com:APPNAME.git
Replace APPNAME by the name of your application on Heroku.

You can then deploy by
git push heroku master
If you follow the recommendation of the Heroku guide to use Unicorn as web server and Foreman to run it locally, you need to make bundler available under the "bundle" command, otherwise Foreman will not start:
sudo ln -s /usr/bin/bundle1.9 /usr/bin/bundle
Then you can start your application locally with
foreman1.9 start
and you can access it at localhost:5000.

That's it. Have fun deploying your Rails application to Heroku on openSUSE.

2 comments:

  1. I have the file heroku and the program installed, but still having a problem:
    dj@linux-0bov:~/rails-dev-box> heroku login
    If 'heroku' is not a typo you can use command-not-found to lookup the package that contains it, like this:
    cnf heroku
    dj@linux-0bov:~/rails-dev-box>


    Any help??

    ReplyDelete
    Replies
    1. You have to put the heroku binary into a path which is automatically searched by the shell. That's what the first command in the instructions is doing, linking it from /usr/local/bin to the bin directory in your home directory, which is already included in the shell search path.

      Delete

Team Profile

What makes a great team? One important factor is that you have a balanced set of skills and personalities in the team. A team which only con...