Build your own PaaS with Dokku

I was looking for some “play” deployment method for a couple of things I want to try out. Most of them require a database. And it should be cheap, cause I don’t have any load on them and don’t earn any money, so I don’t want to spend basically no money if possible. The usual suspects are too expensive – AWS, Heroku, etc.

So I looked around and found Dokku.

Dokku is a set of – hang on – shell scripts – which basically emulate Heroku on a machine of your own. It’s integrated with Digital Ocean droplets out of the box, if you want it. And the whole thing is 5 € / month, which is perfect. It also integrates with a Dockerfile based deployment, so you do git push and everything just works.

It’s amazing.

This is how you get started. But before you can get started, you need a domain you control, either on AWS or any other hoster. This is for routing traffic to your deployments later. You also need a public SSH key, or better a public / private key pair. Once you have both you can …

  1. create a Digital Ocean account, and …
  2. add your SSH public key to your account, and …
  3. in that account, create a new droplet with a “Dokku” image preinstalled.
  4. Wait until the droplet finished provisioning.

While the droplet is being created, you can also create a project locally to test it later:

In this little test project we only create a Dockerfile from an hello-world image which displays “Hello world” in a browser so we can verify it worked.

Once the droplet is done, you can start setting up your personal little PaaS. First, you have to configure your DNS. We will set up a wildcard entry for our deployments, and a non-wildcard entry for git. Let’s assume your domain is for-myself.com, then you would add …

  • my-paas.for-myself.com , type “A” (or “AAAA” if you are IPv6) to your droplet IP
  • *.my-paas.for-myself.com just the same

Then you SSH into your droplet, and create your dokku project. (This is something you have to do for every project). All you have to do for this is:

Done.

Now you configure a git remote URL for your project, and push it:

Again – done. If you push your project now (assuming DNS is already set), everything should happen automagically:

And if you open your URL now (which is hello-world.my-paas.for-myself.com) you should see this image:

Now, for 5 € / month you get:

  • A heroku-like, no-nonsense, fully automated, git-based deployment platform
  • A server which you control (and have to maintain, okay, but on which you can deploy …)
  • A database (or many of them – dokku provides great integration for databases btw; more on that in another post)
  • Publicly reachable deployments (for customers, testing, whatever)
  • Let’s Encrypt certificates (dokku provides support for these as well, again more in a later post)
  • And for 1 € more (it’s always 20% of the base price) you get backups of your system)

That’s absolutely incredible. Oh, and did I mention that the maintainers are not only friendly, but also super responsive and incredibly helpful on Slack?