Static File Hosting on Dokku

How To Deploy A Dokku Static Site

Dokku seems ideal for pushing static sites and small API's to. Rather
then deploying a (reatively)large VM for such small instances.

Update May 2016

It's now much simpler to ship a static site with Dokku. There is now out of the box support for static sites. All that is required is an empty .static file in the root of your project. This will download and compile nginx and serve any file from the repository. It uses the Dokku nginx buildpack. You now don't even need to put the website files in a www folder.

I prefer to place the files inside a www folder so that I'm able to have READMEs and other bits of information or assets related to the project that won't get served. Your mileage may vary.

< /Update >

Saying that it wasn't as simple as 1,2,3. I followed this useful guide
to start with,
https://www.andrewmunsell.com/blog/dokku-tutorial-digital-ocean

First issue: pushing to dokku.

fatal: 'test' does not appear to be a git repository  
fatal: Could not read from remote repository.  

Dokku needed a password for SSH access, the git remote config was
changed to root@ip.address causing this issue. Seeing as I'm using
DigitalOcean I have no passwords on the accounts. The fix was to add my
public key to dokku with the following command.

cat ~/.ssh/id_rsa.pub | ssh root@ip.address "sudo sshcommand acl-add  
dokku your_tag"  

Second Issue: Buildpacks and ENV variables

Second issue is that Dokku didn't have a way of interpreting what we wanted it to do, serve static files.
So I needed to install a dokku package

https://github.com/musicglue/dokku-user-env-compile  

Then run this as a buildpack

ssh dokku@ip.address config:set app_name  
BUILDPACK_URL=https://github.com/aaron524/dokku-buildpack-nginx  

Then create a _static.cfg file in your repo and specify the server type - I chose nginx. Push again and the site should work

If you want a free box for a month feel free to use my referal
code
.