Heroku-like Deployment With Dokku And DigitalOcean
Over the weekend I sat down to play around with Docker/Dokku and was able to set up a small machine on DigitalOcean that basically offers Heroku-like deployment. It was surprisingly simple so here is some rough outline that should get you going.
Go to DigitalOcean and create a droplet (note the comments below the screenshots):
There are some unresolved problems with Dokku on Ubuntu 13+ so if you are not just playing around you might want to setup Dokku manually. After that you're ready to hit the create button and a droplet will be created within the next minute. The last bit of server-setup that’s required is Dokku’s.
To get to Dokku’s setup screen just steer your browser to the IP shown in the droplet’s detail view:
What you’ll see next is Dokku’s setup screen:
To get the hostname you chose earlier actually point to your machine running Dokku you need to add two A records to the zonefile of your domain. This strongly varies between domain/DNS providers so I can’t exactly say how it’d be done for yours. Whats important is that your provider supports wildcard entries. Also the value of an A record should be only the subdomain part of the hostname you set earlier, not the complete domain.
A <subdomain-of-hostname> <droplet-ip> A *.<subdomain-of-hostname> <droplet-ip> # in a zonefile it’d look like this: *.apps 10800 IN A 188.8.131.52 apps 10800 IN A 184.108.40.206
After you’ve waited three hours for DNS servers to propagate the changes you should be able to do something like the following:
git clone firstname.lastname@example.org:heroku/node-js-sample.git cd node-js-sample git remote add digital-ocean email@example.com:nodeapp git push digital-ocean master
Now going to
nodeapp.<dokku-hostname> should bring up “Hello World” from the app we just cloned and pushed.
If you want to add have a custom domain point to your app you'll need to either push to a remote like
firstname.lastname@example.org:example.com or edit the nginx.conf that comes with Dokku’s nginx plugin.
Thanks to Dokku’s Buildstep that utilizes Heroku’s opensource buildpacks you can now deploy almost every application you can deploy to Heroku to Dokku as well.