Dokku: Deploying a static HTML site

In this article we will show you how to deploy a static HTML site to Dokku v0.4.5 running on DigitalOcean.

If you are new to Dokku see our previous article on how to install Dokku.

When you push a repository to your Dokku installation it will try to detect an appropriate buildpack and run it. A buildpack is just a collection of scripts that will execute while your application is being built.

For example, a buildpack might add support to PHP, while another will add support to Ruby. Dokku is compatible with Heroku buildpacks.

To serve a static HTML site you need a web server. We could use a PHP buildpack to accomplish this but I don't want the additional overhead.

We will use florianheinemann NGINX buildpack.

Specify the buildpack

Instead of letting Dokku auto-detect the buildpack we will specify it manually.

Create an .env file in the root of your repository with the following content:


Each buildpack needs to pass the detection step which determines whether the buildpack should be applied.

This buildpack checks for a .static file in the root folder so create an empty one to pass detection.

NGINX configuration

You can place the files to be served in the root of your repository or you can move them to a www folder.

To override the default NGINX configuration add a nginx.conf.erb file with your directives in the root folder of your repository.

Push your repository

Commit and push the changes to your repository.

Add the Git remote for Dokku if you haven't done that yet:

git remote add dokku dokku@host:app_name

Now push to the remote and see how the deployment goes:

git push dokku master

Managing domain names

I will not cover the details in this article on how to configure your DNS records. You just need to create A records pointing to the droplet's IP address.

In Dokku you can manage the domains for the app by using the domains plugin (it comes installed by default).

In the remote host, to see existing domains:

dokku domains app_name

To add new domains:

dokku domains:add app_name domain.tld

Type dokku to check additional commands.

Change virtualhost naming setting

For these settings to work, virtualhost naming must be enabled.

Check the current value of NO_VHOST:

dokku config:get app_name NO_VHOST

If it doesn't exist or if it's set to 0 you don't need to do anything. If it is set to 1 update it:

dokku config:set app_name NO_VHOST=0

Change port number

You might have to change the port number as well.

Check the current port being used:

dokku config:get app_name DOKKU_NGINX_PORT

Set the port to 80 for example:

dokku config:set app_name DOKKU_NGINX_PORT=80

That should be it. In the next article we will see how to deploy a PHP application.

Share this

Did you like this article? Share it!

Keep up to date

Our monthly newsletter. See previous editions.

Related articles