Sam Debruyn

Cloud Data Solution Architect

Specialized in Microsoft Azure, Fabric & modern data stack. Microsoft Data Platform MVP. Public speaker & meetup organizer. FOSS contributor.

Sam Debruyn

Docker image for Hugo builds (with Wercker)

2 minutes

This blog is built with Hugo , which allows me to use some great CI tools like Wercker . The first part of writing a wercker.yml is picking a build container.

A build container on Wercker is the environment in which your build or deploy steps run. Wercker used to build its own containers for that, but they’ve moved away from that approach to Docker containers. You can use all kinds of Docker containers, but most people just use one available publicly on Docker Hub .

To deploy my website to GitHub pages , all I need is Git. So that’s why I built this simple Docker container with Debian and Git.

Building this blog requires some more packages. Wercker doesn’t automatically pull in your Git submodules, so Git is also a necessity there. Another one is Hugo, to build the static website itself. Hugo doesn’t minimize your files, however. That’s why I also include YUI compressor (minifies *.js and *.css) and HTML minifier (like the name says, minifies HTML files). Finally, I’ve been experimenting with HTML proofer to validate the generated HTML files and check them for dead links. All of these packages (and their dependencies) are available in my Docker container called hugo-build .

Side notes

hugo-build

The image is quite big. It needs Java for YUI compressor, Ruby for html-proofer and Node for html-minifier. Setting up the environment and storing the container each take about half a minute. If you have some suggestions on making the image smaller, please submit an issue or a pull request .

The latest list of included packages is available in the README file .

The build often fails on a time-out while running apt-get. It’s usually fixed by running another build.

html-proofer

html-proofer will often fail because it scans your website for dead links before your website is even published. I haven’t been able to work around this, but here’s an issue that’s keeping track of this.

Example wercker.yml using these images

My blog uses these images to build and deploy automatically through Wercker. The source code is publicly available on GitHub.

You might also like

If you liked this article, follow me on LinkedIn, Bluesky, or other social media to stay up-to-date with my latest posts. You might also like the following 2 posts about related topics:

Wercker step to validate Hugo themes

1 minutes

So last week, I created a material design theme for Hugo , a static site generator that I’m quite fond of](/tags/hugo/). As I discovered Wercker , an awesome CI tool, I went looking for a way to automatically validate themes. There wasn’t any, so I simply wrote a build step for Wercker .

Wercker step to minify static resources

1 minutes

I recently blogged a lot about static websites and continuous integration . There was still one step missing in my continuous integration cycle: minification. Wercker is a great CI tool and it allows you to create custom build steps that can be reused in several projects. So I created a build step to minify HTML, CSS and JS files.