# GitHub: https://github.com/gohugoio # Twitter: https://twitter.com/gohugoio # Website: https://gohugo.io/ ARG GO_VERSION="1.23.2" ARG ALPINE_VERSION="3.20" ARG DART_SASS_VERSION="1.79.3" FROM --platform=$BUILDPLATFORM tonistiigi/xx:1.5.0 AS xx FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS gobuild FROM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS gorun FROM gobuild AS build RUN apk add clang lld # Set up cross-compilation helpers COPY --from=xx / / ARG TARGETPLATFORM RUN xx-apk add musl-dev gcc g++ # Optionally set HUGO_BUILD_TAGS to "none" or "withdeploy" when building like so: # docker build --build-arg HUGO_BUILD_TAGS=withdeploy . # # We build the extended version by default. ARG HUGO_BUILD_TAGS="extended" ENV CGO_ENABLED=1 ENV GOPROXY=https://proxy.golang.org ENV GOCACHE=/root/.cache/go-build ENV GOMODCACHE=/go/pkg/mod ARG TARGETPLATFORM WORKDIR /go/src/github.com/gohugoio/hugo # For --mount=type=cache the value of target is the default cache id, so # for the go mod cache it would be good if we could share it with other Go images using the same setup, # but the go build cache needs to be per platform. # See this comment: https://github.com/moby/buildkit/issues/1706#issuecomment-702238282 RUN --mount=target=. \ --mount=type=cache,target=/go/pkg/mod \ --mount=type=cache,target=/root/.cache/go-build,id=go-build-$TARGETPLATFORM <