From b8b470744340937c7fba6b0467a378265ba6c30c Mon Sep 17 00:00:00 2001 From: djkormo Date: Sat, 24 Feb 2024 20:33:43 +0100 Subject: [PATCH] fixing Makefile --- Makefile | 71 ++++++++++++++++++++++++++++++++++++++++++++++++------ deploy.env | 3 +++ 2 files changed, 66 insertions(+), 8 deletions(-) create mode 100644 deploy.env diff --git a/Makefile b/Makefile index 074d675..88f4bdb 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,7 @@ +dpl ?= deploy.env +include $(dpl) +export $(shell sed 's/=.*//' $(dpl)) # VERSION defines the project version for the bundle. # Update this value when you upgrade the version of your project. # To re-generate a bundle for another specific version without changing the standard setup, you can: @@ -6,6 +9,11 @@ # - use environment variables to overwrite this value (e.g export VERSION=0.0.2) VERSION ?= 0.0.1 +COMMIT?=$(shell git rev-parse --short HEAD) +BUILD_TIME?=$(shell date -u '+%Y-%m-%d_%H:%M:%S') + +PROJECT?=github.com/nokia/adcs-issuer + # CHANNELS define the bundle channels used in the bundle. # Add a new line here if you would like to change its default config. (E.g CHANNELS = "candidate,fast,stable") # To re-generate a bundle for other specific channels without changing the standard setup, you can: @@ -107,23 +115,20 @@ vet: ## Run go vet against code. test: manifests generate fmt vet envtest ## Run tests. KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test ./... -coverprofile cover.out +.PHONY clean: + go clean + ##@ Build .PHONY: build -build: generate fmt vet ## Build manager binary. +build: clean generate + go fmt vet ## Build manager binary. go build -o bin/manager main.go .PHONY: run run: manifests generate fmt vet ## Run a controller from your host. go run ./main.go -.PHONY: docker-build -docker-build: test ## Build docker image with the manager. - docker build -t ${IMG} . - -.PHONY: docker-push -docker-push: ## Push docker image with the manager. - docker push ${IMG} ##@ Deployment @@ -254,3 +259,53 @@ sim-install: sim mkdir -p /usr/local/adcs-sim cp -R test/adcs-sim/ca test/adcs-sim/templates /usr/local/adcs-sim + + +.PHONY: operator-build +operator-build: + go clean + go fmt ## Build manager binary. + go vet + CGO_ENABLED=0 GOOS=${GOOS} GOARCH=${GOARCH} go build \ + -ldflags "-s -w -X ${PROJECT}/version.Release=${VERSION} \ + -X ${PROJECT}/version.Commit=${COMMIT} -X ${PROJECT}/version.BuildTime=${BUILD_TIME}" \ + -o ${APP_NAME} + + + +.PHONY: docker-build +docker-build: ## Build docker image with the manager. + DOCKER_BUILDKIT=1 docker build -t $(APP_NAME) . --progress=plain + +.PHONY: docker-push +docker-push: ## Push docker image with the manager. + docker push $(APP_NAME) + +# Docker publish +publish: repo-login publish-latest publish-version ## Publish the `{version}` ans `latest` tagged containers to ECR + +publish-latest: tag-latest ## Publish the `latest` taged container to ECR + @echo 'publish latest to $(DOCKER_REPO)' + docker push $(DOCKER_REPO)/$(APP_NAME):latest + +publish-version: tag-version ## Publish the `{version}` taged container to ECR + @echo 'publish $(VERSION) to $(DOCKER_REPO)' + docker push $(DOCKER_REPO)/$(APP_NAME):$(VERSION) + +# Docker tagging +tag: tag-latest tag-version ## Generate container tags for the `{version}` ans `latest` tags + +tag-latest: ## Generate container `{version}` tag + @echo 'create tag latest' + docker tag $(APP_NAME) $(DOCKER_REPO)/$(APP_NAME):latest + +tag-version: ## Generate container `latest` tag + @echo 'create tag $(VERSION)' + docker tag $(APP_NAME) $(DOCKER_REPO)/$(APP_NAME):$(VERSION) + + + +inspect: ## Generate container `latest` tag + @echo 'inspect $(APP_NAME)' + docker history $(APP_NAME) + docker inspect $(APP_NAME) \ No newline at end of file diff --git a/deploy.env b/deploy.env new file mode 100644 index 0000000..19338ed --- /dev/null +++ b/deploy.env @@ -0,0 +1,3 @@ +APP_NAME=adcs-issuer +DOCKER_REPO=djkormo +VERSION=2.0.9