Bryan Klein

2 minute read

To simplify and improve the process of building this website, I had to make a few changes.

My previous build and delivery process (written about on this site) was based on GitLab CI/CD using a Custom Docker Image and creating GitLab Pages that were hosted on Cloudflare CDN. My new setup just uses GitLab for the code repository and Netlify for everything else.

Using Netlify is fairly common for static sites, but the thing that made mine unique and required some of the complexity of the previous setup, is that I wanted to use Madoko to build some documentation files and include the output of that process into the final website.

In the previous setup, I used a custom Alpine Linux based Docker image and installed into that the Madoko npm package. This way the image was cached and would not need to download madoko and be rebuilt each time I ran the CI/CD scripts. Then I could call the madoko command as part of the build script and it would be there ready to go when I needed it.

With a bit more understanding about how the Netlify build system works, I realized that by creating a package.json file with the madoko dependency in it, Madoko would be included in the build image that Netlify would cache for me and would be ready when I called it in the build command.

This leads to the next bit to sort out, how to call Madoko first and then Hugo to build the site. Well it turns out, it’s not that hard at all, the following is my build command in Netlify.

for filename in docs/*.mdk; do madoko -v --odir=static/html_docs $filename; done && hugo

This iterates through the docs source files and builds them to the html_docs folder in the hugo site static directory. After that hugo is run. Easy Peasy!

I did specify in the Netlify build environment variables, the HUGO_VERSION that I wanted to use. You can read more about this capability on the Netlify Blog post about it.

I removed the GitLab CI config file, the Dockerfile, the bin directory that I was putting my Hugo binaries in, and only added a new package.json file.

Now I commit the code to the GitLab repository, triggering the build on Netlify which also hosts the site. The free SSL through Let’s Encrypt that comes along for the ride with Netlify saved me $5 a month.

I saved money, time and reduced complexity. :)