I wanted to setup a few blogs quickly without the overhead of the Wordpress behemoth. Luckly Jekyll is just the tool for the job. If you are unfamiliar with Jekyll it is a static-site generator which allows you to develop your pages/posts as Markdown files and generate static sites from them.

Having gotten into the whole “minimal machine setup” mode recently I decided to use Jekyll by-way-of Docker and a combination of AWS CLI which allows me to just configure a nice script to build the site using Jekyll without having to install anything (except Docker of course)

The following build.sh script makes a couple of assumptions:

  1. You have an AWS config and credentials file sitting in ~/.aws
  2. You have cloned a default Jekyll site
  3. You have an s3 bucket entitled mysite.com
  4. You have a named credential setup mysite in your ~/.aws/credentials file

This build.sh file should be placed in your Jekyll site directory root:

#!/bin/bash

export JEKYLL_VERSION=3.5
export AWS_CONFIG_DIR=/home/my-username/.aws
export AWS_PROFILE=mysite
export S3_DOMAIN=mysite.com

docker run --rm \
  --net=host \
  --volume=$PWD:/srv/jekyll \
  -it jekyll/builder:$JEKYLL_VERSION \
  jekyll build &&
docker run --rm \
  -e "AWS_SHARED_CREDENTIALS_FILE=/aws-config/credentials" \
  -e "AWS_CONFIG_FILE=/aws-config/config" \
  --net=host \
  --volume=$AWS_CONFIG_DIR:/aws-config \
  --volume=$PWD/_site:/site \
  -it garland/aws-cli-docker \
  aws --profile $AWS_PROFILE s3 sync /site s3://$S3_DOMAIN

And there you have it - you can make changes to your Jekyll directory and run ./build.sh to deploy it to your S3 bucket for static-site deliciousness!