@@ -27,17 +27,21 @@ import (
2727
2828type ApoxyCli struct {}
2929
30- func hostArch ( ) string {
31- switch runtime . GOARCH {
30+ func canonArchFromGoArch ( goarch string ) string {
31+ switch goarch {
3232case "amd64" :
3333return "x86_64"
3434case "arm64" :
3535return "aarch64"
3636default :
37- return runtime . GOARCH
37+ return goarch
3838}
3939}
4040
41+ func hostArch () string {
42+ return canonArchFromGoArch (runtime .GOARCH )
43+ }
44+
4145// BuilderContainer builds a CLI binary.
4246func (m * ApoxyCli ) BuilderContainer (ctx context.Context , src * dagger.Directory ) * dagger.Container {
4347return dag .Container ().
@@ -192,10 +196,17 @@ func (m *ApoxyCli) BuildBackplane(
192196WithMountedCache ("/go/pkg/mod" , dag .CacheVolume ("go-mod-" + goarch )).
193197WithEnvVariable ("GOMODCACHE" , "/go/pkg/mod" ).
194198WithMountedCache ("/go/build-cache" , dag .CacheVolume ("go-build-" + goarch )).
195- WithEnvVariable ("GOCACHE" , "/go/build-cache" ).
196- WithEnvVariable ("CGO_ENABLED" , "1" ).
197- WithExec ([]string {"go" , "build" , "-o" , bpOut , "./cmd/backplane" }).
198- WithExec ([]string {"go" , "build" , "-o" , dsOut , "./cmd/dial-stdio" })
199+ WithEnvVariable ("GOCACHE" , "/go/build-cache" )
200+
201+ if goarch == "amd64" {
202+ builder = builder .
203+ WithEnvVariable ("CGO_ENABLED" , "1" ).
204+ WithEnvVariable ("CC" , fmt .Sprintf ("zig cc --target=%s-linux-musl" , canonArchFromGoArch (goarch )))
205+ }
206+
207+ builder = builder .
208+ WithExec ([]string {"go" , "build" , "-ldflags" , "-v -linkmode=external" , "-o" , bpOut , "./cmd/backplane" }).
209+ WithExec ([]string {"go" , "build" , "-ldflags" , "-v -linkmode=external" , "-o" , dsOut , "./cmd/dial-stdio" })
199210
200211runtimeCtr := m .PullEdgeRuntime (ctx , platform )
201212
@@ -229,7 +240,10 @@ func (m *ApoxyCli) PublishImages(
229240fmt .Println ("API server image published to" , addr )
230241
231242var bCtrs []* dagger.Container
232- for _ , platform := range []string {"linux/amd64" , "linux/arm64" } {
243+ // TODO(dilyevsky): When Go team finally gets around fixing their
244+ // https://github.com/golang/go/issues/22040 hack, we can enable arm64
245+ // builds in CI.
246+ for _ , platform := range []string {"linux/amd64" /* "linux/arm64", */ } {
233247bCtr := m .BuildBackplane (ctx , src , platform )
234248bCtrs = append (bCtrs , bCtr )
235249}
0 commit comments