From 117578cfe840eaa055bab287af2aaecee4147532 Mon Sep 17 00:00:00 2001 From: Raghavendra Talur Date: Thu, 2 May 2024 02:22:20 -0400 Subject: [PATCH] Makefile: add build parameters This commit makes it easy to change the names of the build artifacts. Mainly, 1. Image name 2. Image repository 3. Image registry 4. Image tag Signed-off-by: Raghavendra Talur --- Makefile | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index 6f764a9..d2ff87b 100644 --- a/Makefile +++ b/Makefile @@ -24,19 +24,17 @@ BUNDLE_DEFAULT_CHANNEL := --default-channel=$(DEFAULT_CHANNEL) endif BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL) -# IMAGE_TAG_BASE defines the docker.io namespace and part of the image name for remote images. -# This variable is used to construct full image tags for bundle and catalog images. -# -# For example, running 'make bundle-build bundle-push catalog-build catalog-push' will build and push both -# openshift.io/recipe-bundle:$VERSION and openshift.io/recipe-catalog:$VERSION. -IMAGE_TAG_BASE ?= openshift.io/recipe +# Variables for the container image name +IMAGE_REGISTRY ?= quay.io +IMAGE_REPOSITORY ?= ramendr +IMAGE_NAME ?= recipe +IMAGE_TAG ?= latest -# BUNDLE_IMG defines the image:tag used for the bundle. -# You can use it as an arg. (E.g make bundle-build BUNDLE_IMG=/:) -BUNDLE_IMG ?= $(IMAGE_TAG_BASE)-bundle:v$(VERSION) +# IMG defines the image:tag used for the operator. +IMG ?= $(IMAGE_REGISTRY)/$(IMAGE_REPOSITORY)/$(IMAGE_NAME)-operator:$(IMAGE_TAG) -# CRD_BUNDLE_IMG defines the image:tag used for the crd bundle. -CRD_BUNDLE_IMG ?= $(IMAGE_TAG_BASE)-crd-bundle:v$(VERSION) +# BUNDLE_IMG defines the image:tag used for the bundle. +BUNDLE_IMG ?= $(IMAGE_REGISTRY)/$(IMAGE_REPOSITORY)/$(IMAGE_NAME)-bundle:$(IMAGE_TAG) # BUNDLE_GEN_FLAGS are the flags passed to the operator-sdk generate bundle command BUNDLE_GEN_FLAGS ?= -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS) @@ -49,8 +47,6 @@ ifeq ($(USE_IMAGE_DIGESTS), true) BUNDLE_GEN_FLAGS += --use-image-digests endif -# Image URL to use all building/pushing image targets -IMG ?= controller:latest # ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary. ENVTEST_K8S_VERSION = 1.25.0 @@ -262,7 +258,7 @@ bundle-build: bundle ## Build the bundle image. .PHONY: crd-bundle-build crd-bundle-build: crd-bundle ## Build the crd bundle image. - $(DOCKERCMD) build -f bundle.Dockerfile -t $(CRD_BUNDLE_IMG) . + $(DOCKERCMD) build -f bundle.Dockerfile -t $(BUNDLE_IMG) . .PHONY: bundle-push bundle-push: ## Push the bundle image. @@ -270,7 +266,7 @@ bundle-push: ## Push the bundle image. .PHONY: crd-bundle-push crd-bundle-push: ## Push the bundle image. - $(MAKE) docker-push IMG=$(CRD_BUNDLE_IMG) + $(MAKE) docker-push IMG=$(BUNDLE_IMG) .PHONY: opm OPM = ./bin/opm @@ -294,7 +290,7 @@ endif BUNDLE_IMGS ?= $(BUNDLE_IMG) # The image tag given to the resulting catalog image (e.g. make catalog-build CATALOG_IMG=example.com/operator-catalog:v0.2.0). -CATALOG_IMG ?= $(IMAGE_TAG_BASE)-catalog:v$(VERSION) +CATALOG_IMG ?= $(IMAGE_REGISTRY)/$(IMAGE_REPOSITORY)/$(IMAGE_NAME)-catalog:$(IMAGE_TAG) # Set CATALOG_BASE_IMG to an existing catalog image tag to add $BUNDLE_IMGS to that image. ifneq ($(origin CATALOG_BASE_IMG), undefined)