By

Dockerfiles for Hugo and S3 Website

In the last post we used two docker images to publish a static site, one for encapsulating our Hugo process and another for the S3 website tool. I received a few direct messages asking how to customize these images. Here’s a quick addendum to show you the Dockerfiles for both.

Hugo Image

FROM gliderlabs/alpine:latest
MAINTAINER Ahmed Alani

ENV HUGO_VERSION=0.20
RUN apk add --update \
  wget \
  ca-certificates \
  python \
  python-dev \
  py-pip \
  bash && \
  pip install pygments && \
  wget https://github.com/spf13/hugo/releases/download/v${HUGO_VERSION}/hugo_${HUGO_VERSION}_linux-64bit.tar.gz && \
  tar xzf hugo_${HUGO_VERSION}_linux-64bit.tar.gz && \
  rm hugo_${HUGO_VERSION}_linux-64bit.tar.gz && \
  mkdir -p /usr/local/bin && \
  mv hugo_${HUGO_VERSION}_linux_amd64/hugo* /usr/local/bin/hugo

VOLUME /src
WORKDIR /src

ENTRYPOINT ["hugo"]


View the GitHub Source. If you need details regarding the Dockerfile syntax, see the reference. Quick notes:

  • FROM gliderlabs/alpine:latest - We’re using alpine linux because it’s a lightweight distro (< 5MB) and gives us access to the apk package manager for installing dependencies.
  • ENV HUGO_VERSION=0.20 - This specifies the default version of Hugo we want to download. You can override this while building the image, e.g. $ docker build --build-arg HUGO_VERSION=0.XX .

s3_website Image

FROM anapsix/alpine-java:8_jdk
MAINTAINER Ahmed Alani

RUN apk add --update \
bash \
curl-dev \
ruby \
ruby-dev \
ruby-irb \
ruby-rdoc \
ruby-rake \
ruby-io-console \
ruby-bundler && \
gem install s3_website --no-ri --no-rdoc && \
s3_website install

VOLUME /src
WORKDIR /src

ENTRYPOINT ["s3_website"]

View the GitHub Source. Quick notes:

  • FROM anapsix/alpine-java:8_jdk - We’re still using alpine linux, but this comes with the Java 8 JDK pre-installed, which is a pre-requisite for s3_website.
  • gem install s3_website - We’re not specifying the version for the s3_website gem in order to grab the latest by default. This isn’t a good practice, but you can include that improvement in your own image.