Skip to content

Instantly share code, notes, and snippets.

@underhilllabs
Last active December 7, 2023 16:19
Show Gist options
  • Save underhilllabs/0310ab13e5db108e6a2f to your computer and use it in GitHub Desktop.
Save underhilllabs/0310ab13e5db108e6a2f to your computer and use it in GitHub Desktop.
Setting up a Sinatra app on Dokku

There are a few additional steps I noticed to setting up a Sinatra app to work on Dokku. (These are probably also required for deploying an app to Heroku.)

original app.rb

require 'sinatra'

get '/' do
  "Your Sinatra app is not quite Dokku-fied!"
end

1. Add a Gemfile

Dokku/Docker complains if you do not specify an https source and a ruby version.

source "https://rubygems.org"
gem 'sinatra'
gem 'thin'
ruby '2.0.0'

2. run bundle install to generate Gemfile.lock

bundle install

3. Add a Rack configuration file: config.ru

require './app'
run Sinatra::Application

4. (optional) add a Procfile to tell dokku to use Thin instead of Webrick Procfile

web: bundle exec thin start -p $PORT -e $RACK_ENV

5. Move inline templates to views/ view/welcome.erb

<h2>Welcome to Dokku</h2>
Your Sinatra app is Dokku-fied!

and update app.rb to call new template

require 'sinatra'

get '/' do
  erb :index
end

6. add these to the git repo and push

git push dokku master
@joenas
Copy link

joenas commented Jun 19, 2017

Awesome!

@gn-spawn
Copy link

gn-spawn commented Feb 6, 2018

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment