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.
I found the installation rather tedious and as this was a hackathon I decided to create something simpler.
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:
1 2 3 4 5 dokkufy server > Server hostname or IP: ppd.io > Username on server: cbetta > Desired root domain (e.g. example.com): ppd.io > ...
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!
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.
1 2 3 4 5 6 7 8 cd node-js-sample dokkufy app > Server hostname or IP: ppd.io > Dokku username on server [dokku]: > Using email@example.com:node-js-sample > Setting git remote > Writing .dokkurc > You can now push your app using `git push dokku master`
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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 git push dokku master > Counting objects: 4, done. > Delta compression using up to 8 threads. > Compressing objects: 100% (2/2), done. > Writing objects: 100% (3/3), 307 bytes | 0 bytes/s, done. > Total 3 (delta 1), reused 0 (delta 0) > -----> Cleaning up ... > remote: Cloning into '/tmp/tmp.mTjJcRME5f'... > -----> Building node-js-sample ... > remote: done. > remote: HEAD is now at 961aa4a... Adds dokkurc file > Node.js app detected > -----> Requested node range: 0.10.x > -----> Resolved node version: 0.10.30 > -----> Downloading and installing node > -----> Restoring node_modules directory from cache > -----> Pruning cached dependencies not specified in package.json > -----> Writing a custom .npmrc to circumvent npm bugs > -----> Installing dependencies > -----> Caching node_modules directory for future builds > -----> Cleaning up node-gyp and npm artifacts > -----> No Procfile found; Adding npm start to new Procfile > -----> Building runtime environment > -----> Discovering process types > Procfile declares types -> web > -----> Releasing node-js-sample ... > -----> Deploying node-js-sample ... > =====> Application deployed: > http://node-js-sample.ppd.io > > To firstname.lastname@example.org:node-js-sample > 97a7c5c..961aa4a master -> master
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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 dokku help > backup:export [file] Export dokku configuration files > backup:import [file] Import dokku configuration files > config display the config vars for an app > config:get KEY display a config value for an app > config:set KEY1=VALUE1 [KEY2=VALUE2 ...] set one or more config vars > config:unset KEY1 [KEY2 ...] unset one or more config vars > delete Delete an application > help Print the list of commands > logs [-t] Show the last logs for an application (-t follows) > plugins-install Install active plugins > plugins Print active plugins > run <cmd> Run a command in the environment of an application > url Show the URL for an application > version Print dokku's version
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.