22VERSION = edge
33GIT_COMMIT = $(shell git rev-parse HEAD || echo "unknown")
44DATE = $(shell date -u +"% Y-% m-% dT% H:% M:% SZ")
5+ SELF_DIR := $(dir $(lastword $(MAKEFILE_LIST ) ) )
56MANIFEST_DIR = $(CURDIR ) /deploy/manifests
6- CHART_DIR = $(CURDIR ) / charts/nginx-gateway-fabric
7+ CHART_DIR = $(SELF_DIR ) charts/nginx-gateway-fabric
78NGINX_CONF_DIR = internal/mode/static/nginx/conf
89NJS_DIR = internal/mode/static/nginx/modules/src
910NGINX_DOCKER_BUILD_PLUS_ARGS = --secret id=nginx-repo.crt,src=nginx-repo.crt --secret id=nginx-repo.key,src=nginx-repo.key
1011BUILD_AGENT =local
12+ PLUS_ENABLED ?= false
1113
1214PROD_TELEMETRY_ENDPOINT = oss.edge.df.f5.com:443
1315# the telemetry related variables below are also configured in goreleaser.yml
@@ -16,7 +18,7 @@ TELEMETRY_ENDPOINT=# if empty, NGF will report telemetry in its logs at debug le
1618TELEMETRY_ENDPOINT_INSECURE = false
1719
1820GW_API_VERSION = 1.1.0
19- ENABLE_EXPERIMENTAL = false
21+ ENABLE_EXPERIMENTAL ? = false
2022NODE_VERSION = $(shell cat .nvmrc)
2123
2224# go build flags - should not be overridden by the user
@@ -31,18 +33,23 @@ NGINX_PLUS_PREFIX ?= $(PREFIX)/nginx-plus## The name of the nginx plus image. Fo
3133TAG ?= $(VERSION:v%=% ) # # The tag of the image. For example, 1.1.0
3234TARGET ?= local# # The target of the build. Possible values: local and container
3335KIND_KUBE_CONFIG=$${HOME}/.kube/kind/config# # The location of the kind kubeconfig
34- OUT_DIR ?= $( CURDIR ) / build/out# # The folder where the binary will be stored
36+ OUT_DIR ?= build/out# # The folder where the binary will be stored
3537GOARCH ?= amd64# # The architecture of the image and/or binary. For example: amd64 or arm64
3638GOOS ?= linux# # The OS of the image and/or binary. For example: linux or darwin
3739override HELM_TEMPLATE_COMMON_ARGS += --set creator=template --set nameOverride=nginx-gateway# # The common options for the Helm template command.
3840override HELM_TEMPLATE_EXTRA_ARGS_FOR_ALL_MANIFESTS_FILE += --set service.create=false# # The options to be passed to the full Helm templating command only.
3941override NGINX_DOCKER_BUILD_OPTIONS += --build-arg NJS_DIR=$(NJS_DIR ) --build-arg NGINX_CONF_DIR=$(NGINX_CONF_DIR ) --build-arg BUILD_AGENT=$(BUILD_AGENT )
42+
4043.DEFAULT_GOAL := help
4144
45+ ifneq (,$(findstring plus,$(MAKECMDGOALS ) ) )
46+ PLUS_ENABLED = true
47+ endif
48+
4249.PHONY : help
4350help : Makefile # # Display this help
44- @grep -E ' ^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST ) | sort | awk ' BEGIN {FS = ":.*?## "; printf "Usage:\n\n make \033[36m<target>\033[0m [VARIABLE=value...]\n\nTargets:\n\n"}; {printf " \033[36m%-30s\033[0m %s\n", $$1, $$2}'
45- @grep -E ' ^(override )?[a-zA-Z_-]+ \??\+?= .*?## .*$$' $< | sort | awk ' BEGIN {FS = " \\??\\+?= .*?## "; printf "\nVariables:\n\n"}; {gsub(/override /, "", $$1); printf " \033[36m%-30s\033[0m %s\n", $$1, $$2}'
51+ @grep -hE ' ^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST ) | sort | awk ' BEGIN {FS = ":.*?## "; printf "Usage:\n\n make \033[36m<target>\033[0m [VARIABLE=value...]\n\nTargets:\n\n"}; {printf " \033[36m%-30s\033[0m %s\n", $$1, $$2}'
52+ @grep -hE ' ^(override )?[a-zA-Z_-]+ \??\+?= .*?## .*$$' $( MAKEFILE_LIST ) | sort | awk ' BEGIN {FS = " \\??\\+?= .*?## "; printf "\nVariables:\n\n"}; {gsub(/override /, "", $$1); printf " \033[36m%-30s\033[0m %s\n", $$1, $$2}'
4653
4754.PHONY : build-prod-images
4855build-prod-images : build-prod-ngf-image build-prod-nginx-image # # Build the NGF and nginx docker images for production
@@ -62,21 +69,21 @@ build-prod-ngf-image: build-ngf-image ## Build the NGF docker image for producti
6269
6370.PHONY : build-ngf-image
6471build-ngf-image : check-for-docker build # # Build the NGF docker image
65- docker build --platform linux/$(GOARCH ) --build-arg BUILD_AGENT=$(BUILD_AGENT ) --target $(strip $(TARGET ) ) -f build/Dockerfile -t $(strip $(PREFIX ) ) :$(strip $(TAG ) ) .
72+ docker build --platform linux/$(GOARCH ) --build-arg BUILD_AGENT=$(BUILD_AGENT ) --target $(strip $(TARGET ) ) -f $( SELF_DIR ) build/Dockerfile -t $(strip $(PREFIX ) ) :$(strip $(TAG ) ) $( strip $( SELF_DIR ) )
6673
6774.PHONY : build-prod-nginx-image
6875build-prod-nginx-image : build-nginx-image # # Build the custom nginx image for production
6976
7077.PHONY : build-nginx-image
7178build-nginx-image : check-for-docker # # Build the custom nginx image
72- docker build --platform linux/$(GOARCH ) $(strip $(NGINX_DOCKER_BUILD_OPTIONS ) ) -f build/Dockerfile.nginx -t $(strip $(NGINX_PREFIX ) ) :$(strip $(TAG ) ) .
79+ docker build --platform linux/$(GOARCH ) $(strip $(NGINX_DOCKER_BUILD_OPTIONS ) ) -f $( SELF_DIR ) build/Dockerfile.nginx -t $(strip $(NGINX_PREFIX ) ) :$(strip $(TAG ) ) $( strip $( SELF_DIR ) )
7380
7481.PHONY : build-prod-nginx-plus-image
7582build-prod-nginx-plus-image : build-nginx-plus-image # # Build the custom nginx plus image for production
7683
7784.PHONY : build-nginx-plus-image
7885build-nginx-plus-image : check-for-docker # # Build the custom nginx plus image
79- docker build --platform linux/$(GOARCH ) $(strip $(NGINX_DOCKER_BUILD_OPTIONS ) ) $(strip $(NGINX_DOCKER_BUILD_PLUS_ARGS ) ) -f build/Dockerfile.nginxplus -t $(strip $(NGINX_PLUS_PREFIX ) ) :$(strip $(TAG ) ) .
86+ docker build --platform linux/$(GOARCH ) $(strip $(NGINX_DOCKER_BUILD_OPTIONS ) ) $(strip $(NGINX_DOCKER_BUILD_PLUS_ARGS ) ) -f $( SELF_DIR ) build/Dockerfile.nginxplus -t $(strip $(NGINX_PLUS_PREFIX ) ) :$(strip $(TAG ) ) $( strip $( SELF_DIR ) )
8087
8188.PHONY : check-for-docker
8289check-for-docker : # # Check if Docker is installed
@@ -86,7 +93,7 @@ check-for-docker: ## Check if Docker is installed
8693build : # # Build the binary
8794ifeq (${TARGET},local)
8895 @go version || (code=$$?; printf "\033[0;31mError\033[0m: unable to build locally\n"; exit $$code)
89- CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) go build -trimpath -a -ldflags "$(GO_LINKER_FLAGS)" $(ADDITIONAL_GO_BUILD_FLAGS) -o $(OUT_DIR)/gateway github.com/nginxinc/nginx-gateway-fabric/cmd/gateway
96+ CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) go build -C $(SELF_DIR) - trimpath -a -ldflags "$(GO_LINKER_FLAGS)" $(ADDITIONAL_GO_BUILD_FLAGS) -o $(OUT_DIR)/gateway github.com/nginxinc/nginx-gateway-fabric/cmd/gateway
9097endif
9198
9299.PHONY : build-goreleaser
@@ -103,13 +110,25 @@ generate-crds: ## Generate CRDs and Go types using kubebuilder
103110 go run sigs.k8s.io/controller-tools/cmd/controller-gen crd object paths=./apis/... output:crd:artifacts:config=config/crd/bases
104111 kubectl kustomize config/crd > deploy/crds.yaml
105112
113+ .PHONY : install-crds
114+ install-crds : # # Install CRDs
115+ kubectl kustomize config/crd | kubectl apply -f -
116+
117+ .PHONY : install-gateway-crds
118+ install-gateway-crds : # # Install Gateway API CRDs
119+ $(SELF_DIR ) tests/scripts/install-gateway.sh $(GW_API_VERSION ) $(ENABLE_EXPERIMENTAL )
120+
121+ .PHONY : uninstall-gateway-crds
122+ uninstall-gateway-crds : # # Uninstall Gateway API CRDs
123+ $(SELF_DIR ) tests/scripts/uninstall-gateway.sh $(GW_API_VERSION ) $(ENABLE_EXPERIMENTAL )
124+
106125.PHONY : generate-manifests
107126generate-manifests : # # Generate manifests using Helm.
108127 helm template nginx-gateway $(CHART_DIR ) $(HELM_TEMPLATE_COMMON_ARGS ) $(HELM_TEMPLATE_EXTRA_ARGS_FOR_ALL_MANIFESTS_FILE ) -n nginx-gateway | cat $(strip $(MANIFEST_DIR ) ) /namespace.yaml - > $(strip $(MANIFEST_DIR ) ) /nginx-gateway.yaml
109128 helm template nginx-gateway $(CHART_DIR ) $(HELM_TEMPLATE_COMMON_ARGS ) $(HELM_TEMPLATE_EXTRA_ARGS_FOR_ALL_MANIFESTS_FILE ) --set nginx.plus=true --set nginx.image.repository=$(NGINX_PLUS_PREFIX ) -n nginx-gateway | cat $(strip $(MANIFEST_DIR ) ) /namespace.yaml - > $(strip $(MANIFEST_DIR ) ) /nginx-plus-gateway.yaml
110129 helm template nginx-gateway $(CHART_DIR ) $(HELM_TEMPLATE_COMMON_ARGS ) $(HELM_TEMPLATE_EXTRA_ARGS_FOR_ALL_MANIFESTS_FILE ) --set nginxGateway.gwAPIExperimentalFeatures.enable=true -n nginx-gateway | cat $(strip $(MANIFEST_DIR ) ) /namespace.yaml - > $(strip $(MANIFEST_DIR ) ) /nginx-gateway-experimental.yaml
111130 helm template nginx-gateway $(CHART_DIR ) $(HELM_TEMPLATE_COMMON_ARGS ) $(HELM_TEMPLATE_EXTRA_ARGS_FOR_ALL_MANIFESTS_FILE ) --set nginxGateway.gwAPIExperimentalFeatures.enable=true --set nginx.plus=true --set nginx.image.repository=$(NGINX_PLUS_PREFIX ) -n nginx-gateway | cat $(strip $(MANIFEST_DIR ) ) /namespace.yaml - > $(strip $(MANIFEST_DIR ) ) /nginx-plus-gateway-experimental.yaml
112- helm template nginx-gateway $(CHART_DIR ) $(HELM_TEMPLATE_COMMON_ARGS ) --set metrics.enable=false --set nginxGateway.productTelemetry.enable=false -n nginx-gateway -s templates/deployment.yaml > conformance/provisioner /static-deployment.yaml
131+ helm template nginx-gateway $(CHART_DIR ) $(HELM_TEMPLATE_COMMON_ARGS ) --set metrics.enable=false --set nginxGateway.productTelemetry.enable=false -n nginx-gateway -s templates/deployment.yaml > config/tests /static-deployment.yaml
113132 helm template nginx-gateway $(CHART_DIR ) $(HELM_TEMPLATE_COMMON_ARGS ) -n nginx-gateway -s templates/service.yaml > $(strip $(MANIFEST_DIR ) ) /service/loadbalancer.yaml
114133 helm template nginx-gateway $(CHART_DIR ) $(HELM_TEMPLATE_COMMON_ARGS ) --set service.annotations.' service\.beta\.kubernetes\.io\/aws-load-balancer-type' =" nlb" -n nginx-gateway -s templates/service.yaml > $(strip $(MANIFEST_DIR ) ) /service/loadbalancer-aws-nlb.yaml
115134 helm template nginx-gateway $(CHART_DIR ) $(HELM_TEMPLATE_COMMON_ARGS ) --set service.type=NodePort --set service.externalTrafficPolicy=" " -n nginx-gateway -s templates/service.yaml > $(strip $(MANIFEST_DIR ) ) /service/nodeport.yaml
@@ -128,7 +147,7 @@ deps: ## Add missing and remove unused modules, verify deps and download them to
128147
129148.PHONY : create-kind-cluster
130149create-kind-cluster : # # Create a kind cluster
131- $(eval KIND_IMAGE=$(shell grep -m1 'FROM kindest/node' <conformance/ tests/Dockerfile | awk -F'[ ]' '{print $$2}') )
150+ $(eval KIND_IMAGE=$(shell grep -m1 'FROM kindest/node' <$( SELF_DIR ) tests/Dockerfile | awk -F'[ ]' '{print $$2}') )
132151 kind create cluster --image $(KIND_IMAGE )
133152 kind export kubeconfig --kubeconfig $(KIND_KUBE_CONFIG )
134153
@@ -189,14 +208,12 @@ install-ngf-local-build: build-images load-images helm-install-local ## Install
189208install-ngf-local-build-with-plus : build-images-with-plus load-images-with-plus helm-install-local-with-plus # # Install NGF with NGINX Plus from local build on configured kind cluster.
190209
191210.PHONY : helm-install-local
192- helm-install-local : # # Helm install NGF on configured kind cluster with local images. To build, load, and install with helm run make install-ngf-local-build.
193- ./conformance/scripts/install-gateway.sh $(GW_API_VERSION ) $(ENABLE_EXPERIMENTAL )
194- helm install dev $(CHART_DIR ) --create-namespace --wait --set service.type=NodePort --set nginxGateway.image.repository=$(PREFIX ) --set nginxGateway.image.tag=$(TAG ) --set nginxGateway.image.pullPolicy=Never --set nginx.image.repository=$(NGINX_PREFIX ) --set nginx.image.tag=$(TAG ) --set nginx.image.pullPolicy=Never --set nginxGateway.gwAPIExperimentalFeatures.enable=$(ENABLE_EXPERIMENTAL ) -n nginx-gateway
211+ helm-install-local : install-gateway-crds # # Helm install NGF on configured kind cluster with local images. To build, load, and install with helm run make install-ngf-local-build.
212+ helm install nginx-gateway $(CHART_DIR ) --set nginx.image.repository=$(NGINX_PREFIX ) --create-namespace --wait --set nginxGateway.image.pullPolicy=Never --set service.type=NodePort --set nginxGateway.image.repository=$(PREFIX ) --set nginxGateway.image.tag=$(TAG ) --set nginx.image.tag=$(TAG ) --set nginx.image.pullPolicy=Never --set nginxGateway.gwAPIExperimentalFeatures.enable=$(ENABLE_EXPERIMENTAL ) -n nginx-gateway $(HELM_PARAMETERS )
195213
196214.PHONY : helm-install-local-with-plus
197- helm-install-local-with-plus : # # Helm install NGF with NGINX Plus on configured kind cluster with local images. To build, load, and install with helm run make install-ngf-local-build-with-plus.
198- ./conformance/scripts/install-gateway.sh $(GW_API_VERSION ) $(ENABLE_EXPERIMENTAL )
199- helm install dev $(CHART_DIR ) --create-namespace --wait --set service.type=NodePort --set nginxGateway.image.repository=$(PREFIX ) --set nginxGateway.image.tag=$(TAG ) --set nginxGateway.image.pullPolicy=Never --set nginx.image.repository=$(NGINX_PLUS_PREFIX ) --set nginx.image.tag=$(TAG ) --set nginx.image.pullPolicy=Never --set nginx.plus=true --set nginxGateway.gwAPIExperimentalFeatures.enable=$(ENABLE_EXPERIMENTAL ) -n nginx-gateway
215+ helm-install-local-with-plus : install-gateway-crds # # Helm install NGF with NGINX Plus on configured kind cluster with local images. To build, load, and install with helm run make install-ngf-local-build-with-plus.
216+ helm install nginx-gateway $(CHART_DIR ) --set nginx.image.repository=$(NGINX_PLUS_PREFIX ) --create-namespace --wait --set nginxGateway.image.pullPolicy=Never --set service.type=NodePort --set nginxGateway.image.repository=$(PREFIX ) --set nginxGateway.image.tag=$(TAG ) --set nginx.image.tag=$(TAG ) --set nginx.image.pullPolicy=Never --set nginxGateway.gwAPIExperimentalFeatures.enable=$(ENABLE_EXPERIMENTAL ) -n nginx-gateway --set nginx.plus=true $(HELM_PARAMETERS )
200217
201218# Debug Targets
202219.PHONY : debug-build
0 commit comments