1
mirror of https://github.com/jakejarvis/hugo-docker.git synced 2026-01-12 20:22:56 -05:00

clear temp directories and caches in final image

This commit is contained in:
2021-04-03 09:38:06 -04:00
parent b9d9a45c6a
commit 77fc7a219c

View File

@@ -23,8 +23,7 @@ ENV GO111MODULE=on
WORKDIR /go/src/github.com/gohugoio/hugo WORKDIR /go/src/github.com/gohugoio/hugo
# gcc/g++ are required to build SASS libraries for extended version # gcc/g++ are required to build SASS libraries for extended version
RUN apk update && \ RUN apk add --update --no-cache \
apk add --no-cache \
gcc \ gcc \
g++ \ g++ \
musl-dev \ musl-dev \
@@ -51,6 +50,7 @@ FROM alpine:latest
# renew global args from above & pin any dependency versions # renew global args from above & pin any dependency versions
ARG HUGO_VERSION ARG HUGO_VERSION
# https://github.com/jgm/pandoc/releases
ARG PANDOC_VERSION=2.13 ARG PANDOC_VERSION=2.13
LABEL version="${HUGO_VERSION}" LABEL version="${HUGO_VERSION}"
@@ -62,7 +62,7 @@ LABEL maintainer="Jake Jarvis <jake@jarv.is>"
LABEL org.opencontainers.image.source="https://github.com/jakejarvis/hugo-docker" LABEL org.opencontainers.image.source="https://github.com/jakejarvis/hugo-docker"
# bring over patched binary from build stage # bring over patched binary from build stage
COPY --from=build /go/bin/hugo /usr/local/bin/hugo COPY --from=build /go/bin/hugo /usr/bin/hugo
# this step is intentionally a bit of a mess to minimize the number of layers in the final image # this step is intentionally a bit of a mess to minimize the number of layers in the final image
RUN if [ "$(uname -m)" = "aarch64" ]; then \ RUN if [ "$(uname -m)" = "aarch64" ]; then \
@@ -73,8 +73,7 @@ RUN if [ "$(uname -m)" = "aarch64" ]; then \
# alpine packages # alpine packages
# libc6-compat & libstdc++ are required for extended SASS libraries # libc6-compat & libstdc++ are required for extended SASS libraries
# ca-certificates are required to fetch outside resources (like Twitter oEmbeds) # ca-certificates are required to fetch outside resources (like Twitter oEmbeds)
apk update && \ apk add --update --no-cache \
apk add --no-cache \
ca-certificates \ ca-certificates \
tzdata \ tzdata \
git \ git \
@@ -95,16 +94,19 @@ RUN if [ "$(uname -m)" = "aarch64" ]; then \
autoprefixer \ autoprefixer \
@babel/core \ @babel/core \
@babel/cli && \ @babel/cli && \
npm cache clean --force && \
# ruby gems # ruby gems
gem install asciidoctor && \ gem install asciidoctor && \
# python packages # python packages
python3 -m pip install --upgrade Pygments==2.* docutils && \ python3 -m pip install --no-cache-dir --upgrade Pygments==2.* docutils && \
# manually fetch pandoc binary # manually fetch pandoc binary
wget -O pandoc.tar.gz https://github.com/jgm/pandoc/releases/download/${PANDOC_VERSION}/pandoc-${PANDOC_VERSION}-linux-${ARCH}.tar.gz && \ wget -O pandoc.tar.gz https://github.com/jgm/pandoc/releases/download/${PANDOC_VERSION}/pandoc-${PANDOC_VERSION}-linux-${ARCH}.tar.gz && \
tar xf pandoc.tar.gz && \ tar xf pandoc.tar.gz && \
mv ./pandoc-${PANDOC_VERSION}/bin/pandoc /usr/local/bin/ && \ mv ./pandoc-${PANDOC_VERSION}/bin/pandoc /usr/bin/ && \
chmod +x /usr/local/bin/pandoc && \ chmod +x /usr/bin/pandoc && \
rm -rf pandoc.tar.gz pandoc-${PANDOC_VERSION} && \ rm -rf pandoc.tar.gz pandoc-${PANDOC_VERSION} && \
# clean up some junk
rm -rf /tmp/* /var/tmp/* /var/cache/apk/* && \
# make super duper sure that everything went OK, exit otherwise # make super duper sure that everything went OK, exit otherwise
hugo env && \ hugo env && \
go version && \ go version && \