go-build-template icon indicating copy to clipboard operation
go-build-template copied to clipboard

Build manifest-tool and build+run go-licenses inside containers

Open jingyuanliang opened this issue 2 years ago • 5 comments

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.

jingyuanliang avatar Sep 14 '22 04:09 jingyuanliang

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").

jingyuanliang avatar Sep 14 '22 04:09 jingyuanliang

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.

jingyuanliang avatar Sep 14 '22 20:09 jingyuanliang

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/

jingyuanliang avatar Sep 14 '22 22:09 jingyuanliang

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.

thockin avatar Sep 19 '22 21:09 thockin

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.

jingyuanliang avatar Sep 19 '22 23:09 jingyuanliang

Is there a reason why this runs go-licenses in a container rather than locally, once built?

thockin avatar Dec 20 '22 00:12 thockin

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.

jingyuanliang avatar Dec 20 '22 19:12 jingyuanliang