diff --git a/controllers/account/Makefile b/controllers/account/Makefile index 6f6ceb3c0e9..fe63ee8f5f4 100644 --- a/controllers/account/Makefile +++ b/controllers/account/Makefile @@ -63,7 +63,9 @@ test: manifests generate fmt vet envtest ## Run tests. .PHONY: build build: ## Build manager binary. - CGO_ENABLED=0 GOOS=linux go build $(shell [ -n "${CRYPTOKEY}" ] && echo "-ldflags '-X github.com/labring/sealos/controllers/pkg/crypto.encryptionKey=${CRYPTOKEY} -X github.com/labring/sealos/controllers/pkg/database.cryptoKey=${CRYPTOKEY}'") -o bin/manager main.go + LD_FLAGS="-s -w"; \ + [ -n "$(CRYPTOKEY)" ] && LD_FLAGS+="-X github.com/labring/sealos/controllers/pkg/crypto.encryptionKey=${CRYPTOKEY} -X github.com/labring/sealos/controllers/pkg/database.cryptoKey=${CRYPTOKEY}"; \ + CGO_ENABLED=0 GOOS=linux go build -ldflags "$${LD_FLAGS}" -trimpath -o bin/manager main.go .PHONY: run run: manifests generate fmt vet ## Run a controller from your host. diff --git a/controllers/app/Makefile b/controllers/app/Makefile index 9f69081f38c..91c2ede6e51 100644 --- a/controllers/app/Makefile +++ b/controllers/app/Makefile @@ -70,7 +70,7 @@ test: manifests generate fmt vet envtest ## Run tests. .PHONY: build build: ## Build manager binary. - CGO_ENABLED=0 GOOS=linux go build -o bin/manager cmd/main.go + CGO_ENABLED=0 GOOS=linux go build -ldflags "-s -w" -trimpath -o bin/manager cmd/main.go .PHONY: run run: manifests generate fmt vet ## Run a controller from your host. diff --git a/controllers/db/adminer/Makefile b/controllers/db/adminer/Makefile index 61fc5f08479..92bd69e2cd7 100644 --- a/controllers/db/adminer/Makefile +++ b/controllers/db/adminer/Makefile @@ -63,7 +63,7 @@ test: manifests generate fmt vet envtest ## Run tests. .PHONY: build build: ## Build manager binary. - CGO_ENABLED=0 go build -o bin/manager main.go + CGO_ENABLED=0 go build -ldflags "-s -w" -trimpath -o bin/manager main.go .PHONY: run run: manifests generate fmt vet ## Run a controller from your host. diff --git a/controllers/job/heartbeat/Makefile b/controllers/job/heartbeat/Makefile index 27000b99280..84e977e363e 100644 --- a/controllers/job/heartbeat/Makefile +++ b/controllers/job/heartbeat/Makefile @@ -48,7 +48,7 @@ vet: ## Run go vet against code. .PHONY: build build: fmt vet ## Build manager binary. - CGO_ENABLED=0 GOOS=linux go build -o bin/heartbeat-${GOARCH} cmd/main.go && chmod +x bin/heartbeat-${GOARCH} && cp bin/heartbeat-${GOARCH} bin/manager + CGO_ENABLED=0 GOOS=linux go build -ldflags "-s -w" -trimpath -o bin/heartbeat-${GOARCH} cmd/main.go && chmod +x bin/heartbeat-${GOARCH} && cp bin/heartbeat-${GOARCH} bin/manager .PHONY: run diff --git a/controllers/job/init/Makefile b/controllers/job/init/Makefile index 0a70765c430..3392aa8b514 100644 --- a/controllers/job/init/Makefile +++ b/controllers/job/init/Makefile @@ -50,7 +50,9 @@ vet: ## Run go vet against code. CONTROLLER_PKG=github.com/labring/sealos/controllers/pkg CONTROLLER_LICENSE=github.com/labring/sealos/controllers/license/internal/controller build: fmt vet ## Build manager binary. - CGO_ENABLED=0 GOOS=linux go build $(shell [ -n "${CRYPTOKEY}" ] && echo "-ldflags '-X github.com/labring/sealos/controllers/pkg/crypto.encryptionKey=${CRYPTOKEY} -X github.com/labring/sealos/controllers/pkg/database.cryptoKey=${CRYPTOKEY}'") -o bin/preset-${GOARCH} cmd/preset/main.go && chmod +x bin/preset-${GOARCH} && cp bin/preset-${GOARCH} bin/manager + LD_FLAGS="-s -w"; \ + [ -n "$(CRYPTOKEY)" ] && LD_FLAGS+="-X github.com/labring/sealos/controllers/pkg/crypto.encryptionKey=${CRYPTOKEY} -X github.com/labring/sealos/controllers/pkg/database.cryptoKey=${CRYPTOKEY}"; \ + CGO_ENABLED=0 GOOS=linux go build -ldflags "$${LD_FLAGS}" -trimpath -o bin/preset-${GOARCH} cmd/preset/main.go && chmod +x bin/preset-${GOARCH} && cp bin/preset-${GOARCH} bin/manager .PHONY: run diff --git a/controllers/license/Makefile b/controllers/license/Makefile index 95c4ce484fc..d9086310865 100644 --- a/controllers/license/Makefile +++ b/controllers/license/Makefile @@ -68,10 +68,10 @@ test: manifests generate fmt vet envtest ## Run tests. CONTROLLER_PKG=github.com/labring/sealos/controllers/pkg CONTROLLER_LICENSE=github.com/labring/sealos/controllers/license/internal build: manifests generate fmt vet ## Build manager binary. - LD_FLAGS=""; \ + LD_FLAGS="-s -w"; \ [ -n "$(CRYPTOKEY)" ] && LD_FLAGS+="-X ${CONTROLLER_PKG}/crypto.encryptionKey=${CRYPTOKEY} -X ${CONTROLLER_PKG}/database.cryptoKey=${CRYPTOKEY}"; \ [ -n "$(LICENSE_KEY)" ] && LD_FLAGS+=" -X ${CONTROLLER_LICENSE}/util/key.EncryptionKey=${LICENSE_KEY}"; \ - CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build -ldflags "$${LD_FLAGS}" -o bin/manager cmd/manager/main.go + CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build -ldflags "$${LD_FLAGS}" -trimpath -o bin/manager cmd/manager/main.go .PHONY: run diff --git a/controllers/node/Makefile b/controllers/node/Makefile index 8b7a684ea88..48cd9990fb5 100644 --- a/controllers/node/Makefile +++ b/controllers/node/Makefile @@ -63,7 +63,7 @@ test: manifests generate fmt vet envtest ## Run tests. .PHONY: build build: ## Build manager binary. - CGO_ENABLED=0 GOOS=linux go build -o bin/manager main.go + CGO_ENABLED=0 GOOS=linux go build -ldflags "-s -w" -trimpath -o bin/manager main.go .PHONY: run run: manifests generate fmt vet ## Run a controller from your host. diff --git a/controllers/objectstorage/Makefile b/controllers/objectstorage/Makefile index 34e0ee2cc67..cbe43898401 100644 --- a/controllers/objectstorage/Makefile +++ b/controllers/objectstorage/Makefile @@ -63,7 +63,9 @@ test: manifests generate fmt vet envtest ## Run tests. .PHONY: build build: ## Build manager binary. - CGO_ENABLED=0 GOOS=linux go build $(shell [ -n "${CRYPTOKEY}" ] && echo "-ldflags '-X github.com/labring/sealos/controllers/pkg/crypto.encryptionKey=${CRYPTOKEY} -X github.com/labring/sealos/controllers/pkg/database.cryptoKey=${CRYPTOKEY}'") -o bin/manager main.go + LD_FLAGS="-s -w"; \ + [ -n "$(CRYPTOKEY)" ] && LD_FLAGS+="-X github.com/labring/sealos/controllers/pkg/crypto.encryptionKey=${CRYPTOKEY} -X github.com/labring/sealos/controllers/pkg/database.cryptoKey=${CRYPTOKEY}"; \ + CGO_ENABLED=0 GOOS=linux go build -ldflags "$${LD_FLAGS}" -trimpath -o bin/manager main.go .PHONY: run run: manifests generate fmt vet ## Run a controller from your host. diff --git a/controllers/resources/Makefile b/controllers/resources/Makefile index 23032dc2865..d6733814fb5 100644 --- a/controllers/resources/Makefile +++ b/controllers/resources/Makefile @@ -63,7 +63,9 @@ test: manifests generate fmt vet envtest ## Run tests. .PHONY: build build: ## Build manager binary. - CGO_ENABLED=0 GOOS=linux go build $(shell [ -n "${CRYPTOKEY}" ] && echo "-ldflags '-X github.com/labring/sealos/controllers/pkg/crypto.encryptionKey=${CRYPTOKEY} -X github.com/labring/sealos/controllers/pkg/database.cryptoKey=${CRYPTOKEY}'") -o bin/manager main.go + LD_FLAGS="-s -w"; \ + [ -n "$(CRYPTOKEY)" ] && LD_FLAGS+="-X github.com/labring/sealos/controllers/pkg/crypto.encryptionKey=${CRYPTOKEY} -X github.com/labring/sealos/controllers/pkg/database.cryptoKey=${CRYPTOKEY}"; \ + CGO_ENABLED=0 GOOS=linux go build -ldflags "$${LD_FLAGS}" -trimpath -o bin/manager main.go .PHONY: run run: manifests generate fmt vet ## Run a controller from your host. diff --git a/controllers/terminal/Makefile b/controllers/terminal/Makefile index 92442516e15..1fe5b0a7c45 100644 --- a/controllers/terminal/Makefile +++ b/controllers/terminal/Makefile @@ -65,7 +65,7 @@ test: manifests generate fmt vet envtest ## Run tests. .PHONY: build build: ## Build manager binary. - CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build -o bin/manager main.go + CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build -ldflags "-s -w" -trimpath -o bin/manager main.go .PHONY: run run: manifests generate fmt vet ## Run a controller from your host. diff --git a/controllers/user/Makefile b/controllers/user/Makefile index dfb4ca10285..3fada975794 100644 --- a/controllers/user/Makefile +++ b/controllers/user/Makefile @@ -65,7 +65,7 @@ test: manifests generate fmt vet envtest ## Run tests. .PHONY: build build: ## Build manager binary. - CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build -o bin/manager main.go + CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build -ldflags "-s -w" -trimpath -o bin/manager main.go .PHONY: run run: manifests generate fmt vet ## Run a controller from your host. diff --git a/service/account/Makefile b/service/account/Makefile index fcf211938e0..a00677e3a90 100644 --- a/service/account/Makefile +++ b/service/account/Makefile @@ -43,7 +43,9 @@ clean: .PHONY: build build: ## Build service-hub binary. - CGO_ENABLED=0 GOOS=linux go build $(shell [ -n "${CRYPTOKEY}" ] && echo "-ldflags '-X github.com/labring/sealos/controllers/pkg/crypto.encryptionKey=${CRYPTOKEY}'") -o bin/manager main.go + LD_FLAGS="-s -w"; \ + [ -n "$(CRYPTOKEY)" ] && LD_FLAGS+="-X github.com/labring/sealos/controllers/pkg/crypto.encryptionKey=${CRYPTOKEY}"; \ + CGO_ENABLED=0 GOOS=linux go build -ldflags "$${LD_FLAGS}" -trimpath -o bin/manager main.go .PHONY: docker-build docker-build: build diff --git a/webhooks/admission/Makefile b/webhooks/admission/Makefile index b1b0208a824..979100c8d54 100644 --- a/webhooks/admission/Makefile +++ b/webhooks/admission/Makefile @@ -65,7 +65,7 @@ test: manifests generate fmt vet envtest ## Run tests. .PHONY: build build: ## Build manager binary. - CGO_ENABLED=0 GOOS=linux go build -o bin/manager cmd/main.go + CGO_ENABLED=0 GOOS=linux go build -ldflags "-s -w" -trimpath -o bin/manager cmd/main.go .PHONY: run run: manifests generate fmt vet ## Run a controller from your host.