|
| 1 | +# golang-crossbuild |
| 2 | + |
| 3 | +golang-crossbuild is a set of Docker images containing the requisite |
| 4 | +cross-compilers for cross compiling Go applications. The cross-compilers are |
| 5 | +needed when the application uses [cgo](https://golang.org/cmd/cgo/). |
| 6 | + |
| 7 | +The base image used is Debian 9 (stretch) unless otherwise specified. |
| 8 | + |
| 9 | +## Docker Repo |
| 10 | + |
| 11 | +`docker.elastic.co/beats-dev/golang-crossbuild:[TAG]` |
| 12 | + |
| 13 | +## Build Tags |
| 14 | + |
| 15 | +- `1.10.3-main` - linux/{amd64,386} and windows/{amd64,386} |
| 16 | +- `1.10.3-arm` - linux/{armv5,armv6,armv7,arm64} |
| 17 | +- `1.10.3-darwin` - darwin/{amd64,386} |
| 18 | +- `1.10.3-ppc` - linux/{ppc64,ppc64le} |
| 19 | +- `1.10.3-mips` - linux/{mips,mipsle,mips64,mips64le} |
| 20 | +- `1.10.3-s390x` - linux/s390x |
| 21 | +- `1.10.3-main-debian7` - linux/{amd64,386} and windows/{amd64,386} (Debian 7 |
| 22 | + uses glibc 2.13 so the resulting binaries (if dynamically linked) have greater |
| 23 | + compatibility.) |
| 24 | + |
| 25 | +## Usage Example |
| 26 | + |
| 27 | +```sh |
| 28 | +docker run -it --rm \ |
| 29 | + -v $GOPATH/src/github.com/user/go-project:/go/src/github.com/user/go-project \ |
| 30 | + -w /go/src/github.com/user/go-project \ |
| 31 | + -env CGO_ENABLED=1 \ |
| 32 | + docker.elastic.co/beats-dev/golang-crossbuild:1.10.3-arm \ |
| 33 | + --build-cmd "make build" \ |
| 34 | + -p "linux/armv7" |
| 35 | +``` |
| 36 | + |
| 37 | +This will execute your projects `make build` target. While executing the build |
| 38 | +command the following variables with be added to the environment: GOOS, GOARCH, |
| 39 | +GOARM, PLATFORM_ID, CC, and CXX. |
0 commit comments