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.
- A working spree application. If you want to know how to create one, read my previous post about creating a spree application.
- Working Heroku Account. If you don't already have one, sign up here.
- git client. On Ubuntu this can be easily installed using aptitude.
- 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.
- 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”
- 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
- Push your changes to heroku
$ git push heroku master
- Initialize your database
$ heroku run bundle exec rake db:migrate
$ heroku run bundle exec rake db:seed