golang-crossbuild is a set of Docker images containing the requisite cross-compilers for cross compiling Go applications. The cross-compilers are needed when the application uses cgo.
The base image used is Debian 9 (stretch) unless otherwise specified.
docker.elastic.co/beats-dev/golang-crossbuild:[TAG]
1.10.5-main
,1.11.2-main
- linux/{amd64,386} and windows/{amd64,386}1.10.5-arm
,1.11.2-arm
- linux/{armv5,armv6,armv7,arm64}1.10.5-darwin
,1.11.2-darwin
- darwin/{amd64,386}1.10.5-ppc
,1.11.2-ppc
- linux/{ppc64,ppc64le}1.10.5-mips
,1.11.2-mips
- linux/{mips,mipsle,mips64,mips64le}1.10.5-s390x
,1.11.2-s390x
- linux/s390x1.10.5-main-debian7
,1.11.2-main-debian7
- linux/{amd64,386} and windows/{amd64,386} (Debian 7 uses glibc 2.13 so the resulting binaries (if dynamically linked) have greater compatibility.)1.10.5-main-debian8
,1.11.2-main-debian8
- linux/{amd64,386} and windows/{amd64,386} (Debian 8 uses glibc 2.19)
docker run -it --rm \
-v $GOPATH/src/github.com/user/go-project:/go/src/github.com/user/go-project \
-w /go/src/github.com/user/go-project \
-e CGO_ENABLED=1 \
docker.elastic.co/beats-dev/golang-crossbuild:1.10.5-arm \
--build-cmd "make build" \
-p "linux/armv7"
This will execute your projects make build
target. While executing the build
command the following variables with be added to the environment: GOOS, GOARCH,
GOARM, PLATFORM_ID, CC, and CXX.
- Update the Docker tag in Makefile.common and/or Makefile.common.
- Update the Go version and SHA256 in the Dockerfile. The SHA256 must be obtained from https://golang.org/dl/.
- Commit the changes.
git add -u && git commit -m 'Update to Go 1.x.y'
. - Build the images from the project's root with
make
. - Get a logon token for the container registry by visiting https://docker.elastic.co:7000.
In the provided login command change
docker.elastic.co
topush.docker.elastic.co
. - Publish the images with
make push
.