Skip to content

Commit

Permalink
Refactor Makefile to support customizable build tool
Browse files Browse the repository at this point in the history
This change provides the flexibility to use different container build tools by simply setting the `BUILD_TOOL` variable.

Signed-off-by: vbadrina <[email protected]>
  • Loading branch information
vbnrh committed Jun 20, 2024
1 parent acfbd5a commit 9739735
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/publish-images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
go-version: ${{ matrix.go }}

- name: Build
run: make docker-build
run: make operator-build

- name: Login to Quay
uses: docker/login-action@v1
Expand All @@ -41,7 +41,7 @@ jobs:
password: ${{ secrets.QUAY_ROBOT_TOKEN }}

- name: Push
run: make docker-push
run: make operator-push

publish-bundle:
name: Bundle Image
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-and-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ jobs:
go-version: ${{ matrix.go }}

- name: Build
run: make docker-build
run: make operator-build

validate-bundle:
name: Validate Operator Bundle
Expand Down
16 changes: 8 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ build: generate fmt vet golangci-lint kube-linter ## Build manager binary.
run: manifests generate fmt vet ## Run a controller from your host.
go run ./main.go

docker-build: generate fmt vet golangci-lint kube-linter ## Build docker image with the manager.
docker build -t ${IMG} .
operator-build: generate fmt vet golangci-lint kube-linter ## Build docker image with the manager.
${BUILD_TOOL} build -t ${IMG} .

docker-push: ## Push docker image with the manager.
docker push ${IMG}
operator-push: ## Push docker image with the manager.
${BUILD_TOOL} push ${IMG}

##@ Deployment

Expand Down Expand Up @@ -117,19 +117,19 @@ endif

.PHONY: bundle-build
bundle-build: bundle ## Build the bundle image.
docker build -f bundle.Dockerfile -t $(BUNDLE_IMG) .
${BUILD_TOOL} build -f bundle.Dockerfile -t $(BUNDLE_IMG) .

.PHONY: bundle-push
bundle-push: ## Push the bundle image.
$(MAKE) docker-push IMG=$(BUNDLE_IMG)
$(MAKE) operator-push IMG=$(BUNDLE_IMG)

.PHONY: catalog-build
catalog-build: opm ## Build a catalog image.
$(OPM) index add --container-tool docker --mode semver --tag $(CATALOG_IMG) --bundles $(BUNDLE_IMGS) $(FROM_INDEX_OPT)
$(OPM) index add --container-tool ${BUILD_TOOL} --mode semver --tag $(CATALOG_IMG) --bundles $(BUNDLE_IMGS) $(FROM_INDEX_OPT)

.PHONY: catalog-push
catalog-push: ## Push a catalog image.
$(MAKE) docker-push IMG=$(CATALOG_IMG)
$(MAKE) operator-push IMG=$(CATALOG_IMG)

##@ Actions

Expand Down
1 change: 1 addition & 0 deletions hack/make/vars.mk
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ MULTICLUSTER_CONSOLE_IMG_TAG ?= latest
IMG ?= $(IMAGE_REGISTRY)/$(REGISTRY_NAMESPACE)/$(IMAGE_NAME):$(IMAGE_TAG)
MULTICLUSTER_CONSOLE_IMG ?= ${IMAGE_REGISTRY}/$(REGISTRY_NAMESPACE)/$(MULTICLUSTER_CONSOLE_IMG_NAME):$(MULTICLUSTER_CONSOLE_IMG_TAG)

BUILD_TOOL ?= docker
# 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:
Expand Down

0 comments on commit 9739735

Please sign in to comment.