-
Notifications
You must be signed in to change notification settings - Fork 516
The 'GOARCH'/'GOHOSTARCH' changed from 'amd64' to '386' in golang:1.21-alpine3.18 #481
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
go1.20 works well: golang/1.20/alpine3.18/Dockerfile Line 21 in b637fdd
But go1.21 changed: golang/1.21/alpine3.18/Dockerfile Line 21 in b637fdd
|
This is also the case for the golang:1.21.0, golang:1.21.0-bullseye, and goland:1.21.0-bookworm (e.g. all the Debian-based) images. This broke our product build when we upgraded to using the 1.21.0 image to build; it produces an i386 binary instead of an x86_64 binary. We can work around it by setting GOARCH=x86_64 variable in our build to cross-compile, but I wonder if this change was accidental. |
This is because Docker helpfully pulled the first architecture available that your system could run, the The change in the Dockerfile is irrelevant; Go upstream now provides compiled binaries that work on Alpine, so we don't have to compile it (#474). The images are available now: $ docker pull --platform=linux/amd64 golang:1.21-alpine
1.21-alpine: Pulling from library/golang
7264a8db6415: Pull complete
c4d48a809fc2: Pull complete
4f1c88b9dad5: Pull complete
ad3a456e5733: Pull complete
Digest: sha256:445f34008a77b0b98bf1821bf7ef5e37bb63cc42d22ee7c21cc17041070d134f
Status: Downloaded newer image for golang:1.21-alpine
docker.io/library/golang:1.21-alpine
$ docker run -it --rm golang:1.21-alpine
/go # env
HOSTNAME=daef19d37a59
SHLVL=1
HOME=/root
TERM=xterm
PATH=/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
GOPATH=/go
PWD=/go
GOLANG_VERSION=1.21.0
/go # go env
GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/root/.cache/go-build'
GOENV='/root/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.21.0'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='0'
GOMOD='/dev/null'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build3518816536=/tmp/go-build -gno-record-gcc-switches' |
I am very happy to see go1.21 released yesterday!
I can't wait to upgrade my base image which is golang:1.21-alpine3.18.
However, something wrong, my CICD broken.
I checked my code and found the GOARCH changed from 'amd64' to '386'.
I read golang release notes and I can't find the reason for the change.
➜ ~ docker run -it golang:1.21-alpine3.18
/go # go env GOHOSTARCH
386
/go # go env GOARCH
386
/go #
The text was updated successfully, but these errors were encountered: