Deploy Sinatra App on Heroku

Deploy Sinatra app on Heroku

You need a Procfile file alongside your config.ru to tell Heroku how to run your app. Here is the content of an example Procfile:

web: bundle exec ruby web.rb -p $PORT

Heroku Ruby docs on Procfiles

EDIT: Here's a sample config.ru from one of my sinatra/Heroku apps:

$:.unshift File.expand_path("../", __FILE__)
require 'rubygems'
require 'sinatra'
require './web'
run Sinatra::Application

You may need to require sinatra and rubygems for it to work.

How can I deploy this Ruby/Sinatra app to Heroku?

Remove gem 'dbm' from your Gemfile.

That dbm gem only works with jruby and you don't need it since you are using yaml/dbm.

How can I deploy a Sinatra-based Ruby web app to Heroku?

When deploying from a different branch into Heroku's master branch, you need to specify the branch in the push command: git push heroku heroku:master.

Do I need a Procfile to push a Sinatra app to Heroku?

Heroku knows how to launch different types of applications by default and it tries to detect your type of app when you deploy. If you have a config.ru for example, Heroku knows you’re deploying a rack app and then rack uses that file.

A custom Procfile is needed if you want to customize the command that boots up your application, for example to run it with a different webserver or to start an additional worker process.

So: You don’t need a Procfile for default app configurations (like most Sinatra or Rails Apps for example).

More info here: https://devcenter.heroku.com/articles/procfile



Related Topics



Leave a reply



Submit