Skip to content

Commit ed6785a

Browse files
authored
Adds podman compatibility in makefile (#1299)
* feat: podman compatibility in makefile Author: Elias Rami <[email protected]> Date: Sun Apr 7 19:11:24 2024 +0200 Signed-off-by: Elias Rami <[email protected]> * fix: throw warning instead of error when neither podman or docker is installed Author: Elias Rami <[email protected]> Date: Mon May 27 17:09:22 2024 +0200 Signed-off-by: Elias Rami <[email protected]> --------- Signed-off-by: Elias Rami <[email protected]>
1 parent 22ded96 commit ed6785a

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

Makefile

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@
55
# - use environment variables to overwrite this value (e.g export VERSION=0.0.2)
66
VERSION ?= 0.10.0
77

8+
# Try to detect Docker or Podman
9+
CONTAINER_RUNTIME := $(shell command -v docker 2> /dev/null || command -v podman 2> /dev/null)
10+
11+
# If neither Docker nor Podman is found, print an error message and exit
12+
ifeq ($(CONTAINER_RUNTIME),)
13+
$(warning "No container runtime (Docker or Podman) found in PATH. Please install one of them.")
14+
endif
15+
816
# CHANNELS define the bundle channels used in the bundle.
917
# Add a new line here if you would like to change its default config. (E.g CHANNELS = "candidate,fast,stable")
1018
# 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.
99107
REDIS_CONFIG_PATH="build/redis" go run -ldflags=$(LD_FLAGS) ./main.go
100108

101109
docker-build: test ## Build docker image with the manager.
102-
docker build --build-arg LD_FLAGS=$(LD_FLAGS) -t ${IMG} .
110+
$(CONTAINER_RUNTIME) build --build-arg LD_FLAGS=$(LD_FLAGS) -t ${IMG} .
103111

104112
docker-push: ## Push docker image with the manager.
105-
docker push ${IMG}
113+
$(CONTAINER_RUNTIME) push ${IMG}
106114

107115
##@ Deployment
108116

@@ -169,7 +177,7 @@ bundle: manifests kustomize ## Generate bundle manifests and metadata, then vali
169177

170178
.PHONY: bundle-build
171179
bundle-build: ## Build the bundle image.
172-
docker build -f bundle.Dockerfile -t $(BUNDLE_IMG) .
180+
$(CONTAINER_RUNTIME) build -f bundle.Dockerfile -t $(BUNDLE_IMG) .
173181

174182
.PHONY: bundle-push
175183
bundle-push: ## Push the bundle image.
@@ -181,7 +189,7 @@ UTIL_IMG ?= $(IMAGE_TAG_BASE)-util:v$(VERSION)
181189

182190
.PHONY: util-build
183191
util-build: ## Build the util container image (for backup)
184-
docker build --no-cache -t $(UTIL_IMG) build/util
192+
$(CONTAINER_RUNTIME) build --no-cache -t $(UTIL_IMG) build/util
185193

186194
.PHONY: util-push
187195
util-push: ## Push the util container image
@@ -198,7 +206,7 @@ registry-build: ## Build the registry container image
198206
cp -r deploy/registry/* build/_output/registry/
199207
mkdir -p build/_output/registry/manifests
200208
cp -r deploy/olm-catalog/argocd-operator build/_output/registry/manifests/
201-
docker build -t $(REGISTRY_IMG) build/_output/registry
209+
$(CONTAINER_RUNTIME) build -t $(REGISTRY_IMG) build/_output/registry
202210

203211
.PHONY: registry-push
204212
registry-push: ## Push the util container image
@@ -238,7 +246,7 @@ endif
238246
# https://github.com/operator-framework/community-operators/blob/7f1438c/docs/packaging-operator.md#updating-your-existing-operator
239247
.PHONY: catalog-build
240248
catalog-build: opm ## Build a catalog image.
241-
$(OPM) index add --container-tool docker --mode semver --tag $(CATALOG_IMG) --bundles $(BUNDLE_IMGS) $(FROM_INDEX_OPT)
249+
$(OPM) index add --container-tool $(CONTAINER_RUNTIME) --mode semver --tag $(CATALOG_IMG) --bundles $(BUNDLE_IMGS) $(FROM_INDEX_OPT)
242250

243251
# Push the catalog image.
244252
.PHONY: catalog-push

0 commit comments

Comments
 (0)