use last modified as publish date

look I get it I don't know Docker

I thought this was going to be easy, because in the config.toml file you just add EnableGitInfo based on https://gohugo.io/variables/git/. But then my automated push via Cloud Build stopped building because

ERROR 2019/07/20 20:46:13 Failed to read Git log: Git executable not found in $PATH

I thought that the Cloud Build environment needed to have Git installed, but what is even a Cloud Build environment? It turns out, the answer is “nothing” and that’s a stupid question. The right question is “which container image is missing Git”. And that answer is the cloud build community’s Hugo package. The Dockerfile tells the story:

FROM busybox
ENV HUGO_VERSION=0.55.0
RUN wget -O- https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_${HUGO_VERSION}_Linux-64bit.tar.gz | tar zx

FROM gcr.io/distroless/base
ENTRYPOINT ["/hugo"]
COPY --from=0 /hugo /

This is a Docker multi-stage build and it’s the last image that becomes the Hugo image used by my cloud builder based on my previous post. I don’t know how to install anything into that base image. So I cheated and went to alpine:

FROM busybox
ENV HUGO_VERSION=0.55.0
RUN wget -O- https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_${HUGO_VERSION}_Linux-64bit.tar.gz | tar zx

FROM alpine
ENTRYPOINT ["/hugo"]
RUN apk add --no-cache git
COPY --from=0 /hugo /

To be clear, this is stupid. I should learn about multi-stage builds and probably create another stage that has Git, which I can add to the distroless base image, based on this issue on GitHub. But, instead, I’m cheating based on this issue.

It works, so I’ll leave it for now.

Published by using 223 words.