From c84f0fecbaaa1aca7198c496f4289b86773a3a9a Mon Sep 17 00:00:00 2001 From: baalajimaestro Date: Fri, 14 Apr 2023 16:04:11 +0530 Subject: [PATCH] Build hugo fully from source on alpine Signed-off-by: baalajimaestro --- Dockerfile | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index d4ef362..d6b6c0f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,15 @@ -FROM alpine:latest - -RUN apk add --no-cache go libc6-compat +FROM golang:1.20-alpine as builder ARG HUGO_VERSION -RUN wget "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_Linux-64bit.tar.gz" && \ - tar -xf "hugo_extended_${HUGO_VERSION}_Linux-64bit.tar.gz" && \ - mv ./hugo /usr/bin/hugo && \ - rm -rf "hugo_extended_${HUGO_VERSION}_Linux-64bit.tar.gz" +ENV CGO_ENABLED=1 -CMD ["/usr/bin/hugo"] +RUN apk add --no-cache git build-base && \ + go install -tags extended github.com/gohugoio/hugo@v$HUGO_VERSION +FROM golang:1.20-alpine + +RUN apk add libstdc++ +COPY --from=builder /go/bin/hugo /go/bin/hugo + +CMD ["/go/bin/hugo"]