5
5
# - use environment variables to overwrite this value (e.g export VERSION=0.0.2)
6
6
VERSION ?= 0.10.0
7
7
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
+
8
16
# CHANNELS define the bundle channels used in the bundle.
9
17
# Add a new line here if you would like to change its default config. (E.g CHANNELS = "candidate,fast,stable")
10
18
# 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.
99
107
REDIS_CONFIG_PATH=" build/redis" go run -ldflags=$(LD_FLAGS ) ./main.go
100
108
101
109
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} .
103
111
104
112
docker-push : # # Push docker image with the manager.
105
- docker push ${IMG}
113
+ $( CONTAINER_RUNTIME ) push ${IMG}
106
114
107
115
# #@ Deployment
108
116
@@ -169,7 +177,7 @@ bundle: manifests kustomize ## Generate bundle manifests and metadata, then vali
169
177
170
178
.PHONY : bundle-build
171
179
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 ) .
173
181
174
182
.PHONY : bundle-push
175
183
bundle-push : # # Push the bundle image.
@@ -181,7 +189,7 @@ UTIL_IMG ?= $(IMAGE_TAG_BASE)-util:v$(VERSION)
181
189
182
190
.PHONY : util-build
183
191
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
185
193
186
194
.PHONY : util-push
187
195
util-push : # # Push the util container image
@@ -198,7 +206,7 @@ registry-build: ## Build the registry container image
198
206
cp -r deploy/registry/* build/_output/registry/
199
207
mkdir -p build/_output/registry/manifests
200
208
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
202
210
203
211
.PHONY : registry-push
204
212
registry-push : # # Push the util container image
@@ -238,7 +246,7 @@ endif
238
246
# https://github.com/operator-framework/community-operators/blob/7f1438c/docs/packaging-operator.md#updating-your-existing-operator
239
247
.PHONY : catalog-build
240
248
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 )
242
250
243
251
# Push the catalog image.
244
252
.PHONY : catalog-push
0 commit comments