Build hugo fully from source on alpine

Signed-off-by: baalajimaestro <me@baalajimaestro.me>
This commit is contained in:
baalajimaestro 2023-04-14 16:04:11 +05:30
parent 1b07cb236d
commit c84f0fecba
Signed by: baalajimaestro
GPG key ID: F93C394FE9BBAFD5

View file

@ -1,13 +1,15 @@
FROM alpine:latest FROM golang:1.20-alpine as builder
RUN apk add --no-cache go libc6-compat
ARG HUGO_VERSION ARG HUGO_VERSION
RUN wget "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_Linux-64bit.tar.gz" && \ ENV CGO_ENABLED=1
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"
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"]