Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Makefile build cmd to create static binaries #297

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,31 @@ VERSION = $(shell git describe --always --long --dirty)
# The default `go build` process embeds debugging information. Building
# without that debugging information reduces the binary size by around 28%.
#
# We also include additional flags in an effort to generate static binaries
# that do not have external dependencies. As of Go 1.15 this still appears to
# be a mixed bag, so YMMV.
#
# See https://github.com/golang/go/issues/26492 for more information.
#
# -s
# Omit the symbol table and debug information.
#
# -w
# Omit the DWARF symbol table.
#
# -tags 'osusergo,netgo'
# Use pure Go implementation of user and group id/name resolution.
# Use pure Go implementation of DNS resolver.
#
# -trimpath
# https://golang.org/cmd/go/
# removes all file system paths from the compiled executable, to improve
# build reproducibility.
BUILDCMD = go build -mod=vendor -a -trimpath -ldflags="-s -w -X $(VERSION_VAR_PKG).version=$(VERSION)"
#
# CGO_ENABLED=0
# https://golang.org/cmd/cgo/
# explicitly disable use of cgo
BUILDCMD = CGO_ENABLED=0 go build -mod=vendor -a -trimpath -tags 'osusergo,netgo' -ldflags="-s -w -X $(VERSION_VAR_PKG).version=$(VERSION)"
GOCLEANCMD = go clean -mod=vendor ./...
GITCLEANCMD = git clean -xfd
CHECKSUMCMD = sha256sum -b
Expand Down