Dokku meets phoenix / elixir.

Deploy whatever web app with ease – part 1

This post is about deploying your web-application using the same idea Heroku is build on. But instead we’ll be configuring our own heroku using any vps with a minimum spec of 1Gb and install Ubuntu. We won’t dive into the details of private PaaS we’ll just take an example setup (Dokku) and deploy a very simple hello World application. More like a lightning article. If you recently used dokku you can skip this article.

Awesome stuff is happening recently for us developers. I mean, we are in 2016 nothing I’m discussing here is new. I remembered when started doing web development more than 10 years ago. I remember the struggle fighting against configuring servers to run a Rails application.

Things changed, PaaS provider Heroku saved the day of a lot developers out there. If I am not mistaken it was around 2012 when the open source community started developing simple open source alternatives for heroku. Despite the fact some of the available tools aren’t suitable for production (yet) they are becoming more awesome every single day. The community is extremely active and willing to help newcomers.

To be clear this is article is not about comparing them, because I only tested Flynn and Dokku. They do the same but the focus differs. And there are lot more out there. Because I needed a way to cover our own simple internal projects and my side project I needed something that could work like I used to work with Heroku.

In my search, sometimes I was frustrated other times amazed. But now I am used to the idea of having our own PaaS at balatin.com. We use it to host different internal server side apps including ember-cli. Currently it’s already a huge win when it comes the setup of test / staging environments.

So how do you start your own private PaaS using Dokku.

Server setup

According to Dokku we need the following

  • A fresh installation of Ubuntu 14.04 x64 with the FQDN set
  • At least 1 GB of system memory

It’s important to stick to the given Ubuntu version and from experience more memory is always better.

Next we’ll install dokku using the recommended way, in this case we’ll download the bootstrap script. And make sure you read it, to know what will happen to your server. At the time of writing the most recent version is v0.4.13 make sure to have the latest stable version installed (http://dokku.viewdocs.io/dokku/installation/#installing-the-latest-stable-version).

# installs dokku via apt-get
wget https://raw.githubusercontent.com/dokku/dokku/v0.4.13/bootstrap.sh
sudo DOKKU_TAG=v0.4.13 bash bootstrap.sh

Go get some coffee now, because will take up some time depending on your VPS / Machine specs and network conditions.

When install is finished, you can visit your machine through the web browser, you can setup access (ssh) settings here by providing you public ssh key.

If somehow one of the above does not work make sure read the details at http://dokku.viewdocs.io/dokku/installation/, which also contains specific info about at providers like Linode or DigitalOcean.

Client setup and deploy

Server should be up and running now. Now we need to setup our client. In heroku’s case we would be installing our heroku-toolbelt which will help run command from the command-line.

But dokku isn’t heroku,

In this example we’ll deploy a hello-world phoenix application with a database setup backed by a postgres database. So let’s have look at our shopping list, we need to:

  • setup the application (Really this could be any kind of application)
  • add postgres support
  • reference the application to the database
  • some application specific env variables
  • add needed build-packs to support for the phoenix app
  • prepare application config to work with dokku
  • add SSL support

Great thing when it comes to a PaaS is that we don’t need to provision a machine every time we build an app. Luckily Dokku and other a-likes support heroku compatible build-packs. Build-packs are used by Heroku applications, they are used to do some additional configurations. For example; if we were deploying a Rails application, we wouldn’t need any build-pack because ruby applications are supported out the box.

There are already a lot of available build-packs out there, examples;

Chances are big some of you know or don’t know about Dokku, even if you had a look into Docker at least six months ago, I encourage you to check it out again, there is a lot of stability gained since then.

For my next part of this article we’ll show you how the setup looks like, I will prepare a short screencast for this.