From 28dec80a8b7f8e1c97a0841d07f4fec2b307f842 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Sterba?= Date: Mon, 20 Jun 2022 17:15:30 +0200 Subject: [PATCH] Build static binaries --- .goreleaser.yml | 4 ++++ Makefile | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index 088d2ab..3681856 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -6,6 +6,10 @@ builds: env: # needed for sqlite support - CGO_ENABLED=1 + ldflags: + - "-extldflags=-static" + tags: + - sqlite_omit_load_extension goos: - linux # not able to build for these plattforms, as sqlite needs cgo diff --git a/Makefile b/Makefile index d592d63..5c1da2b 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ BINARY_NAME=upstream-watch all: build build: - $(GOBUILD) -o $(BINARY_NAME) cmd/main.go + $(GOBUILD) -ldflags="-extldflags=-static" -tags sqlite_omit_load_extension -o $(BINARY_NAME) cmd/main.go test: $(GOTEST) ./... clean: @@ -17,7 +17,7 @@ clean: run: build ./$(BINARY_NAME) localtest: build - cp $(BINARY_NAME) ../../upstream-watch-test-repo/ + cp $(BINARY_NAME) ../../upstream-watch-test-repo testcoverage: $(GOTEST) -coverprofile coverage.out ./... && go tool cover -html=coverage.out && rm coverage.out lint: