Heroku Alternative: Dokku

Dokku is advertising itself as a self hosted Platform as a service and it lives up to its promise. You can fairly easily deploy a range of applications like Ruby, Node.js, Go and so on. Basically everything beyond your standard PHP CMS like WordPress (but also that ;)).

Dokku is easy to install and maintain. Under the hood it uses docker containers to run your apps. Dokku also comes as a pre-built app as a one click installer on Digital Ocean*. Since Dokku is very easy to install, there's a couple of alternatives for you, for example Linode* or Vultr*.

Note: Dokku recommends at least 1GB or RAM.

Installing Dokku

Installing Dokku feels a bit like installing WordPress, except it just asks you for which domain you want to use and what your favourite ssh key is.

Afterwards you have a powerful, but simple command line interface available on your server, dokku:

Usage: dokku [--quiet|--trace|--rm-container|--rm|--force] COMMAND <app> [command-specific-options]

Primary help options, type "dokku COMMAND:help" for more details, or dokku help --all to see all commands.

Commands:

    apps             Manage Dokku apps
    config           Pretty-print an app or global environment
    domains          Manage vhost domains used by the Dokku proxy
    help             Print the list of commands
    ls               Pretty listing of deployed applications and containers
    [...]            [redacted many more]

Community plugin commands:

    letsencrypt   Plugin for managing letsencrypt app integration

You can always read more about a command by appending help to a sub-command like:

dokku apps:help
Usage: dokku apps[:COMMAND]

Manage Dokku apps

Example:

$ dokku apps:list
=====> My Apps
example
example2

Additional commands:
    apps:clone <old-app> <new-app>    Clones an app
    apps:create <app>                 Create a new app
    apps                              [DEPRECATED] Alias for apps:list
    apps:destroy <app>                Permanently destroy an app
    apps:list                         List your apps
    apps:rename <old-app> <new-app>   Rename an app
    apps:report [<app>] [<flag>]      Display report about an app

Creating a Dokku App

Creating an app takes two commands and a git push to the right remote, so it's really painless:

# on your dokku server
dokku apps:create clacks
dokku domains:add clacks clacks.jonathanmh.com
git remote add dokku dokku@$YOURSERVERNAME:clacks
git push dokku

and your application will start to deploy!

It will probably fail, because you'll need to define some additional settings, but they're very simple and just tell Dokku with which application your code should be started like node or which executable to run in your go project.

For Ruby it can be as simple as adding a Procfile with:

web: bundle exec puma -C config/puma.rb

See the official documentation for more: Deploying to Dokku

Note about the $YOURSERVERNAME, check out: how to define a server alias in your .ssh file

Deploying to Dokku

When deploying applications you can pick multiple methods, but they'll most likely be triggered by a git push dokku regardless of your language of choice. The two main options are using buildpacks or to use a Dockerfile.

Buildpacks (herokuish) or Dockerfiles

Since Dokku is heavily inspired by [heroku][], you can have a look at the official list of buildpacks which also are supported inside dokku. If you're not familiar with Docker, you'll probably want to make use of the buildpacks and let some automagic happen for your deployments.

On top of that, if you have very specific needs, you can even link your custom buildpacks via github / other URL to a repository.

Summary

I have not yet explored all features with Dokku and I bet I'll break my brain on one or two things along the way, but so far it's been a ton of fun!

For me Dokku is an amazing place to gather all my weird web projects in different languages without having to think about custom deployment for each server / droplet / vps they run on.

Let me know if you're interested in more in depth examples for Node, Go and other things!

  • indicates a referral link referral link
Tagged with: #Dokku #heroku #Linux

Thank you for reading! If you have any comments, additions or questions, please tweet or toot them at me!