@@ -20,6 +20,10 @@ BIN ?= velero
2020# This repo's root import path (under GOPATH).
2121PKG := github.com/vmware-tanzu/velero
2222
23+ # Container tool for local development targets (shell, lint, build-image, etc.)
24+ # Override with CONTAINER_TOOL=podman to use podman instead of docker.
25+ CONTAINER_TOOL ?= docker
26+
2327# Where to push the docker image.
2428REGISTRY ?= velero
2529# In order to push images to an insecure registry, follow the two steps:
6367endif
6468
6569BUILDER_IMAGE := $(REGISTRY ) /build-image:$(BUILDER_IMAGE_TAG )
66- BUILDER_IMAGE_CACHED := $(shell docker images -q ${BUILDER_IMAGE} 2>/dev/null )
70+ BUILDER_IMAGE_CACHED := $(shell $( CONTAINER_TOOL ) images -q ${BUILDER_IMAGE} 2>/dev/null )
6771
6872HUGO_IMAGE := ghcr.io/gohugoio/hugo
6973
@@ -198,7 +202,7 @@ shell: build-dirs build-env
198202 @# because the Kubernetes code-generator tools require the project to
199203 @# exist in a directory hierarchy ending like this (but *NOT* necessarily
200204 @# under $GOPATH).
201- @docker run \
205+ @$( CONTAINER_TOOL ) run \
202206 -e GOFLAGS \
203207 -e GOPROXY \
204208 -i $(TTY ) \
@@ -363,21 +367,21 @@ else ifneq ($(BUILDER_IMAGE_CACHED),)
363367 @echo "Using Cached Image: $(BUILDER_IMAGE)"
364368else
365369 @echo "Trying to pull build-image: $(BUILDER_IMAGE)"
366- docker pull -q $(BUILDER_IMAGE) || $(MAKE) build-image
370+ $(CONTAINER_TOOL) pull -q $(BUILDER_IMAGE) || $(MAKE) build-image
367371endif
368372
369373build-image :
370374 @# When we build a new image we just untag the old one.
371375 @# This makes sure we don't leave the orphaned image behind.
372- $(eval old_id=$(shell docker image inspect --format '{{ .ID }}' ${BUILDER_IMAGE} 2>/dev/null) )
376+ $(eval old_id=$(shell $( CONTAINER_TOOL ) image inspect --format '{{ .ID }}' ${BUILDER_IMAGE} 2>/dev/null) )
373377ifeq ($(BUILDX_ENABLED ) , true)
374- @cd hack/build-image && docker buildx build --build-arg=GOPROXY=$(GOPROXY) --output=type=docker --pull -t $(BUILDER_IMAGE) -f $(BUILDER_IMAGE_DOCKERFILE_REALPATH) .
378+ @cd hack/build-image && $(CONTAINER_TOOL) buildx build --build-arg=GOPROXY=$(GOPROXY) --output=type=docker --pull -t $(BUILDER_IMAGE) -f $(BUILDER_IMAGE_DOCKERFILE_REALPATH) .
375379else
376- @cd hack/build-image && docker build --build-arg=GOPROXY=$(GOPROXY) --pull -t $(BUILDER_IMAGE) -f $(BUILDER_IMAGE_DOCKERFILE_REALPATH) .
380+ @cd hack/build-image && $(CONTAINER_TOOL) build --build-arg=GOPROXY=$(GOPROXY) --pull -t $(BUILDER_IMAGE) -f $(BUILDER_IMAGE_DOCKERFILE_REALPATH) .
377381endif
378- $(eval new_id=$(shell docker image inspect --format '{{ .ID }}' ${BUILDER_IMAGE} 2>/dev/null))
382+ $(eval new_id=$(shell $(CONTAINER_TOOL) image inspect --format '{{ .ID }}' ${BUILDER_IMAGE} 2>/dev/null))
379383 @if [ "$(old_id)" != "" ] && [ "$(old_id)" != "$(new_id)" ]; then \
380- docker rmi -f $$id || true; \
384+ $(CONTAINER_TOOL) rmi -f $$id || true; \
381385 fi
382386
383387push-build-image :
@@ -392,17 +396,17 @@ else
392396endif
393397
394398build-image-hugo :
395- cd site && docker build --pull -t $(HUGO_IMAGE ) .
399+ cd site && $( CONTAINER_TOOL ) build --pull -t $(HUGO_IMAGE ) .
396400
397401clean :
398402# if we have a cached image then use it to run go clean --modcache
399403# this test checks if we there is an image id in the BUILDER_IMAGE_CACHED variable.
400404ifneq ($(strip $(BUILDER_IMAGE_CACHED ) ) ,)
401405 $(MAKE) shell CMD="-c 'go clean --modcache'"
402- docker rmi -f $(BUILDER_IMAGE) || true
406+ $(CONTAINER_TOOL) rmi -f $(BUILDER_IMAGE) || true
403407endif
404408 rm -rf .go _output
405- docker rmi $(HUGO_IMAGE)
409+ $(CONTAINER_TOOL) rmi $(HUGO_IMAGE)
406410
407411
408412.PHONY : modules
@@ -447,7 +451,7 @@ release:
447451 ./hack/release-tools/goreleaser.sh' "
448452
449453serve-docs : build-image-hugo
450- docker run \
454+ $( CONTAINER_TOOL ) run \
451455 --rm \
452456 -v " $$ (pwd)/site:/project" \
453457 -it -p 1313:1313 \
0 commit comments