Docker image for Hugo builds (with Wercker)
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 .
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 .
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 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
Wercker step to validate Hugo themes
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
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.