go-build-template
go-build-template copied to clipboard
Build manifest-tool and build+run go-licenses inside containers
I'm tired of updating tools from the template and seeing it not working on Louhi, potentially due to Go version issues. Since we've already got BUILD_IMAGE, let's build them using the BUILD_IMAGE instead of the local Go toolchain.
We can consider using a different BUILD_IMAGE variable (which defaults to the same as the main BUILD_IMAGE) in case someone needs a different main BUILD_IMAGE which isn't compatible with go-licenses and manifest-tool - I don't see an upfront need and can leave this as future work (plus, BUILD_IMAGE is listed under "These variables should not need tweaking").
I don't know what the Go version is on Louhi, but https://github.com/thockin/go-build-template/actions/runs/3055948724/jobs/4929577924 (triggered by https://github.com/thockin/go-build-template/pull/75) is a showcase that the current tools/
doesn't compile on Go 1.16.
GitHub CI itself runs on Go 1.17 so it didn't catch the issue before.
It appears even running an already-built go-licenses on an old Go machine still causes issues:
sigs.k8s.io/json/internal/golang/encoding/json: vendor/sigs.k8s.io/json/json.go:24:2: //go:build comment without // +build comment
End up using two containers because they need to have different GOPATH/working directory, and I don't really want to manipulate it inside the container.
I expect that manifest-tools has less issues as it's not interacting with Go build toolchain.
Ref: https://www.reddit.com/r/golang/comments/rn25ov/encountering_gobuild_comment_without_build/
I'll have to think about this. In truth, I have very little desire to support go 1.16 or earlier. That's 18 months old.
Well let's consider this as "support running on a dedicated build machine without (proper) Go toolchain" so we eliminate the whole dependency on the local Go.
Is there a reason why this runs go-licenses in a container rather than locally, once built?
Is there a reason why this runs go-licenses in a container rather than locally, once built?
This is to workaround https://github.com/google/go-licenses/issues/149 by using the same build+execution environments.