github.com/nginxinc/kubernetes-ingress@v1.12.5/Makefile (about)

     1  PREFIX = nginx/nginx-ingress
     2  GIT_COMMIT = $(shell git rev-parse HEAD)
     3  GIT_COMMIT_SHORT = $(shell echo ${GIT_COMMIT} | cut -c1-7)
     4  GIT_TAG = $(shell git describe --tags --abbrev=0)
     5  DATE = $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
     6  VERSION = $(GIT_TAG)-SNAPSHOT-$(GIT_COMMIT_SHORT)
     7  TAG = $(VERSION:v%=%)
     8  TARGET ?= local
     9  
    10  override DOCKER_BUILD_OPTIONS += --build-arg IC_VERSION=$(VERSION) --build-arg GIT_COMMIT=$(GIT_COMMIT) --build-arg DATE=$(DATE)
    11  DOCKER_CMD = docker build $(DOCKER_BUILD_OPTIONS) --target $(TARGET) -f build/Dockerfile -t $(PREFIX):$(TAG) .
    12  PLUS_ARGS = --build-arg PLUS=-plus --build-arg FILES=plus-common --secret id=nginx-repo.crt,src=nginx-repo.crt --secret id=nginx-repo.key,src=nginx-repo.key
    13  
    14  export DOCKER_BUILDKIT = 1
    15  
    16  .DEFAULT_GOAL:=help
    17  
    18  .PHONY: help
    19  help: ## Display this help
    20  	@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}'
    21  
    22  .PHONY: all
    23  all: test lint verify-codegen update-crds debian-image
    24  
    25  .PHONY: lint
    26  lint: ## Run linter
    27  	@git fetch
    28  	docker run --pull always --rm -v $(shell pwd):/kubernetes-ingress -w /kubernetes-ingress -v $(shell go env GOCACHE):/cache/go -e GOCACHE=/cache/go -e GOLANGCI_LINT_CACHE=/cache/go -v $(shell go env GOPATH)/pkg:/go/pkg golangci/golangci-lint:latest git diff -p origin/master > /tmp/diff.patch && golangci-lint --color always run -v --new-from-patch=/tmp/diff.patch
    29  
    30  .PHONY: test
    31  test: ## Run tests
    32  	GO111MODULE=on go test ./...
    33  
    34  .PHONY: verify-codegen
    35  verify-codegen: ## Verify code generation
    36  	./hack/verify-codegen.sh
    37  
    38  .PHONY: update-codegen
    39  update-codegen: ## Generate code
    40  	./hack/update-codegen.sh
    41  
    42  .PHONY: update-crds
    43  update-crds: ## Update CRDs
    44  	go run sigs.k8s.io/controller-tools/cmd/controller-gen crd:crdVersions=v1 schemapatch:manifests=./deployments/common/crds/ paths=./pkg/apis/configuration/... output:dir=./deployments/common/crds
    45  	@cp -Rp deployments/common/crds/ deployments/helm-chart/crds
    46  
    47  .PHONY: certificate-and-key
    48  certificate-and-key: ## Create default cert and key
    49  	./build/generate_default_cert_and_key.sh
    50  
    51  .PHONY: build
    52  build: ## Build Ingress Controller binary
    53  	@docker -v || (code=$$?; printf "\033[0;31mError\033[0m: there was a problem with Docker\n"; exit $$code)
    54  ifeq (${TARGET},local)
    55  	@go version || (code=$$?; printf "\033[0;31mError\033[0m: unable to build locally, try using the parameter TARGET=container\n"; exit $$code)
    56  	CGO_ENABLED=0 GO111MODULE=on GOOS=linux go build -trimpath -ldflags "-s -w -X main.version=${VERSION} -X main.commit=${GIT_COMMIT} -X main.date=$(DATE)" -o nginx-ingress github.com/nginxinc/kubernetes-ingress/cmd/nginx-ingress
    57  endif
    58  
    59  .PHONY: debian-image
    60  debian-image: build ## Create Docker image for Ingress Controller (debian)
    61  	$(DOCKER_CMD) --build-arg BUILD_OS=debian
    62  
    63  .PHONY: alpine-image
    64  alpine-image: build ## Create Docker image for Ingress Controller (alpine)
    65  	$(DOCKER_CMD) --build-arg BUILD_OS=alpine
    66  
    67  .PHONY: alpine-image-plus
    68  alpine-image-plus: build ## Create Docker image for Ingress Controller (alpine plus)
    69  	$(DOCKER_CMD) $(PLUS_ARGS) --build-arg BUILD_OS=alpine-plus
    70  
    71  .PHONY: debian-image-plus
    72  debian-image-plus: build ## Create Docker image for Ingress Controller (nginx plus)
    73  	$(DOCKER_CMD) $(PLUS_ARGS) --build-arg BUILD_OS=debian-plus
    74  
    75  .PHONY: debian-image-nap-plus
    76  debian-image-nap-plus: build ## Create Docker image for Ingress Controller (nginx plus with nap)
    77  	$(DOCKER_CMD) $(PLUS_ARGS) --build-arg BUILD_OS=debian-plus-nap --build-arg FILES=nap-common --build-arg DEBIAN_VERSION=buster-slim
    78  
    79  .PHONY: openshift-image
    80  openshift-image: build ## Create Docker image for Ingress Controller (ubi)
    81  	$(DOCKER_CMD) --build-arg BUILD_OS=ubi --build-arg NGINX_VERSION=$(shell cat build/Dockerfile | grep -m1 "FROM nginx:" | cut -d":" -f2 | cut -d" " -f1)
    82  
    83  .PHONY: openshift-image-plus
    84  openshift-image-plus: build ## Create Docker image for Ingress Controller (ubi with plus)
    85  	$(DOCKER_CMD) $(PLUS_ARGS) --build-arg BUILD_OS=ubi-plus
    86  
    87  .PHONY: openshift-image-nap-plus
    88  openshift-image-nap-plus: build ## Create Docker image for Ingress Controller (ubi with plus and nap)
    89  	$(DOCKER_CMD) $(PLUS_ARGS) --secret id=rhel_license,src=rhel_license --build-arg BUILD_OS=ubi-plus-nap --build-arg FILES=nap-common
    90  
    91  .PHONY: debian-image-opentracing
    92  debian-image-opentracing: build ## Create Docker image for Ingress Controller (with opentracing)
    93  	$(DOCKER_CMD) --build-arg BUILD_OS=opentracing
    94  
    95  .PHONY: debian-image-opentracing-plus
    96  debian-image-opentracing-plus: build ## Create Docker image for Ingress Controller (with opentracing and plus)
    97  	$(DOCKER_CMD) $(PLUS_ARGS) --build-arg BUILD_OS=opentracing-plus
    98  
    99  .PHONY: all-images ## Create all the Docker images for Ingress Controller
   100  all-images: alpine-image alpine-image-plus debian-image debian-image-plus debian-image-nap-plus debian-image-opentracing debian-image-opentracing-plus openshift-image openshift-image-plus openshift-image-nap-plus
   101  
   102  .PHONY: push
   103  push: ## Docker push to $PREFIX and $TAG
   104  	docker push $(PREFIX):$(TAG)
   105  
   106  .PHONY: clean
   107  clean:  ## Remove nginx-ingress binary
   108  	-rm nginx-ingress
   109  	-rm -r dist
   110  
   111  .PHONY: deps
   112  deps: ## Add missing and remove unused modules, verify deps and dowload them to local cache
   113  	@go mod tidy && go mod verify && go mod download
   114  
   115  .PHONY: clean-cache
   116  clean-cache: ## Clean go cache
   117  	@go clean -modcache