@@ -6,6 +6,11 @@ MANIFEST_DIR = $(shell pwd)/deploy/manifests
6
6
NJS_DIR = $(shell pwd) /internal/mode/static/nginx/modules/src
7
7
CHART_DIR = $(shell pwd) /deploy/helm-chart
8
8
9
+ # go build flags - should not be overridden by the user
10
+ GO_LINKER_FlAGS_VARS = -X main.version=${VERSION} -X main.commit=${GIT_COMMIT} -X main.date=${DATE}
11
+ GO_LINKER_FLAGS_OPTIMIZATIONS = -s -w
12
+ GO_LINKER_FLAGS = $(GO_LINKER_FLAGS_OPTIMIZATIONS ) $(GO_LINKER_FlAGS_VARS )
13
+
9
14
# variables that can be overridden by the user
10
15
PREFIX ?= nginx-kubernetes-gateway# # The name of the image. For example, nginx-kubernetes-gateway
11
16
TAG ?= $(VERSION:v%=% ) # # The tag of the image. For example, 0.3.0
@@ -31,7 +36,7 @@ container: build ## Build the container
31
36
build : # # Build the binary
32
37
ifeq (${TARGET},local)
33
38
@go version || (code=$$?; printf "\033[0;31mError\033[0m: unable to build locally\n"; exit $$code)
34
- CGO_ENABLED=0 GOOS=linux GOARCH=$(ARCH) go build -trimpath -a -ldflags "-s -w -X main.version=${VERSION} -X main.commit=${GIT_COMMIT} -X main.date=${DATE}" -o $(OUT_DIR)/gateway github.com/nginxinc/nginx-kubernetes-gateway/cmd/gateway
39
+ CGO_ENABLED=0 GOOS=linux GOARCH=$(ARCH) go build -trimpath -a -ldflags "$(GO_LINKER_FLAGS)" $(ADDITIONAL_GO_BUILD_FLAGS) -o $(OUT_DIR)/gateway github.com/nginxinc/nginx-kubernetes-gateway/cmd/gateway
35
40
endif
36
41
37
42
.PHONY : build-goreleaser
@@ -89,6 +94,7 @@ unit-test: ## Run unit tests for the go code
89
94
go test ./... -race -coverprofile cover.out
90
95
go tool cover -html=cover.out -o cover.html
91
96
97
+ .PHONY : njs-unit-test
92
98
njs-unit-test : # # Run unit tests for the njs httpmatches module
93
99
docker run --rm -w /modules \
94
100
-v $(PWD ) /internal/mode/static/nginx/modules:/modules/ \
@@ -103,5 +109,13 @@ generate-njs-yaml: ## Generate the njs-modules ConfigMap
103
109
lint-helm : # # Run the helm chart linter
104
110
helm lint $(CHART_DIR )
105
111
112
+ .PHONY : debug-build
113
+ debug-build : GO_LINKER_FLAGS=$(GO_LINKER_FlAGS_VARS )
114
+ debug-build : ADDITIONAL_GO_BUILD_FLAGS=-gcflags "all=-N -l"
115
+ debug-build : build # # Build binary with debug info, symbols, and no optimizations
116
+
117
+ .PHONY : debug-container
118
+ debug-container : debug-build container # # Build container with debug binary
119
+
106
120
.PHONY : dev-all
107
121
dev-all : deps fmt njs-fmt vet lint unit-test njs-unit-test # # Run all the development checks
0 commit comments