From f44706c661985bbf96bf31798d3b995cba6649d8 Mon Sep 17 00:00:00 2001 From: Soren Mathiasen Date: Tue, 19 Apr 2016 15:15:56 +0200 Subject: [PATCH 1/2] Reduce the size of the binaries --- scripts/build.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/build.sh b/scripts/build.sh index 6681565c185d..76ff6dad6117 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -35,12 +35,18 @@ if ! which gox > /dev/null; then go get -u github.com/mitchellh/gox fi +LD_FLAGS="-X main.GitCommit=${GIT_COMMIT}${GIT_DIRTY}" +# In relase mode we don't want debug information in the binary +if [[ -n "${TF_RELEASE}" ]]; then + LD_FLAGS="-X main.GitCommit=${GIT_COMMIT}${GIT_DIRTY} -s -w" +fi + # Build! echo "==> Building..." gox \ -os="${XC_OS}" \ -arch="${XC_ARCH}" \ - -ldflags "-X main.GitCommit=${GIT_COMMIT}${GIT_DIRTY}" \ + -ldflags "${LD_FLAGS}" \ -output "pkg/{{.OS}}_{{.Arch}}/terraform-{{.Dir}}" \ $(go list ./... | grep -v /vendor/) From a1530855a3a762661dd1d78ca28fdfddc32e797f Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Tue, 19 Apr 2016 09:50:46 -0700 Subject: [PATCH 2/2] Build release binaries in release mode This strips debug information from the binaries, making them slightly smaller. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 08308556034e..de7aa27e92fc 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ default: test vet # bin generates the releaseable binaries for Terraform bin: fmtcheck generate - @sh -c "'$(CURDIR)/scripts/build.sh'" + @TF_RELEASE=1 sh -c "'$(CURDIR)/scripts/build.sh'" # dev creates binaries for testing Terraform locally. These are put # into ./bin/ as well as $GOPATH/bin