Skip to content

Commit

Permalink
feat: podman compatibility in makefile
Browse files Browse the repository at this point in the history
Author:    Elias Rami <[email protected]>
Date:      Sun Apr 7 19:11:24 2024 +0200
Signed-off-by: Elias Rami <[email protected]>
  • Loading branch information
Elyytscha committed Apr 7, 2024
1 parent c7c457d commit 7312ca0
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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

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

0 comments on commit 7312ca0

Please sign in to comment.