Using Dokku and Digital Ocean to create your own Heroku

Dokku is a PaaS built with Docker and designed to act like Heroku. You can easily deploy your apps to a remote production server from the command line at a fraction of the cost. You can even use subdomains to deploy multiple apps on the same Dokku install.

Setup Rails Project

Create a new project

$ rails _4.1.8_ new PROJECTNAME

Add these lines to your Gemfile

group :production do
 gem 'rails_12factor'
 gem 'pg'
 gem 'thin'

Then run

$ bundle update
$ bundle install

Setup Dokku

You can install and run Dokku anywhere you’d like, but Digital Ocean’s 1-Click Dokku install is too good to pass up.

  • Create and name your droplet. I am currently running two apps on the smallest droplet, so any of them should work.
  • Scroll down and work through the options until you get to Select Image. Click Applications and select Dokku.
  • Note according to the Dokku Docs, you must disable IPv6 on your droplet.
  • After the install finishes, visit your droplets IP address to finish the setup.
  • Add your computer’s ssh key.
  • Select either to use the droplet’s IP address or your custom domain.
  • If you use a hostname, make sure to point your DNS to the droplet IP address for each Dokku app

Deploying Your App

Setup git for your project

$ git init
$ git add -A
$ git commit -m "Init Commit"

Add the Dokku Remote

$ git remote add dokku
$ git push dokku master

This will deploy your app to your droplet with the domain name

Setup PostgreSQL Database

SSH into your droplet and install the Postgres Plugin

$ ssh
$ cd /var/lib/dokku/plugins
$ git clone
$ dokku plugins-install

Create a Postgres container and link it to our project

$ dokku postgresql:create example-pg
$ dokku postgresql:link example example-pg

Migrate your database

$ dokku run example bundle exec rake db:migrate

Your site should be up and running! Repeat these steps for each project you put on your Dokku instance.


Check logs with

$dokku logs example