Description
Would like the ability to build natively on the cross compile architectures, i.e. arm, amd64, s390x, ppc64le.
Steps to reproduce the issue:
On an arm machine:
$ make -f docker.Makefile binary
Describe the results you received:
Dockerfile used to build the binary is x86_64 only:
panic: standard_init_linux.go:175: exec user process caused "exec format error" [recovered]
panic: standard_init_linux.go:175: exec user process caused "exec format error"
Describe the results you expected:
A valid native binary in the build dir.
Additional information you deem important (e.g. issue happens only occasionally):
Workaround for now is to cross-compile the other architectures on an x86_64 machine:
$ make -f docker.Makefile cross
/cc @dnephin @seemethere
How important is it that we re-use the binary target? Would it be ok to have a binary-arch-native target?
We could add a new Dockerfile like this:
Dockerfile.multiarch
ARG ARCH
FROM $ARCH/golang:1-8.3
WORKDIR /go/src/github.com/docker/cli
And use:
@dnephin A binary-arch-native target would be fine.
I suppose we just have to be mindful if you are on a mac and run make binary-archive-native. The make target would have to detect running on a mac and build the mac binary as a cross compile in a linux container.
A multi-arch repo also works pretty well here.
I don't know if there is any plans for an "official" one, but I used tianon's trollin repo and changed the FROM in dockerfiles/Dockerfile.dev to trollin/golang and that works.
I believe this pattern should also support windows images.
@andrewhsu @tophj-ibm with the golang images now being multi arch; is there any adjustment needed in this repository?
It looks like the -alpine version is not multi-arch just yet (alpine is still a WIP). Hopefully that will be done soon and everything will just work.
@thaJeztah We are still waiting on alpine, and then golang:x-alpine to be multiarch (waiting on z). Once that happens I don't think anything will have to change here.
Oh; yes, forgot we're using the Alpine version here
alpine + golang:1.8.5-alpine3.6 is multi-arch now, so this should work on all the supported linux/arch combinations. Just tested master on ppc64le and everything looks 馃憤
@dnephin this is probably good to close
Thanks! I'm happy with this solution.