diff --git a/Makefile b/Makefile index 393798dcdb2..bc54733a5a7 100644 --- a/Makefile +++ b/Makefile @@ -1,16 +1,14 @@ # variables that should not be overridden by the user -GIT_COMMIT = $(shell git rev-parse HEAD || echo unknown) -GIT_COMMIT_SHORT = $(shell echo ${GIT_COMMIT} | cut -c1-7) GIT_TAG = $(shell git describe --tags --abbrev=0 || echo untagged) -VERSION = $(GIT_TAG)-SNAPSHOT-$(GIT_COMMIT_SHORT) +VERSION = $(GIT_TAG)-SNAPSHOT PLUS_ARGS = --secret id=nginx-repo.crt,src=nginx-repo.crt --secret id=nginx-repo.key,src=nginx-repo.key # variables that can be overridden by the user -PREFIX ?= nginx/nginx-ingress## The name of the image. For example, nginx/nginx-ingress -TAG ?= $(VERSION:v%=%)## The tag of the image. For example, 2.0.0 -TARGET ?= local## The target of the build. Possible values: local, container and download -override DOCKER_BUILD_OPTIONS += --build-arg IC_VERSION=$(VERSION) --build-arg GIT_COMMIT=$(GIT_COMMIT)## The options for the docker build command. For example, --pull. -ARCH ?= amd64## The architecture of the image or binary. For example: amd64, arm64, ppc64le, s390x. Not all architectures are supported for all targets. +PREFIX ?= nginx/nginx-ingress ## The name of the image. For example, nginx/nginx-ingress +TAG ?= $(VERSION:v%=%) ## The tag of the image. For example, 2.0.0 +TARGET ?= local ## The target of the build. Possible values: local, container and download +override DOCKER_BUILD_OPTIONS += --build-arg IC_VERSION=$(VERSION) ## The options for the docker build command. For example, --pull +ARCH ?= amd64 ## The architecture of the image or binary. For example: amd64, arm64, ppc64le, s390x. Not all architectures are supported for all targets # final docker build command DOCKER_CMD = docker build --platform linux/$(ARCH) $(strip $(DOCKER_BUILD_OPTIONS)) --target $(strip $(TARGET)) -f build/Dockerfile -t $(strip $(PREFIX)):$(strip $(TAG)) . @@ -22,7 +20,7 @@ export DOCKER_BUILDKIT = 1 .PHONY: help help: Makefile ## Display this help @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "; printf "Usage:\n\n make \033[36m\033[0m [VARIABLE=value...]\n\nTargets:\n\n"}; {printf " \033[36m%-30s\033[0m %s\n", $$1, $$2}' - @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}' + @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}' .PHONY: all all: test lint verify-codegen update-crds debian-image @@ -85,7 +83,7 @@ endif .PHONY: download-binary-docker download-binary-docker: ## Download Docker image from which to extract Ingress Controller binary, TARGET=download is required ifeq (${TARGET},download) -DOWNLOAD_TAG := $(shell ./hack/docker.sh $(GIT_COMMIT) $(GIT_TAG)) +DOWNLOAD_TAG := $(shell ./hack/docker.sh $(GIT_TAG)) ifeq ($(DOWNLOAD_TAG),fail) $(error unable to build with TARGET=download, this function is only available when building from a git tag or from the latest commit matching the edge image) endif @@ -114,15 +112,15 @@ debian-image-plus: build ## Create Docker image for Ingress Controller (Debian w $(DOCKER_CMD) $(PLUS_ARGS) --build-arg BUILD_OS=debian-plus .PHONY: debian-image-nap-plus -debian-image-nap-plus: build ## Create Docker image for Ingress Controller (Debian with NGINX Plus and App Protect WAF) +debian-image-nap-plus: build ## Create Docker image for Ingress Controller (Debian with NGINX Plus and NGINX App Protect WAF) $(DOCKER_CMD) $(PLUS_ARGS) --build-arg BUILD_OS=debian-plus-nap --build-arg NAP_MODULES=waf .PHONY: debian-image-dos-plus -debian-image-dos-plus: build ## Create Docker image for Ingress Controller (Debian with NGINX Plus and App Protect DoS) +debian-image-dos-plus: build ## Create Docker image for Ingress Controller (Debian with NGINX Plus and NGINX App Protect DoS) $(DOCKER_CMD) $(PLUS_ARGS) --build-arg BUILD_OS=debian-plus-nap --build-arg NAP_MODULES=dos .PHONY: debian-image-nap-dos-plus -debian-image-nap-dos-plus: build ## Create Docker image for Ingress Controller (Debian with NGINX Plus, App Protect WAF and DoS) +debian-image-nap-dos-plus: build ## Create Docker image for Ingress Controller (Debian with NGINX Plus, NGINX App Protect WAF and DoS) $(DOCKER_CMD) $(PLUS_ARGS) --build-arg BUILD_OS=debian-plus-nap --build-arg NAP_MODULES=waf,dos .PHONY: ubi-image @@ -134,30 +132,17 @@ ubi-image-plus: build ## Create Docker image for Ingress Controller (UBI with NG $(DOCKER_CMD) $(PLUS_ARGS) --build-arg BUILD_OS=ubi-plus .PHONY: ubi-image-nap-plus -ubi-image-nap-plus: build ## Create Docker image for Ingress Controller (UBI with NGINX Plus and App Protect WAF) +ubi-image-nap-plus: build ## Create Docker image for Ingress Controller (UBI with NGINX Plus and NGINX App Protect WAF) $(DOCKER_CMD) $(PLUS_ARGS) --secret id=rhel_license,src=rhel_license --build-arg BUILD_OS=ubi-plus-nap --build-arg NAP_MODULES=waf .PHONY: ubi-image-dos-plus -ubi-image-dos-plus: build ## Create Docker image for Ingress Controller (UBI with NGINX Plus and App Protect DoS) +ubi-image-dos-plus: build ## Create Docker image for Ingress Controller (UBI with NGINX Plus and NGINX App Protect DoS) $(DOCKER_CMD) $(PLUS_ARGS) --secret id=rhel_license,src=rhel_license --build-arg BUILD_OS=ubi-plus-nap --build-arg NAP_MODULES=dos .PHONY: ubi-image-nap-dos-plus -ubi-image-nap-dos-plus: build ## Create Docker image for Ingress Controller (UBI with NGINX Plus, App Protect WAF and DoS) +ubi-image-nap-dos-plus: build ## Create Docker image for Ingress Controller (UBI with NGINX Plus, NGINX App Protect WAF and DoS) $(DOCKER_CMD) $(PLUS_ARGS) --secret id=rhel_license,src=rhel_license --build-arg BUILD_OS=ubi-plus-nap --build-arg NAP_MODULES=waf,dos -.PHONY: openshift-image openshift-image-plus openshift-image-nap-plus openshift-image-dos-plus openshift-image-nap-dos-plus -openshift-image openshift-image-plus openshift-image-nap-plus openshift-image-dos-plus openshift-image-nap-dos-plus: - @printf "\033[0;31mWarning\033[0m: The target $(filter openshift-%,$(MAKECMDGOALS)) was renamed to $(subst openshift,ubi,$(filter openshift-%,$(MAKECMDGOALS))) and will be removed in a future release.\n" - @$(MAKE) $(subst openshift,ubi,$(MAKECMDGOALS)) $(MAKEFLAGS) - -.PHONY: alpine-image-opentracing -alpine-image-opentracing: - @echo "OpenTracing is now included in all Alpine based images" - -.PHONY: debian-image-opentracing debian-image-opentracing-plus -debian-image-opentracing debian-image-opentracing-plus: - @echo "OpenTracing is now included in all Debian based images" - .PHONY: all-images ## Create all the Docker images for Ingress Controller all-images: alpine-image alpine-image-plus debian-image debian-image-plus debian-image-nap-plus debian-image-dos-plus debian-image-nap-dos-plus ubi-image ubi-image-plus ubi-image-nap-plus ubi-image-dos-plus ubi-image-nap-dos-plus diff --git a/build/Dockerfile b/build/Dockerfile index 221ddcd8fdb..5381252b3bb 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -187,7 +187,6 @@ FROM ${BUILD_OS} as common ARG BUILD_OS ARG IC_VERSION -ARG GIT_COMMIT ARG TARGETPLATFORM ARG NAP_MODULES=none @@ -224,7 +223,6 @@ ENTRYPOINT ["/nginx-ingress"] USER 101 LABEL org.opencontainers.image.version="${IC_VERSION}" -LABEL org.opencontainers.image.revision="${GIT_COMMIT}" LABEL org.nginx.kic.image.build.target="${TARGETPLATFORM}" LABEL org.nginx.kic.image.build.os="${BUILD_OS}" LABEL org.nginx.kic.image.build.nginx.version="${NGINX_PLUS_VERSION}${NGINX_VERSION}" diff --git a/hack/docker.sh b/hack/docker.sh index ed79b501cf7..5b608bbc14f 100755 --- a/hack/docker.sh +++ b/hack/docker.sh @@ -1,9 +1,9 @@ #!/usr/bin/env bash -git_commit=$1 -git_tag=$2 +git_tag=$1 docker_tag=edge +git_commit=$(git rev-parse HEAD) commit_tag=$(git describe --exact-match ${git_commit} 2>/dev/null) if [[ ${commit_tag} == ${git_tag} ]]; then