Skip to content

Commit

Permalink
Makefile: add build parameters
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
raghavendra-talur authored and ShyamsundarR committed May 2, 2024
1 parent 1f55849 commit 117578c
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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=<some-registry>/<project-name-bundle>:<tag>)
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)
Expand All @@ -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

Expand Down Expand Up @@ -262,15 +258,15 @@ 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.
$(MAKE) docker-push IMG=$(BUNDLE_IMG)

.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
Expand All @@ -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)
Expand Down

0 comments on commit 117578c

Please sign in to comment.