From 47ae5e6841c635d7a523f514f6f9bc1749d57098 Mon Sep 17 00:00:00 2001 From: Michael Kriese Date: Sat, 4 Jul 2026 16:56:25 +0200 Subject: [PATCH] build: enable go toolchain download on docker images (#9837) This ensures we use the right go toolchain on docker build even if there is an older image already cached. Tested manually: - `docker buildx build --progress plain -f Dockerfile.rootless .` currently is up-to-date - change `build-env` image to `golang:1.24-alpine3.22` and run again: see `go: downloading go1.25.3 (linux/amd64)` in output ```diff diff --git a/Dockerfile.rootless b/Dockerfile.rootless index 2dbcd6ddd2..8c6ac5f266 100644 --- a/Dockerfile.rootless +++ b/Dockerfile.rootless @@ -1,6 +1,6 @@ FROM --platform=$BUILDPLATFORM data.forgejo.org/oci/xx AS xx -FROM --platform=$BUILDPLATFORM data.forgejo.org/oci/golang:1.25-alpine3.22 AS build-env +FROM --platform=$BUILDPLATFORM data.forgejo.org/oci/golang:1.24-alpine3.22 AS build-env ARG GOPROXY ENV GOPROXY=${GOPROXY:-https://proxy.golang.org,direct} @@ -10,10 +10,13 @@ ARG TAGS="sqlite sqlite_unlock_notify" ENV TAGS="bindata timetzdata $TAGS" ARG CGO_EXTRA_CFLAGS +RUN go env + # it's set to local by default in the base image # we want to use auto to let go choose the right toolchain ENV GOTOOLCHAIN=auto + # # Transparently cross compile for the target platform # @@ -37,6 +40,9 @@ RUN apk --no-cache add build-base git nodejs npm COPY . ${GOPATH}/src/forgejo.org WORKDIR ${GOPATH}/src/forgejo.org + +RUN set -ex; go env; + RUN make clean-no-bindata RUN make frontend RUN go build contrib/environment-to-ini/environment-to-ini.go && xx-verify environment-to-ini ``` Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/9837 Reviewed-by: Mathieu Fenniak Reviewed-by: Gusted --- Dockerfile | 4 ++++ Dockerfile.rootless | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/Dockerfile b/Dockerfile index 2639d91e44..d30e6a2c48 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,6 +10,10 @@ ARG TAGS="sqlite sqlite_unlock_notify" ENV TAGS="bindata timetzdata $TAGS" ARG CGO_EXTRA_CFLAGS +# it's set to local by default in the base image +# we want to use auto to let go choose the right toolchain +ENV GOTOOLCHAIN=auto + # # Transparently cross compile for the target platform # diff --git a/Dockerfile.rootless b/Dockerfile.rootless index d6e037c522..71d1e8b789 100644 --- a/Dockerfile.rootless +++ b/Dockerfile.rootless @@ -10,6 +10,10 @@ ARG TAGS="sqlite sqlite_unlock_notify" ENV TAGS="bindata timetzdata $TAGS" ARG CGO_EXTRA_CFLAGS +# it's set to local by default in the base image +# we want to use auto to let go choose the right toolchain +ENV GOTOOLCHAIN=auto + # # Transparently cross compile for the target platform #