status-go icon indicating copy to clipboard operation
status-go copied to clipboard

Create binary releases of statusd for popular platforms

Open jakubgs opened this issue 5 years ago • 13 comments

The main thing complicating deployment of statusd for people is the need to install Go and build statusd. To start we should support at least the following:

  • linux-adm64
  • linux-arm32
  • linux-arm64
  • darwin-amd64

This could simplify the deployment process for mailservers.

jakubgs avatar Jan 14 '20 15:01 jakubgs

Based on this doc: https://www.digitalocean.com/community/tutorials/how-to-build-go-executables-for-multiple-platforms-on-ubuntu-16-04 We could build the binaries using the GOOS and GOARCH variables:

GOOS GOARCH
linux amd64
linux arm
linux arm64
darwin amd64

jakubgs avatar Jan 14 '20 15:01 jakubgs

I tried building for arm64 but I'm having issues with golang.org/x/net/context import:

 $ GOOS=linux GOARCH=arm64 go build -v -o build/bin/statusd ./cmd/statusd                                 ~/go/src/github.com/status-im/status-go
build github.com/status-im/status-go/cmd/statusd: cannot find module for path golang.org/x/net/context

This happens because of a mutecomm/go-sqlcipher module which imports it here: https://github.com/mutecomm/go-sqlcipher/blob/55dbde17/sqlite3.go#L91 Which is obsolete because golang.org/x/net/context was replaced by built in context:

As of Go 1.7 this package is available in the standard library under the name context. https://golang.org/pkg/context https://godoc.org/golang.org/x/net/context

And we use it in several places, for example here: https://github.com/status-im/status-go/blob/741f43cb0c544a03bb8477dfccc3151ae874b355/sqlite/sqlite.go#L8

THe comment states that

We require go sqlcipher that overrides default implementation

@adambabik can you clarify why this is necessary?

I guess I could fork this and adjust the import for our own usage and submit a PR.

jakubgs avatar Jan 24 '20 12:01 jakubgs

Same thing happens for 386:

 $ GO111MODULE=on GOOS=linux GOARCH=386 go build -v -o build/bin/statusd ./cmd/statusd
build github.com/status-im/status-go/cmd/statusd: cannot find module for path golang.org/x/net/context

I don't think some of our modules like being cross-compiled.

jakubgs avatar Jan 24 '20 13:01 jakubgs

When I tried changing that context import by hand in the vendor folder I got more errors:

 $ GOOS=linux GOARCH=arm64 go build -v -o build/bin/statusd ./cmd/statusd
github.com/ethereum/go-ethereum/crypto/secp256k1
go build github.com/ethereum/go-ethereum/crypto/secp256k1: build constraints exclude all Go files in /home/sochan/go/pkg/mod/github.com/status-im/[email protected]/crypto/secp256k1
gopkg.in/olebedev/go-duktape.v3
# gopkg.in/olebedev/go-duktape.v3
../../../../pkg/mod/gopkg.in/olebedev/[email protected]/dbgsockettransport.go:14:16: undefined: Context
../../../../pkg/mod/gopkg.in/olebedev/[email protected]/dbgsockettransport.go:16:15: undefined: DebugRequestFunc
../../../../pkg/mod/gopkg.in/olebedev/[email protected]/dbgsockettransport.go:17:15: undefined: DebugDetachedFunc

I don't know if this cross-compiling is doable. The go-ethereum/crypto/secp256k1 part is critical.

jakubgs avatar Jan 24 '20 13:01 jakubgs

This might be more trouble than it's worth. I'm putting this on hold.

jakubgs avatar Jan 27 '20 09:01 jakubgs

@jakubgs, Did you try that? https://goreleaser.com/quick-start

Pantani avatar Feb 21 '20 06:02 Pantani

I don't think that would help at all with the compilation issues.

But thanks for the suggestion.

jakubgs avatar Feb 21 '20 13:02 jakubgs

I'm tryin to do the same thing as @jakubgs in order to include statusd in Ethereum on ARM new release, but I'm facing the same problem, did you find antother way to create a statusd binary for arm64 (rpi4 is our main focus right now)?

washosk avatar Feb 07 '21 16:02 washosk

Build it directly on the host. Should work.

jakubgs avatar Feb 07 '21 19:02 jakubgs

Yes, compiling it in a rpi4 works like a charm. If you ever found a way to crosscompile it please let us know.

Thanks!

washosk avatar Feb 08 '21 10:02 washosk

Same problem here. Using some of the packages from github.com/ethereum/go-ethereum v1.9.25 and cross compilation fails for Darwin :(

Searching how to resolve it atm... let's see. Will share if I find something.

 ~/go/src/github.com/web3coach/the-blockchain-bar  c14_why_transaction_costs_gas  GOOS=darwin GOARCH=amd64 go install ./...                                                                                                                                                    2 err 
# gopkg.in/olebedev/go-duktape.v3
../../../../pkg/mod/gopkg.in/olebedev/[email protected]/dbgsockettransport.go:14:16: undefined: Context
../../../../pkg/mod/gopkg.in/olebedev/[email protected]/dbgsockettransport.go:16:15: undefined: DebugRequestFunc
../../../../pkg/mod/gopkg.in/olebedev/[email protected]/dbgsockettransport.go:17:15: undefined: DebugDetachedFunc
../../../../pkg/mod/gopkg.in/olebedev/[email protected]/dbgsockettransport.go:31:30: undefined: Context
../../../../pkg/mod/gopkg.in/olebedev/[email protected]/dbgsockettransport.go:33:14: undefined: DebugRequestFunc
../../../../pkg/mod/gopkg.in/olebedev/[email protected]/dbgsockettransport.go:34:15: undefined: DebugDetachedFunc
../../../../pkg/mod/gopkg.in/olebedev/[email protected]/timers.go:11:10: undefined: Context
../../../../pkg/mod/gopkg.in/olebedev/[email protected]/timers.go:30:10: undefined: Context
../../../../pkg/mod/gopkg.in/olebedev/[email protected]/timers.go:37:20: undefined: Context
../../../../pkg/mod/gopkg.in/olebedev/[email protected]/timers.go:63:22: undefined: Context
../../../../pkg/mod/gopkg.in/olebedev/[email protected]/timers.go:63:22: too many errors

web3coach avatar Jun 06 '21 11:06 web3coach

Update: seems like go-Ethereum is using xgo to cross-compile https://geth.ethereum.org/docs/install-and-build/cross-compile because of the C crypto libraries.

Try something around the lines:

go get -u github.com/karalabe/xgo
xgo --deps=https://gmplib.org/download/gmp/gmp-6.1.0.tar.bz2 --targets="linux/*,darwin/*" YOUR_CODEPATH 

Although this further fails for me bc it still uses Go 1.13 and I need Go 1.14 for CertMagic ...

I hope you will have more luck cross-compiling the statusd

web3coach avatar Jun 06 '21 12:06 web3coach

There is a PR currently for Go 1.14 merge but it seems to be im "mempool" :) https://github.com/karalabe/xgo/pull/184

web3coach avatar Jun 06 '21 12:06 web3coach