Skip to content

Commit fb0899e

Browse files
Joeavaikathclaude
andcommitted
Add CONTAINER_TOOL variable to Makefile for podman support
Local development targets (shell, lint, build-image, clean, serve-docs) hardcode `docker`, preventing developers who use podman from running them. Add a CONTAINER_TOOL variable that defaults to `docker` and can be overridden: make lint CONTAINER_TOOL=podman CI/release targets (container builds, manifest push, buildx instance management) are left unchanged since they use Docker-specific features like `docker buildx` and `docker manifest`. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Joseph <jvaikath@redhat.com>
1 parent 4c19509 commit fb0899e

1 file changed

Lines changed: 16 additions & 12 deletions

File tree

Makefile

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ BIN ?= velero
2020
# This repo's root import path (under GOPATH).
2121
PKG := 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.
2428
REGISTRY ?= velero
2529
# In order to push images to an insecure registry, follow the two steps:
@@ -63,7 +67,7 @@ else
6367
endif
6468

6569
BUILDER_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

6872
HUGO_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)"
364368
else
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
367371
endif
368372

369373
build-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))
373377
ifeq ($(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) .
375379
else
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) .
377381
endif
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

383387
push-build-image:
@@ -392,17 +396,17 @@ else
392396
endif
393397

394398
build-image-hugo:
395-
cd site && docker build --pull -t $(HUGO_IMAGE) .
399+
cd site && $(CONTAINER_TOOL) build --pull -t $(HUGO_IMAGE) .
396400

397401
clean:
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.
400404
ifneq ($(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
403407
endif
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

449453
serve-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

Comments
 (0)