Skip to content

Instantly share code, notes, and snippets.

@zanbaldwin
Last active December 20, 2019 19:50
Show Gist options
  • Save zanbaldwin/14e682169b8c6b7ca4b7262ee8a5752f to your computer and use it in GitHub Desktop.
Save zanbaldwin/14e682169b8c6b7ca4b7262ee8a5752f to your computer and use it in GitHub Desktop.
Compressed Docker Image (~14MiB) for Hugo Site Builder (v0.50)
FROM "golang:1.13.5-alpine3.10" AS builder
ARG HUGO_VERSION="v0.61.0"
RUN apk add --no-cache --virtual .build-deps gcc g++ git musl-dev upx \
&& git clone git://github.com/gohugoio/hugo.git \
&& cd hugo \
&& git checkout "${HUGO_VERSION}" \
&& go build -o "/tmp/hugo" -ldflags "-s -w" -tags "extended" \
&& upx --brute -o "/sbin/hugo" "/tmp/hugo" \
&& apk del .build-deps
FROM "alpine:3.10" AS clitool
MAINTAINER Zan Baldwin
# https://engineeringblog.yelp.com/2016/01/dumb-init-an-init-for-docker.html
RUN apk add --no-cache --virtual .build-deps bash gcc git libc-dev make \
&& git clone "git://github.com/Yelp/dumb-init.git" /tmp/dumb-init \
&& (cd "/tmp/dumb-init"; git checkout "$(git describe --tags)"; make) \
&& mv "/tmp/dumb-init/dumb-init" "/sbin/dumb-init" \
&& rm -rf "/tmp/dumb-init" \
&& apk del .build-deps \
&& chmod +x "/sbin/dumb-init"
ENTRYPOINT [ "/sbin/dumb-init", "--" ]
COPY --from="builder" "/sbin/hugo" "/sbin/hugo"
# May have to install other dependencies later on for Sass, Image Processing, etc.
RUN apk add --no-cache bash
CMD [ "bash" ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment