Running worker scripts with dokku

I occasionally hack on web apps either as part of my job or just for fun, and the pattern I've settled on for most things should be pretty familiar to people:

  • nginx on the front-end of course
  • static files or an express app to serve web content
  • static json files and web apis and maybe redis to store some data
  • a preference for offline data, I really like localForage and am also excited about things like and pouchdb
  • for some apps, worker scripts running phantomjs-node to fetch data from other sources and cache them as json every once in a while.

I've been hosting these pretty ad-hoc on Linode and now Digital Ocean, but I would really prefer to be able to cheaply host multiple apps on a heroku-style system. Git deployment ftw, basically.

Last week Rob Conery posted about using dokku as a personal Heroku-style app host on Digital Ocean. I set this up fairly easily using his suggestions and this blog post, in fact the biggest issue was just DNS propagation. It's really powerful to be able to just push to a remote git repo and have everything work. The trade-off is that you have to maintain the vm to a certain extent, and it really helps if you understand the innards of Docker and Dokku a bit as well, otherwise you'll be wondering 'where are my files?', etc.

Worker Scripts? WAT

One thing that isn't obvious is how you should run worker scripts under dokku / docker. There isn't a whole lot of info for this, but what I found that worked right away was this:

  1. install the dokku-shoreman plugin, as detailed here
  2. define your worker job as per usual in your Procfile. eg:
    web: npm start
    worker: node bin/ping


In a lot of cases, all you really want is cron. This is actually much easier but isn't handled by dokku itself, see this github issue. In a nutshell, the recommendation is to define your command in your app and then run dokku run <app> <COMMAND> from cron. For my purposes ( running on a single host, no message queues, etc ) this is just simpler than fiddling around with Heroku's scheduled job stuff / clock processes.


  • ponder whether I need SSL for the entire paas. It would be expensive to get a glob cert potentially, so it requires more investigation but I'd really prefer to start encrypting everything
  • get github web hooks working somehow for continuous deployment?
  • a homepage at [] that points to the various apps available, ideally in a way so that I don't have to manually update it.
Jeff Griffiths


Jeff Griffiths

Open Web hacker and Product Manager at Mozilla.