From 4aaa21fd6cc5d0460348fd9258a08068708d400e Mon Sep 17 00:00:00 2001 From: Filippe Spolti Date: Thu, 19 Sep 2024 09:37:44 -0400 Subject: [PATCH] feat: Make container build engine configurable (#87) chore: Allow to run make goals provinding the desired Container Enginer builder tool, e.g. `ENGINE=podman make build` Signed-off-by: Spolti --- Makefile | 21 ++++++++++++--------- README.md | 4 ++-- scripts/build_docker.sh | 2 +- scripts/develop.sh | 2 +- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 332ebcd2..99d78d06 100644 --- a/Makefile +++ b/Makefile @@ -12,11 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. +# 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 @@ -25,29 +28,29 @@ endif all: build .PHONY: build -## Build runtime Docker image +## Build runtime container image build: - ./scripts/build_docker.sh --target runtime + ENGINE=${ENGINE} && ./scripts/build_docker.sh --target runtime .PHONY: build.develop ## Build developer container image build.develop: - ./scripts/build_docker.sh --target develop + ENGINE=${ENGINE} && ./scripts/build_docker.sh --target develop .PHONY: use.develop -## Check if developer image exists, build it if it doesn't +## Check if developer container image exists, build it if it doesn't use.develop: - ./scripts/build_docker.sh --target develop --use-existing + ENGINE=${ENGINE} && ./scripts/build_docker.sh --target develop --use-existing .PHONY: develop -## Run interactive shell inside developer container +## Run interactive shell inside developer container image develop: use.develop - ./scripts/develop.sh + ENGINE=${ENGINE} && ./scripts/develop.sh .PHONY: run ## Run make target inside developer container (e.g. `make run fmt`) run: use.develop - ./scripts/develop.sh make $(RUN_ARGS) + ENGINE=${ENGINE} && ./scripts/develop.sh make $(RUN_ARGS) .PHONY: test ## Run tests diff --git a/README.md b/README.md index af056d7d..8a80d79d 100644 --- a/README.md +++ b/README.md @@ -53,10 +53,10 @@ make run fmt ## Build the Docker image Once the code changes have been tested and linted, build a new `modelmesh-runtime-adapter` -Docker image. +Container image. If you need to use another builder than `docker`, you can specify it by using the `ENGINE` variable: ```shell -make build +ENGINE=podman make build ``` ## Push the image to a container registry diff --git a/scripts/build_docker.sh b/scripts/build_docker.sh index 56d18240..d10d0d5d 100755 --- a/scripts/build_docker.sh +++ b/scripts/build_docker.sh @@ -103,5 +103,5 @@ if [[ $DOCKER_TARGET == 'runtime' ]]; then docker_args+=("--build-arg=IMAGE_VERSION=${DOCKER_TAG}") fi -docker build . \ +${ENGINE:-docker} build . \ "${docker_args[@]}" diff --git a/scripts/develop.sh b/scripts/develop.sh index 54559765..572da340 100755 --- a/scripts/develop.sh +++ b/scripts/develop.sh @@ -75,6 +75,6 @@ else fi # Run the develop container with local source mounted in -docker run --rm \ +${ENGINE:-docker} run --rm \ "${docker_run_args[@]}" \ "${DOCKER_USER}/modelmesh-runtime-adapter-develop:${IMAGE_TAG}" "$@"