-
Notifications
You must be signed in to change notification settings - Fork 502
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
fix: go in docker failing #1989
Conversation
cmd/proxy/Dockerfile
Outdated
@@ -27,19 +27,17 @@ RUN DATE="$(date -u +%Y-%m-%d-%H:%M:%S-%Z)" && \ | |||
-ldflags "-X github.com/gomods/athens/pkg/build.version=$VERSION -X github.com/gomods/athens/pkg/build.buildDate=$DATE -s -w" \ | |||
-o /bin/athens-proxy ./cmd/proxy | |||
|
|||
FROM alpine:${ALPINE_VERSION} | |||
FROM golang:${GOLANG_VERSION}-alpine |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, I think if we just set the values for GOROOT=/go, GOSUMDB=off, and GOPROXY=direct then it'll fix this issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only thing I'm not super sure of is if our users would find turning the sumdb off and proxy to direct a sane default. Maybe we can figure out what it used to default to?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not work, you must move the GOROOT through the code, otherwise you get the same error.
I will make the needed changes, so we have a full comparison, but my concerns are as follows:
- It is not obvious that GOROOT needs to move through the code, and will likely be missed down the line
- I doubt this is the last rodio we will have with moving the Go bin around like this, and breaks are a little untestable.
In my testing earlier today I found that setting GOPROXY, GOSUMDB, and GOROOT alleviated errors on a base alpine image. The base alpine image is much smaller than the Go one.
For thoroughness, I pulled your branch, built the image locally, and ran it:
|
and just to pin down the source: https://github.com/golang/go/blame/630d4fb600ae309476c87a4ca0e29b60425bc0c1/src/cmd/go/main.go#L127-L130 |
This version uses the original Alpine base. The env control was more centralised than I had originally thought, so it is less ugly than I had imagined. For reference, /usr/local/go/go.env contains the defaults like GOPROXY and GOSUMDB. I think this is a good base for the install, and they can be overridden by Athens when needed. |
What is the problem I am trying to address?
In v0.15.2, an error occurs when trying to use the proxy:
It seems in Go 1.21, so defaults are no longer baked into the binary, causing issues when running Go.
My first attempt at a fix was to set
GOROOT
in the Dockerfile, but Athens does not pass all env vars to the Go binary when executing it. I did consider passingGOROOT
by default to the Go binary, but this seems wrong for people not running the docker image. There are also multiple go call sites, each using their own env calling conventions.The downside to this approach is the image grows from
170MB
to379MB
.How is the fix applied?
To get around the complexity, the root of the Dockerfile is set to
golang:<ver>-alpine
. This added the least complexity.