The idea for this site started when I was working with a co-worker to celebrate the 5-year anniversary of someone on our team.
Part of the celebration included a joke web-site, intended to be the “discovered” middle-school website of the celebrant. That got me looking for cool domains to buy.
Once I’d found one I had to come up something to do with the domain.
I wanted to see how far I could go using free “cloud” resources to publish a site, while at the same time making it a smooth and sustainable publishing process for something like blogging.
Free stuff this site uses:
I write a post in markdown, commit it to my Git repo, and then push to trunk. GitLab CI runs Pandoc over the content and then ships it over to a Google Cloud Storage bucket, which is exposed as a static web-site.
Rendering is a bit of a horror-show combination of Makefile and TypeScript - we do one pass over the content to build an index of posts by posting-date (to build the “recent posts” listing), and then another pass over the content with Pandoc to render HTML.
It’s all in a makefile so that when doing development we only render as much or as little as is needed - editing a post only renders that post, but editing part of the TypeScript utility will re-render everything.
I’m a make novice, but here’s an example of the rules for running Pandoc - generating HTML in an out folder from Markdown in the content folder:
site_source ?= content
site_output ?= out
PANDOC_OPTS := -f markdown -t html5 -s --template $(template) --base-header-level=2
sources := $(shell find $(site_source) -name '*.md')
htmlDocs := $(patsubst %.md,%.html,$(subst $(site_source),$(site_output),$(sources)))
$(site_output)/%.html: $(site_source)/%.md $(template)
$(@D)
mkdir -p $(PANDOC_OPTS) $< -o $@
pandoc
all: $(htmlDocs) # among other things
For hosting content, the free-tier of Google Storage is pretty great. The free-tier lets you store up to 5 GB forever, which is plenty for a personal site.
Cloudlfare offers free DNS and CDN services, which (in theory) makes it easier to stay within the “always free” tier of Google Storage, and their DNS-management page is pretty easy to use.
It was pretty easy to set up Google Storage and Cloudflare to directly serve Google Storage objects using the directions here.
GitLab offers free CI/CD runners which can run pretty much anything in a Docker container. There are probably limits on what you can do within their free services, but I haven’t run in to them on small personal projects.
The actual “publish” script, which copies the build folder to Google Storage is:
#!/usr/bin/env bash
set -euo pipefail
# Log in
echo ${G_CRED} > auth.json
gcloud auth activate-service-account --key-file auth.json
rm auth.json
# Go!
gsutil -m rsync -r -d out/ gs://xn--clich-fsa.org
And that’s the basics of it!