From 7312ca0627ef824c12e32be33c17efe8e909ec90 Mon Sep 17 00:00:00 2001 From: Elias Rami Date: Sun, 7 Apr 2024 19:11:24 +0200 Subject: [PATCH 1/2] feat: podman compatibility in makefile Author: Elias Rami Date: Sun Apr 7 19:11:24 2024 +0200 Signed-off-by: Elias Rami --- Makefile | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 9aea19ada..5839b0a5f 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,14 @@ # - use environment variables to overwrite this value (e.g export VERSION=0.0.2) VERSION ?= 0.9.0 +# Try to detect Docker or Podman +CONTAINER_RUNTIME := $(shell command -v docker 2> /dev/null || command -v podman 2> /dev/null) + +# If neither Docker nor Podman is found, print an error message and exit +ifeq ($(CONTAINER_RUNTIME),) +$(error "No container runtime (Docker or Podman) found in PATH. Please install one of them.") +endif + # 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: @@ -99,10 +107,10 @@ run: manifests generate fmt vet ## Run a controller from your host. REDIS_CONFIG_PATH="build/redis" go run -ldflags=$(LD_FLAGS) ./main.go docker-build: test ## Build docker image with the manager. - docker build --build-arg LD_FLAGS=$(LD_FLAGS) -t ${IMG} . + $(CONTAINER_RUNTIME) build --build-arg LD_FLAGS=$(LD_FLAGS) -t ${IMG} . docker-push: ## Push docker image with the manager. - docker push ${IMG} + $(CONTAINER_RUNTIME) push ${IMG} ##@ Deployment @@ -169,7 +177,7 @@ bundle: manifests kustomize ## Generate bundle manifests and metadata, then vali .PHONY: bundle-build bundle-build: ## Build the bundle image. - docker build -f bundle.Dockerfile -t $(BUNDLE_IMG) . + $(CONTAINER_RUNTIME) build -f bundle.Dockerfile -t $(BUNDLE_IMG) . .PHONY: bundle-push bundle-push: ## Push the bundle image. @@ -181,7 +189,7 @@ UTIL_IMG ?= $(IMAGE_TAG_BASE)-util:v$(VERSION) .PHONY: util-build util-build: ## Build the util container image (for backup) - docker build --no-cache -t $(UTIL_IMG) build/util + $(CONTAINER_RUNTIME) build --no-cache -t $(UTIL_IMG) build/util .PHONY: util-push util-push: ## Push the util container image @@ -198,7 +206,7 @@ registry-build: ## Build the registry container image cp -r deploy/registry/* build/_output/registry/ mkdir -p build/_output/registry/manifests cp -r deploy/olm-catalog/argocd-operator build/_output/registry/manifests/ - docker build -t $(REGISTRY_IMG) build/_output/registry + $(CONTAINER_RUNTIME) build -t $(REGISTRY_IMG) build/_output/registry .PHONY: registry-push registry-push: ## Push the util container image @@ -238,7 +246,7 @@ endif # https://github.com/operator-framework/community-operators/blob/7f1438c/docs/packaging-operator.md#updating-your-existing-operator .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 $(CONTAINER_RUNTIME) --mode semver --tag $(CATALOG_IMG) --bundles $(BUNDLE_IMGS) $(FROM_INDEX_OPT) # Push the catalog image. .PHONY: catalog-push From b748f8453dcb3b0d78d5f69f89a4be5e2c337a42 Mon Sep 17 00:00:00 2001 From: Elias Rami Date: Mon, 27 May 2024 17:09:22 +0200 Subject: [PATCH 2/2] fix: throw warning instead of error when neither podman or docker is installed Author: Elias Rami Date: Mon May 27 17:09:22 2024 +0200 Signed-off-by: Elias Rami --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 5839b0a5f..3d90acbd1 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ CONTAINER_RUNTIME := $(shell command -v docker 2> /dev/null || command -v podman # If neither Docker nor Podman is found, print an error message and exit ifeq ($(CONTAINER_RUNTIME),) -$(error "No container runtime (Docker or Podman) found in PATH. Please install one of them.") +$(warning "No container runtime (Docker or Podman) found in PATH. Please install one of them.") endif # CHANNELS define the bundle channels used in the bundle.