From a20e3ab917a34c3ea54dbebd4074e79918cb21c7 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Thu, 29 Aug 2024 13:27:44 +0200 Subject: [PATCH] Update to Go 1.23.0 (#436) --- .../updatecli.d/bump-go-release-version.sh | 6 ----- .github/workflows/bump-golang.yml | 2 +- .go-version | 2 +- README.md | 3 +-- go/Makefile.common | 2 +- go/base-arm/Dockerfile.tmpl | 13 +++++++---- go/base/Dockerfile.tmpl | 22 +++++++++++++------ go/base/install-go.sh | 8 +++---- 8 files changed, 32 insertions(+), 26 deletions(-) diff --git a/.github/updatecli.d/bump-go-release-version.sh b/.github/updatecli.d/bump-go-release-version.sh index 52361e99..4d39e284 100755 --- a/.github/updatecli.d/bump-go-release-version.sh +++ b/.github/updatecli.d/bump-go-release-version.sh @@ -45,9 +45,3 @@ find "go" -type f -name Dockerfile.tmpl -print0 | ${SED} -E -e "s#(ARG GOLANG_DOWNLOAD_SHA256)=.+#\1=${GOLANG_DOWNLOAD_SHA256_AMD}#g" "$line" fi done - -if [ -e go/base/install-go.sh ] ; then - ${SED} -E -e "s#(GOLANG_VERSION)=[0-9]+\.[0-9]+(\.[0-9]+)?#\1=${GO_RELEASE_VERSION}#g" go/base/install-go.sh - ${SED} -E -e "s#(GOLANG_DOWNLOAD_SHA256_AMD)=.+#\1=${GOLANG_DOWNLOAD_SHA256_AMD}#g" go/base/install-go.sh - ${SED} -E -e "s#(GOLANG_DOWNLOAD_SHA256_ARM)=.+#\1=${GOLANG_DOWNLOAD_SHA256_ARM}#g" go/base/install-go.sh -fi diff --git a/.github/workflows/bump-golang.yml b/.github/workflows/bump-golang.yml index 5db3f1bd..023be4a4 100644 --- a/.github/workflows/bump-golang.yml +++ b/.github/workflows/bump-golang.yml @@ -21,7 +21,7 @@ jobs: with: branch: 'main' # NOTE: when a new golang version please update me with 1. - go-minor: '1.22' + go-minor: '1.23' command: '--experimental apply' slack-bot-token: ${{ secrets.SLACK_BOT_TOKEN }} github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.go-version b/.go-version index e81ed8be..bfbadb3a 100644 --- a/.go-version +++ b/.go-version @@ -1 +1 @@ -1.22.6 \ No newline at end of file +1.23.0 \ No newline at end of file diff --git a/README.md b/README.md index fb68180a..ce7522b5 100644 --- a/README.md +++ b/README.md @@ -276,8 +276,7 @@ In the folder you can find the `sources.list` file that contains the list of rep this file is different for each Debian version. In some cases, this file must point to `http://archive.debian.org/debian` instead of `http://deb.debian.org/debian` to be able to install the packages, this happens when the Debian version reach the end of life. The base image is the one that install the `go` compiler, and the build tools for the rest of Docker images. -There is a scrip `install-go.sh` that download, check the SHA256, and install the `go` compiler, during the build of the Docker image. -When a new version of go i released, the `install-go.sh` script must be updated to install the new version. +When a new version of go is released, the aDockerimage.tmpla files must be updated to install the new version. ## go/base-arm Docker image diff --git a/go/Makefile.common b/go/Makefile.common index 4dfc3f43..07a59c8f 100644 --- a/go/Makefile.common +++ b/go/Makefile.common @@ -2,7 +2,7 @@ SELF_DIR := $(dir $(lastword $(MAKEFILE_LIST))) include $(SELF_DIR)/../Makefile.common NAME := golang-crossbuild -VERSION := 1.22.6 +VERSION := 1.23.0 DEBIAN_VERSION ?= 9 SUFFIX := -$(shell basename $(CURDIR)) TAG_EXTENSION ?= diff --git a/go/base-arm/Dockerfile.tmpl b/go/base-arm/Dockerfile.tmpl index 21bacf04..6d1ea1b8 100644 --- a/go/base-arm/Dockerfile.tmpl +++ b/go/base-arm/Dockerfile.tmpl @@ -37,17 +37,18 @@ RUN \ libsqlite3-0 \ && rm -rf /var/lib/apt/lists/* -ARG GOLANG_VERSION=1.22.6 +ARG GOLANG_VERSION=1.23.0 ARG GOLANG_DOWNLOAD_URL=https://golang.org/dl/go$GOLANG_VERSION.linux-arm64.tar.gz -ARG GOLANG_DOWNLOAD_SHA256=c15fa895341b8eaf7f219fada25c36a610eb042985dc1a912410c1c90098eaf2 +ARG GOLANG_DOWNLOAD_SHA256=62788056693009bcf7020eedc778cdd1781941c6145eab7688bd087bce0f8659 RUN curl -fsSL "$GOLANG_DOWNLOAD_URL" -o golang.tar.gz \ && echo "$GOLANG_DOWNLOAD_SHA256 golang.tar.gz" | sha256sum -c - \ + && rm -rf /usr/local/go \ && tar -C /usr/local -xzf golang.tar.gz \ && rm golang.tar.gz ENV GOPATH /go -ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH +ENV PATH $PATH:/usr/local/go/bin RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH" WORKDIR $GOPATH @@ -58,8 +59,12 @@ COPY rootfs / RUN ldd --version WORKDIR / + +RUN mkdir -p /root/.config/go/telemetry && echo "off 2024-08-23" > /root/.config/go/telemetry/mode RUN go mod init github.com/elastic/golang-crossbuild-$GOLANG_VERSION-arm \ - && go get -d . \ + && go get . \ + && go env \ + && echo "toolcompile=$(go tool compile -V)" \ && go build -o /crossbuild /entrypoint.go \ && rm -rf /go/* /root/.cache/* /entrypoint.go diff --git a/go/base/Dockerfile.tmpl b/go/base/Dockerfile.tmpl index f0f5c156..c552e9bb 100644 --- a/go/base/Dockerfile.tmpl +++ b/go/base/Dockerfile.tmpl @@ -31,13 +31,18 @@ RUN apt-get -o Acquire::Check-Valid-Until=false update -y --no-install-recommend RUN ln -s /usr/bin/pip3 /usr/bin/pip {{- end }} -COPY install-go.sh /tmp/install-go.sh -RUN chmod ugo+rx /tmp/install-go.sh \ - && /tmp/install-go.sh \ - && rm /tmp/install-go.sh +ARG GOLANG_VERSION=1.23.0 +ARG GOLANG_DOWNLOAD_URL=https://golang.org/dl/go$GOLANG_VERSION.linux-amd64.tar.gz +ARG GOLANG_DOWNLOAD_SHA256=905a297f19ead44780548933e0ff1a1b86e8327bb459e92f9c0012569f76f5e3 + +RUN curl -fsSL "$GOLANG_DOWNLOAD_URL" -o golang.tar.gz \ + && echo "$GOLANG_DOWNLOAD_SHA256 golang.tar.gz" | sha256sum -c - \ + && rm -rf /usr/local/go \ + && tar -C /usr/local -xzf golang.tar.gz \ + && rm golang.tar.gz ENV GOPATH /go -ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH +ENV PATH $PATH:/usr/local/go/bin RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH" WORKDIR $GOPATH @@ -48,9 +53,12 @@ COPY rootfs / RUN ldd --version WORKDIR / +RUN mkdir -p /root/.config/go/telemetry && echo "off 2024-08-23" > /root/.config/go/telemetry/mode RUN go mod init github.com/elastic/golang-crossbuild-$GOLANG_VERSION \ - && go get -d . \ - && go build -o /crossbuild /entrypoint.go \ + && go get . \ + && go env \ + && echo "toolcompile=$(go tool compile -V)" \ + && CGO_ENABLED=0 go build -o /crossbuild /entrypoint.go \ && rm -rf /go/* /root/.cache/* /entrypoint.go RUN curl -sSLO https://storage.googleapis.com/obs-ci-cache/beats/libpcap-1.8.1.tar.gz \ diff --git a/go/base/install-go.sh b/go/base/install-go.sh index 947c901a..adffa747 100644 --- a/go/base/install-go.sh +++ b/go/base/install-go.sh @@ -2,10 +2,10 @@ # This script install the Go version correct for each architecture. set -e -GOLANG_VERSION=1.22.6 +GOLANG_VERSION=1.23.0 GOLANG_DOWNLOAD_URL=https://golang.org/dl/go$GOLANG_VERSION.linux-amd64.tar.gz -GOLANG_DOWNLOAD_SHA256_AMD=999805bed7d9039ec3da1a53bfbcafc13e367da52aa823cb60b68ba22d44c616 -GOLANG_DOWNLOAD_SHA256_ARM=c15fa895341b8eaf7f219fada25c36a610eb042985dc1a912410c1c90098eaf2 +GOLANG_DOWNLOAD_SHA256_AMD=905a297f19ead44780548933e0ff1a1b86e8327bb459e92f9c0012569f76f5e3 +GOLANG_DOWNLOAD_SHA256_ARM=62788056693009bcf7020eedc778cdd1781941c6145eab7688bd087bce0f8659 GO_TAR_FILE=/tmp/golang.tar.gz @@ -21,5 +21,5 @@ if [ "$(uname -m)" != "x86_64" ]; then echo "$GOLANG_DOWNLOAD_SHA256_ARM ${GO_TAR_FILE}" | sha256sum -c - fi -tar -C /usr/local -xzf "${GO_TAR_FILE}" +rm -rf /usr/local/go && tar -C /usr/local -xzf "${GO_TAR_FILE}" rm "${GO_TAR_FILE}"