Posted almost 7 years ago by Adam Wiggins
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!" end
Then create a config.ru 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 config.ru create mode 100644 hello.rb
Finally, create the app on Heroku and deploy:
$ heroku create Created http://severe-spring-77.heroku.com/ | firstname.lastname@example.org:severe-spring-77.git 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 To email@example.com:severe-spring-77.git * [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 http://severe-spring-77.heroku.com/). 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.