From 94714efe8024ac5d94240931910e243313a84066 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Wed, 9 Oct 2024 11:39:36 +0200 Subject: [PATCH] Upgrade to latest Go version + Some Docker image improvements (note) * Rename /site to /project * Add ldflags * Add go and node to the default image * Add Dart Sass to the default image * Build the extended version by default * Add "npm i" install support with custom entry script override * Adjust cache logic to speed up CGO rebuilds Closes #12920 See #12885 --- .circleci/config.yml | 4 +- Dockerfile | 84 ++++++++++++------- notesdocker.md | 34 ++++++++ scripts/docker/entrypoint.sh | 19 +++++ scripts/docker/install_runtimedeps_default.sh | 20 +++++ 5 files changed, 129 insertions(+), 32 deletions(-) create mode 100644 notesdocker.md create mode 100755 scripts/docker/entrypoint.sh create mode 100755 scripts/docker/install_runtimedeps_default.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index 0ff9559365e..6a82e96b7d0 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -4,7 +4,7 @@ parameters: defaults: &defaults resource_class: large docker: - - image: bepsays/ci-hugoreleaser:1.22300.20000 + - image: bepsays/ci-hugoreleaser:1.22300.20200 environment: &buildenv GOMODCACHE: /root/project/gomodcache version: 2 @@ -60,7 +60,7 @@ jobs: environment: <<: [*buildenv] docker: - - image: bepsays/ci-hugoreleaser-linux-arm64:1.22300.20000 + - image: bepsays/ci-hugoreleaser-linux-arm64:1.22300.20200 steps: - *restore-cache - &attach-workspace diff --git a/Dockerfile b/Dockerfile index afe5cf1322c..649bfb882b3 100755 --- a/Dockerfile +++ b/Dockerfile @@ -3,55 +3,79 @@ # Website: https://gohugo.io/ FROM --platform=$BUILDPLATFORM tonistiigi/xx:1.5.0 AS xx - -FROM --platform=$BUILDPLATFORM golang:1.22.6-alpine AS build +FROM --platform=$BUILDPLATFORM golang:1.23.2-alpine AS base +FROM base AS build # Set up cross-compilation helpers COPY --from=xx / / -RUN apk add clang lld +#RUN apk add clang lld -# Optionally set HUGO_BUILD_TAGS to "extended" or "nodeploy" when building like so: -# docker build --build-arg HUGO_BUILD_TAGS=extended . -ARG HUGO_BUILD_TAGS="none" -ARG CGO=1 -ENV CGO_ENABLED=${CGO} -ENV GOOS=linux -ENV GO111MODULE=on +# gcc/g++ are required to build libsass and libwebp libraries for the extended version. +RUN xx-apk add --no-scripts --no-cache gcc g++ +# RUN xx-apk add --no-scripts --no-cache gcc g++ musl-dev git -WORKDIR /go/src/github.com/gohugoio/hugo +# Optionally set HUGO_BUILD_TAGS to "none" or "nodeploy" when building like so: +# docker build --build-arg HUGO_BUILD_TAGS=nodeploy . +# +# We build the extended version by default. +ARG HUGO_BUILD_TAGS="extended" +ENV GOPROXY=https://proxy.golang.org +ENV GOCACHE=/root/.cache/go-build +ENV GOMODCACHE=/go/pkg/mod -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 +WORKDIR /go/src/github.com/gohugoio/hugo -ARG TARGETPLATFORM -# gcc/g++ are required to build SASS libraries for extended version -RUN xx-apk add --no-scripts --no-cache gcc g++ musl-dev git RUN --mount=target=. \ - --mount=type=cache,target=/go/pkg/mod <