2018-03-18 16:54:49 -04:00
|
|
|
# GitHub: https://github.com/gohugoio
|
|
|
|
# Twitter: https://twitter.com/gohugoio
|
|
|
|
# Website: https://gohugo.io/
|
2016-01-04 02:27:21 -05:00
|
|
|
|
2024-09-29 13:30:04 -04:00
|
|
|
FROM --platform=$BUILDPLATFORM tonistiigi/xx:1.5.0 AS xx
|
|
|
|
|
|
|
|
FROM --platform=$BUILDPLATFORM golang:1.22.6-alpine AS build
|
|
|
|
|
|
|
|
# Set up cross-compilation helpers
|
|
|
|
COPY --from=xx / /
|
|
|
|
RUN apk add clang lld
|
2018-03-18 16:54:49 -04:00
|
|
|
|
2020-10-23 03:03:41 -04:00
|
|
|
# Optionally set HUGO_BUILD_TAGS to "extended" or "nodeploy" when building like so:
|
2019-10-09 11:27:08 -04:00
|
|
|
# docker build --build-arg HUGO_BUILD_TAGS=extended .
|
2024-09-29 13:30:04 -04:00
|
|
|
ARG HUGO_BUILD_TAGS="none"
|
2019-10-09 11:27:08 -04:00
|
|
|
|
|
|
|
ARG CGO=1
|
|
|
|
ENV CGO_ENABLED=${CGO}
|
|
|
|
ENV GOOS=linux
|
|
|
|
ENV GO111MODULE=on
|
2017-09-07 09:17:44 -04:00
|
|
|
|
2017-09-07 09:08:56 -04:00
|
|
|
WORKDIR /go/src/github.com/gohugoio/hugo
|
2019-10-09 11:27:08 -04:00
|
|
|
|
2024-09-29 13:30:04 -04:00
|
|
|
RUN --mount=src=go.mod,target=go.mod \
|
|
|
|
--mount=src=go.sum,target=go.sum \
|
|
|
|
--mount=type=cache,target=/go/pkg/mod \
|
|
|
|
go mod download
|
2019-02-06 20:01:26 -05:00
|
|
|
|
2024-09-29 13:30:04 -04:00
|
|
|
ARG TARGETPLATFORM
|
2019-10-09 11:27:08 -04:00
|
|
|
# gcc/g++ are required to build SASS libraries for extended version
|
2024-09-29 13:30:04 -04:00
|
|
|
RUN xx-apk add --no-scripts --no-cache gcc g++ musl-dev git
|
|
|
|
RUN --mount=target=. \
|
|
|
|
--mount=type=cache,target=/go/pkg/mod <<EOT
|
|
|
|
set -ex
|
|
|
|
xx-go build -tags "$HUGO_BUILD_TAGS" -o /usr/bin/hugo
|
|
|
|
xx-verify /usr/bin/hugo
|
|
|
|
EOT
|
2018-03-18 16:54:49 -04:00
|
|
|
|
|
|
|
# ---
|
2016-01-04 02:27:21 -05:00
|
|
|
|
2023-08-23 12:06:52 -04:00
|
|
|
FROM alpine:3.18
|
2019-10-09 11:27:08 -04:00
|
|
|
|
2024-09-29 13:30:04 -04:00
|
|
|
COPY --from=build /usr/bin/hugo /usr/bin/hugo
|
2019-10-09 11:27:08 -04:00
|
|
|
|
|
|
|
# libc6-compat & libstdc++ are required for extended SASS libraries
|
|
|
|
# ca-certificates are required to fetch outside resources (like Twitter oEmbeds)
|
|
|
|
RUN apk update && \
|
2020-02-14 10:49:20 -05:00
|
|
|
apk add --no-cache ca-certificates libc6-compat libstdc++ git
|
2019-10-09 11:27:08 -04:00
|
|
|
|
|
|
|
VOLUME /site
|
|
|
|
WORKDIR /site
|
|
|
|
|
|
|
|
# Expose port for live server
|
|
|
|
EXPOSE 1313
|
|
|
|
|
|
|
|
ENTRYPOINT ["hugo"]
|
|
|
|
CMD ["--help"]
|