Tuesday, January 1, 2013

Deploying a Spree application on Heroku

Heroku is a no-hassle hosting solution for Ruby, Node.js, Clojure, Java, Python, and Scala. It helps the developers to focus on the most important thing i.e creating the most amazing web app ever and forget about servers. Your application can be up and running in minutes. All you need to do is create an app on their servers and then push your code to it using git. They provide a handy utility to create and manage applications from command line and it can be installed from www.toolbelt.heroku.com.

Spree is an open source e-commerce platform that is available as a ruby gem for Ruby on Rails framework. It is intended as a foundation over which developers can build their own e-commerce sites.

Running a Spree application on Heroku is easy and can be done using the steps below.

Prerequisites

  1. A working spree application. If you want to know how to create one, read my previous post about creating a spree application.
  2. Working Heroku Account. If you don't already have one, sign up here.
  3. git client. On Ubuntu this can be easily installed using aptitude.

Steps

  1. Install Heroku Toolbelt.
    The toolbelt is a very handy utility for working with Heroku. The most important part of this toolbelt is a command line interface for creating and managing applications on Heroku server. For details and installation instructions please visit the Heroku Toolbelt website.
  2. Add your application to git version control.
    If not already done, add your app to git as this is required for pushing to Herokus servers. This is easily done using following commands:
    $ git init
    $ git add .
    $ git commit -m “initial commit”
  3. Next login to heroku from command line, add your SSH security keys to Heroku and create a new application
    $ heroku login
    $ heroku keys:add
    $ heroku apps:create myapp
  4. Push your changes to heroku
    $ git push heroku master
  5. Initialize your database
    $ heroku run bundle exec rake db:migrate
    $ heroku run bundle exec rake db:seed
And that is it. Your app should now be live at myapp.herokuapps.com. Head over to Heroku developer center for more details about this amazing platform or you can read this amazing book.

No comments: