Docker Image

I use wercker to automatically deploy this site. One of the nice things about wercker is that it allows for you use docker images in your builds. To keep deployment time to a minimum I’ve created a docker image with all the tools I need to build and deploy this site. Namely:

The Dockerfile itself is nothing shocking:

FROM mhart/alpine-node:latest

ENV HUGO_BINARY hugo_${HUGO_VERSION}_linux-64bit

# Install pygments (for syntax highlighting)
RUN apk update && apk add py-pygments && apk add git && apk add bash && rm -rf /var/cache/apk/*

# Download and Install hugo
ADD${HUGO_VERSION}/${HUGO_BINARY}.tgz /usr/local/
RUN tar xzf /usr/local/${HUGO_BINARY}.tgz -C /usr/local/bin/ \
	&& rm /usr/local/${HUGO_BINARY}.tgz

# Install surge client
RUN npm install -g surge

A comparison of image sizes & build/deploy speeds :

Image Size Build Duration Deploy Duration Total Duration
nodesource/trusty 62.8 MB 55s 33s 1m28s
andthensome/alpine-hugo-surge-git-bash 49.9 MB 25s 26s 51s

While 37 seconds per deployment saved might not sound like a huge deal, every second does count when it comes to continuous automated deployment (Wercker, you’re welcome).