How is Caffeinated Coder Hosted?
Well, as part of a coding blog written by a DevOps engineer, I should probably talk about some DevOps topics. Let's start with how the heck this site is currently hosted!
So, at the time of writing, this site isn't actually live anywhere. Its also worth noting, I'm not expecting to break the internet with this blog, so I'm trying not to over-engineer my hosting solution. But with that, let's dig into it.
For starters, I am very cheap and money conscious. So at this point in my life, big name cloud providers aren't getting my credit card for fear of unexpected charges. So away I go looking for other hosting providers that may be better suited for a small hobby blog. This lead me to Netlify, who I've heard of through various software development podcasts as well as by reading through other similar blog deployments.
So right, Netlify. Now being a good DevOps engineer, I quickly googled for a Terraform provider for Netlify, or some reasonable infrastructure as code solution that made sense. What I found was an archived Hashicorp providers and a few forked versions of said provider, none of which really appealed to me as a good solution. Digging a bit deeper, I found that this topic had been discussed before on the Netlify forums, and the general consensus there was they had an API and a JavaScript library for automation purposes. However, what I was looking to do was maintain the state of my site in code, not necessarily automate the deployment and configuration of it. So for now, as much as it pains me to say this, I'll be shelving my infrastructure as code for at least this part of my site, but keep an eye out for future developments from me on this front.
Now that I had admitted defeat on one DevOps front, I wasn't going to let another one slide. That meant, I needed a decent CI/CD solution. In my day job, we typically host our code in GitLab, so I've grown rather fond of their CI/CD, and hence will be using it for this site.
Now Netlify has some nice built in CI/CD features, but for the sake of learning, I wanted to home roll a few of them. Netlify is made to basically keep a branch of your git repo in sync with the actual website. So my home rolled solution will be more focused around the "CI" portion rather than the "CD" portion. Maybe I might try to get a development deployment of this site hosted some day that feature branches get pushed to, but for now, I'm a small one dev operation. So, for a first pass at my CI-only pipeline, I wanted to start with 2 main things:
- lint/spell check my blog posts
- build my site to ensure I can actually generate a proper public folder
With that in mind, this is what I came up with:
1---
2stages:
3 - lint
4 - build
5
6spell-check:
7 stage: lint
8 image: mvochoa/cspell-checker
9 script:
10 - cspell "content/**"
11
12build:
13 stage: build
14 image: klakegg/hugo:0.89.4-ubuntu-ci
15 script:
16 - hugo
17 artifacts:
18 paths:
19 - public
I opted to start my build by using cspell to make sure I didn't have any typos in my blog posts. Cspell also provides a few nice flags that I might take advantage of later to actual try to fix your spelling mistakes for you and write them to the file in question. Cspell also offers a nice VS Code plugin so I'm using the same spell checking linting tool in my CI system and in my editor.
Now, as with most coding essays, there's going to be words that a spell checker doesn't like. Cspell has a way to specify a config file to ignore certain words or regular expressions. Now I didn't want to catch myself continuously updating a config file as I need to exclude new tech, so instead, I went with the following approach:
1{
2 "ignoreRegExpList": [
3 "(`.*`|\".*\")",
4 "```(.|\n)*```",
5 "(.|\n)*draft: true(.|\n)*",
6 "\\*\\*.*\\*\\*"
7 ],
8 "ignoreWords": [
9 "caffeinatedcoder"
10 ]
11}
The nice thing about this config, is it being in the post itself, doesn't throw off my CI pipeline. Basically we have a few parts here:
- Ignore anything in double quotes
- Ignore anything between back ticks
- Ignore any multi-line string in between triple back ticks
- Ignore any file that contains "draft: true" as those are posts I'm still working on and most likely have typos that I'll fix before publishing
- Ignore anything between double asterisks
- And of course, ignore the actual domain name for this site
The first 3 are meant to take advantage of markdown formatting to allow for me to tell cspell to ignore certain words based on how they're formatted. For example, ignoring weird strings as long as its in between triple back ticks as that's most likely going to be a code snippet.
Secondly, I needed to build my site, which in the Hugo world, is a matter of just running the hugo command. I opted to output an artifact of this build in case I wanted to pull a certain build down and test it after the fact.
Now, one not so easy decision I had to make for this blog was, what to call it. So over to Google Domains I go to try to find some inspiration. I had originally thought "basement coder" would be a good name since in my day job or personal projects, I always seem to be in the basement when I'm coding. After mentioning my blogging aspirations to my wife, she suggested "Caffeinated Coder" and as a smart husband, I said "Yes, dear" (even though I actually liked her choice better). Now caffeinatedcoder.com was taken, but I'm not one to be confined to your typical domain name endings. Luckily, caffeinatedcoder.dev was available, and isn't that way more appropriate for a coding blog?
Once I had my domain name, I needed to CNAME that to my Netlify domain. Again, I searched for a TF provider for Google Domains, but no dice. So again, I must bite my lip and create this DNS record through the UI. Now Google Domains doesn't let you create a CNAME record for the root domain, so for now, I prefixed my domain with blog. to go live and added it to the TODO list for down the road.
Finally, this wouldn't be a reputable site if I didn't have TLS enabled, but luckily, Netlify takes care of that for me too.
So, that's the current hosting situation. Am I expecting to grow out of it? Not in the slightest. But this is also my first foray into exposing myself on the internet, so maybe y'all will surprise me.