How I built this
This is how I build the toolchain enabling me to quickly publish these posts. I wanted to make it easy and fun for me to write posts.
I have been using Obsidian as my main note taking app for a long time, when I came across NetworkChuck’s video on starting a blog. In the video he uses Obsidian paired with Hugo and because I like playing with different ways of using Obsidian, I thought I have to try this. Chuck’s toolchain in the video was Python, Github and Hostinger, I thought that seems like too much work for me. I have at my finger tips;
- Obsidian
- GitLab CE running on a local network server
- Docker also running on a local network server
- A good internet connection
So I thought take what Chuck is doing and what I have and merge the too. Let’s go!
I’ll leave you to watch Chuck’s video and only detail the differences here.
Obsidian
The first difference is that I use a Vault to store the raw files for this blog. There two main reasons I decided to do this. The first was to keep all my current notes separated from the blog posts, this may seem a little excessive however I like clear separations. The second reason was to ensure a context change when I decided to write. My thought was that if I had to change vaults then there is much less chance of me getting distracted.
GitLab CE
I have GitLab CE running on a local server and use this to do all the grunt work. I have built a pipeline that is triggered by a commit on a branch and then builds the Hugo site, a docker container containing the site and then deploys it to the server. This is great because I don’t have to remember how to do any of this every time I want to publish a post.
The pipeline is built in three stages;
- Build (prod-site-pages)
- Publish (prod-publish)
- Deploy (prod-deploy)
Build (prod-site-pages)
This stage pulls the commit code from the Git repository and runs the hugo
command. This results in a public folder being created that contains the compiled site and assets.
Publish (prod-publish)
This stage runs a very basic Dockerfile
that uses the nginx:alpine
images as it’s base. The contents of the public
folder created in the build stage are then copied in and assigned to the html folder for nginx.
It then pushes the build docker image to the local GitLab registry with a tag and also as the latest version.
Deploy (prod-deploy)
This stage is a fun one, on my local server it pulls the image pushed in the above stage, stops the container if it’s running and the runs a new container using the latest image. This is all done via ssh and secured using a service user account.
Below is a screenshot of the prod pipeline in action