From 03479312f1772f52ffc758b6997317112a6b1d3c Mon Sep 17 00:00:00 2001 From: kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com> Date: Thu, 26 Aug 2021 11:19:52 +0100 Subject: [PATCH] Improved build script (#152) - explicity disable cgo - ensure static builds - reduce binary size - small formatting changes Signed-off-by: kim (grufwub) --- build.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/build.sh b/build.sh index 18a927e2d..65b258cba 100755 --- a/build.sh +++ b/build.sh @@ -2,7 +2,10 @@ set -eu -export COMMIT=$(git rev-list -1 HEAD) -export VERSION=$(cat ./version) +COMMIT=$(git rev-list -1 HEAD) +VERSION=$(cat ./version) -go build -ldflags="-X 'main.Commit=$COMMIT' -X 'main.Version=$VERSION'" ./cmd/gotosocial +CGO_ENABLED=0 go build -trimpath \ + -tags 'netgo osusergo static_build' \ + -ldflags="-s -w -extldflags '-static' -X 'main.Commit=${COMMIT}' -X 'main.Version=${VERSION}'" \ + ./cmd/gotosocial