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.
In case you have any further questions, remarks or suggestions about this post, feel free to drop me a tweet or an email! You can also find me on Slack on the Xamarin Chat. I go by the username sam_d.
About the author
Sam is a C# developer who builds mobile (cross platform) apps with Xamarin. He's been a certified Xamarin mobile developer since 2016. Sam likes to experiment with all kinds of programming languages and software frameworks. More info