Skip to content

Commit

Permalink
feat: strip bin and trimpath (#4860)
Browse files Browse the repository at this point in the history
  • Loading branch information
zijiren233 authored Jul 12, 2024
1 parent 1b92dcd commit 88961c5
Show file tree
Hide file tree
Showing 13 changed files with 24 additions and 14 deletions.
4 changes: 3 additions & 1 deletion controllers/account/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion controllers/app/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion controllers/db/adminer/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion controllers/job/heartbeat/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion controllers/job/init/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions controllers/license/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion controllers/node/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 3 additions & 1 deletion controllers/objectstorage/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 3 additions & 1 deletion controllers/resources/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion controllers/terminal/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion controllers/user/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 3 additions & 1 deletion service/account/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion webhooks/admission/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 88961c5

Please sign in to comment.