Deploy Merb, Sinatra, or any Rack App to Heroku

The past eighteen months have seen an explosion of Rails-inspired Ruby web frameworks. Merb and Sinatra are the best known; plus many others such as Ramaze, Camping, and Waves.

That’s why we’re so pleased to announce the ability to deploy any Rack-compatible web app to Heroku.

Assuming you have a Heroku account, here’s how you can deploy a Sinatra app in about 30 seconds. Make a new directory, and inside create hello.rb:

require 'rubygems'
require 'sinatra'

get '/' do
  "Hello from Sinatra on Heroku!"

Then create a file in the same directory (the location follows the Passenger convention):

require './hello'
run Sinatra::Application

Now let’s put our microapp under revision control with Git:

$ git init
Initialized empty Git repository in /Users/adam/hello/.git/
$ git add .
$ git commit -m "sinatra and heroku, two great tastes"
[master (root-commit)]: created 93a9e6d: "sinatra and heroku, two great tastes"
 2 files changed, 9 insertions(+), 0 deletions(-)
 create mode 100644
 create mode 100644 hello.rb

Finally, create the app on Heroku and deploy:

$ heroku create
Created |
Git remote heroku added
$ git push heroku master
Counting objects: 4, done.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (4/4), 385 bytes, done.
Total 4 (delta 0), reused 0 (delta 0)

-----> Heroku receiving push
-----> Verifying repository integrity... done, looks like a Rack app.
       Compiled slug size is 0.1MB
-----> Launching....... done
       App deployed to Heroku

 * [new branch]      master -> master

Type “heroku open” at your shell (or cut-and-paste the web URL displayed when you created the app – in the example above it was Congratulations, you’re riding the Rack!

For more details, including how to deploy other frameworks or even a frameworkless Rack app, check out the docs.

Browse the blog archives or subscribe to the full-text feed.

Visit the Engineering Blog