From 9aa33337b26d48a909f6937fd6f89cb1c62a9f5e Mon Sep 17 00:00:00 2001 From: Pier-Hugues Pellerin Date: Thu, 27 Aug 2020 15:41:08 -0400 Subject: [PATCH] [Build] Make mage-linux-amd64 statically compiled. (#20827) * [Build] Make mage-linux-amd64 statically compiled. When I've upgraded my arch system, they have upgraded the libc library, that libary is much newer than the library used in the crossbuild docker images. This made building beats impossible because the mage-linux-amd64 is compiled dynamically and used in all our docker build. This PR make the mage binary to be statically compiled so it doesn't rely on any installed libraries. (cherry picked from commit 273ecae934b916e0344c59932aca650d0c0d72f5) --- CHANGELOG-developer.next.asciidoc | 2 ++ dev-tools/mage/crossbuild.go | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG-developer.next.asciidoc b/CHANGELOG-developer.next.asciidoc index 8b473f0d68b..e76cd10c833 100644 --- a/CHANGELOG-developer.next.asciidoc +++ b/CHANGELOG-developer.next.asciidoc @@ -92,3 +92,5 @@ The list below covers the major changes between 7.0.0-rc2 and master only. - Added SQL helper that can be used from any Metricbeat module {pull}18955[18955] - Update Go version to 1.14.4. {pull}19753[19753] - Update Go version to 1.14.7. {pull}20508[20508] +- Add packaging for docker image based on UBI minimal 8. {pull}20576[20576] +- Make the mage binary used by the build process in the docker container to be statically compiled. {pull}20827[20827] diff --git a/dev-tools/mage/crossbuild.go b/dev-tools/mage/crossbuild.go index 6a11f7666cd..22b0ae574df 100644 --- a/dev-tools/mage/crossbuild.go +++ b/dev-tools/mage/crossbuild.go @@ -173,7 +173,7 @@ func CrossBuildXPack(options ...CrossBuildOption) error { // values for Docker. It has the benefit of speeding up the build because the // mage -compile is done only once rather than in each Docker container. func buildMage() error { - return sh.Run("mage", "-f", "-goos=linux", "-goarch=amd64", + return sh.RunWith(map[string]string{"CGO_ENABLED": "0"}, "mage", "-f", "-goos=linux", "-goarch=amd64", "-compile", CreateDir(filepath.Join("build", "mage-linux-amd64"))) }