This is the easiest configuration + deployment option. Heroku has full support for Sinatra applications. Deploying to Heroku is simply a matter of pushing to a remote git repository.
Steps to deploy to Heroku:
- Create an account if you don't have one
- Download and install Heroku toolbelt
- Make sure you have a
Gemfile. Otherwise, you can create one and install the
- Make a config.ru in the root-directory
- Create the app on heroku
- Push to it
bundlerif you haven't yet (
gem install bundler). Create a
bundle init. Modify your
Gemfileto look like:
source 'http://rubygems.org' gem 'sinatra'
bundleto install the gem.
It is possible to specify a specific Ruby version on your Gemfile. For more information, check this.
Here is an example config.ru file that does two things. First, it requires your main app file, whatever it's called. In the example, it will look for
myapp.rb. Second, run your application. If you're subclassing, use the subclass's name, otherwise use Sinatra::Application.
require "myapp" run Sinatra::Application
Create the app and push to it
From the root directory of the application, run these commands:
$ heroku create <app-name> # This will add heroku as a remote $ git push heroku master
For more details see this.