Cristiano Betta

Your mini-Heroku with Dokku and Dokkufy

I’ve always enjoyed Heroku but there are plenty of reasons both monetary and practical not to use it. I always liked the deployment method through Git though.

So this weekend at LeedsHack I started to look into Dokku, an open source mini-Heroku powered by Docker, Buildstep and some other bits that share infrastructure elements with Heroku.

I found the installation rather tedious and as this was a hackathon I decided to create something simpler.

Introducing Dokkufy

Dokkufy is a Ruby gem that makes it super simple to set up your own mini-Heroku on your own server.

Simply install with a swift gem install dokkufy and you’re ready to “dokkufy” both your server and your app.

Part 1: Dokkufying your server

Dokku only works with Ubuntu 12.04 and 14.04 server, so go get one of those images and boot up a server.

Then on your local machine run:

As you can see this will ask you for a few details: server name or IP, username, and the eventual server domain to run all apps under. After a few minutes, depending on your broadband speeds, you will have a Dokku server ready do go.

Open up your server’s domain or IP in a browser and voila!

Nginx

Part 2a: Dokkufying your app

Now that we have a Dokku server ready to go it’s time to prepare your app.

I used the Heroku Node JS sample app for my example.

As you can see this simply asks for the details of your server and then adds a Git remote and writes a .dokkurc file to your app.

Now do a git push dokku master and you will see your app deployed.

Dokku will automatically create your project for you on first push and deploy your app to a subdomain of your chosen domain. In this case we deployed our app to http://node-js-sample.ppd.io.

Part 2b: Controlling Dokku

When you install Dokku on your server it gives you some handy commands. Sadly to run those from your local machine you need to perform some ssh-fu.

So to make this easier Dokkufy also comes with a local dokku command. You can use this command in any dokkufied app that has a .dokkurc file. It will automatically use that file to infer the remote server details and your app name.

 

Some final notes

That’s it for Dokkufy. I recommend running dokkufy help to see how you can explore and install plugins to install things like Postgres, Redis, and other features on your machine.

I also want to thank the awesome Jeff Lindsay for his work on Dokku and I want to highlight what seems to be the next iteration of Dokku: Flynn.

Comments