Skip to content

Commit

Permalink
Link linux binary statically. (#253)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerrit91 authored Aug 22, 2023
1 parent 25d3dab commit c4aabc6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 10 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
GOOS := linux
GOARCH := amd64
CGO_ENABLED := 0
CGO_ENABLED := 1
TAGS := -tags 'netgo'
BINARY := cloudctl-$(GOOS)-$(GOARCH)

SHA := $(shell git rev-parse --short=8 HEAD)
GITVERSION := $(shell git describe --long --all)
BUILDDATE := $(shell date --rfc-3339=seconds)
VERSION := $(or ${VERSION},$(shell git describe --tags --exact-match 2> /dev/null || git symbolic-ref -q --short HEAD || git rev-parse --short HEAD))

ifeq ($(CGO_ENABLED),1)
ifeq ($(GOOS),linux)
LINKMODE := -linkmode external -extldflags '-static -s -w'
TAGS := -tags 'osusergo netgo static_build'
endif
endif

LINKMODE := $(LINKMODE) \
-s -w \
-X 'github.com/metal-stack/v.Version=$(VERSION)' \
-X 'github.com/metal-stack/v.Revision=$(GITVERSION)' \
-X 'github.com/metal-stack/v.GitSHA1=$(SHA)' \
Expand All @@ -18,7 +25,7 @@ LINKMODE := $(LINKMODE) \
.PHONY: build
build:
go build \
-tags netgo \
$(TAGS) \
-ldflags \
"$(LINKMODE)" \
-o bin/$(BINARY) \
Expand Down
2 changes: 2 additions & 0 deletions cmd/output/shootprinter.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ func (s ShootLastErrorsTablePrinter) Print(data []*models.V1beta1LastError) {
s.wideHeader = []string{"Time", "Task", "Description"}
s.shortHeader = []string{"Time", "Task", "Description"}
for _, e := range data {
e := e

wide := []string{
strValue(&e.LastUpdateTime),
strValue(&e.TaskID),
Expand Down

0 comments on commit c4aabc6

Please sign in to comment.