Introduction

When you're using Dokku to deploy your application or just have been browsing through their documentation, you may already stumbled upon their own implementation of Heroku's app.json file which can be used to declare some deployment tasks.

The Problem

Compared to Heroku, Dokku offers only a fraction of the functions here.

{
  "scripts": {
    "dokku": {
      "predeploy": "",
      "postdeploy": ""
    }
  }
}

Most features like mounting a persistent storage either needs to be done manually beforehand, semi-automatic through some CI/CD pipeline, server orchestration or whatever black magic you toolchain provides.

The Solution, yet another plugin

Yes. Here we are again, installing another Dokku plugin. At this point you might think Dokku is somewhat Lego type of software. But at least it's configure once - run everywhere and every-time.

As stated above, the answer is yet another plugin, this one is called dokku-require which has been created by crisward. Compared to others, this is more a swiss pocketknife than just some small extension providing one or two funny commands.

Pre-configuring instead preparing your application

Using dokku-require, your app.json feels like it received a good shot steroids - or more child-friendly - popeye's spinach. You can define:

  • plugins - Require dokku services like PostgreSQL or Redis as dependency.
  • volumes - Map Volumes directly inside your configuration.
  • predeploy & prebuild - Already well known, a core feature since v0.5.0

Every good infrastructure should be configured once, so it can automatically run everywhere. Not to be confused with Sun Microsystem's "Wrice once, run anywhere".

Your app.json then can then look like this

{
  "name": "my website",
  "description": "My website",
  "keywords": [
    "productivity",
    "HTML5"
  ],
  "website": "https://mywebsite.com/",
  "dokku":{
    "plugins":[
      "mariadb","redis"
    ],
    "volumes":[
      {"host":"/var/lib/dokku/data/storage","app":"/storage"}
    ]
  }
}

When you need more informations, just check his Readme, it's well documented and should cover every case you might think of.

... but wait... there's more!

Multiple environments - Staging, Development and more

If you did your homework, as stated in the last step, you may have seen the dokku require:mode <env> command/feature. It's exactly what you think. Multiple environments just by switching the mode using some build-in commands.

The end

That's it, We're done. If you got feedback or something on your mind, you know, just drop it! Either write me a mail at p.krason@padr.io or simply create a comment down below.