shit.cx

The shit.cx Infra

2020-10-30T02:46

Today I've stood up a Gemini server for the first time. I've really enjoyed the process. So far it has been easy and super fast.

Agate was the first server I tried. It gave me no reason to look at alternatives so I haven't. I'm very happy with it. It's distributed as a Rust binary which is small enough to commit directly into the repo. This has made deployments very easy.

I threw together a template that is used by a Make target to generate new pages.

${DOCUMENT_DIRECTORY}:
        mkdir -p $@

${DOCUMENT_LOCATION}: template/article.gmi.template | ${DOCUMENT_DIRECTORY}
        @envsubst < $< > $@

A script creates index.gmi which links out to the articles.

#!/usr/bin/env bash
content_dir=$1
cd ${content_dir}

files() {
  find . -iname \*.gmi -not -iname index.gmi
}

file_heading() {
  grep -m1 "^##\ " $1 | sed -E 's/^##\ +//'
}

file_created() {
  str=$(awk '/^created_at:/ { print $2 }' $1)
  date --date="${str}" +%s
}

for f in $(files); do
  epoch=$(file_created $f)
  date=$(date --date=@${epoch} +%Y/%m/%d)
  heading=$(file_heading $f)

  echo "${epoch} => $f [${date}] ${heading}"

  unset date
  unset epoch
  unset heading
done | sort -n -r | awk '{ gsub(/^[0-9]*\ /,"", $0); print $0 }'

I then spun up a Linode and deployed it.

deploy:
        ssh shit.cx "bash -c 'cd /usr/local/src/shit.cx && git pull && systemctl restart agate.service'"

I then setup DNS and a health check with Route 53.

So within a few hours, I've built and deployed a blogging tool. This has been fun and so easy. It's refreshing that so much complexity is omitted.

agate
More Posts Like This
Return to Homepage

The content for this site is CC-BY-SA-4.0.