Skip to content

Commit 4aaa21f

Browse files
authored
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 <[email protected]>
1 parent 5c07033 commit 4aaa21f

File tree

4 files changed

+16
-13
lines changed

4 files changed

+16
-13
lines changed

Makefile

+12-9
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,14 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
# make builder configurable, default to docker.
16+
ENGINE ?= docker
17+
1518
# collect args from `make run` so that they don't run twice
1619
ifeq (run,$(firstword $(MAKECMDGOALS)))
1720
RUN_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
1821
ifneq ("$(wildcard /.dockerenv)","")
19-
$(error Inside docker container, run 'make $(RUN_ARGS)')
22+
$(error Inside the developer container, run 'make $(RUN_ARGS)')
2023
endif
2124
endif
2225

@@ -25,29 +28,29 @@ endif
2528
all: build
2629

2730
.PHONY: build
28-
## Build runtime Docker image
31+
## Build runtime container image
2932
build:
30-
./scripts/build_docker.sh --target runtime
33+
ENGINE=${ENGINE} && ./scripts/build_docker.sh --target runtime
3134

3235
.PHONY: build.develop
3336
## Build developer container image
3437
build.develop:
35-
./scripts/build_docker.sh --target develop
38+
ENGINE=${ENGINE} && ./scripts/build_docker.sh --target develop
3639

3740
.PHONY: use.develop
38-
## Check if developer image exists, build it if it doesn't
41+
## Check if developer container image exists, build it if it doesn't
3942
use.develop:
40-
./scripts/build_docker.sh --target develop --use-existing
43+
ENGINE=${ENGINE} && ./scripts/build_docker.sh --target develop --use-existing
4144

4245
.PHONY: develop
43-
## Run interactive shell inside developer container
46+
## Run interactive shell inside developer container image
4447
develop: use.develop
45-
./scripts/develop.sh
48+
ENGINE=${ENGINE} && ./scripts/develop.sh
4649

4750
.PHONY: run
4851
## Run make target inside developer container (e.g. `make run fmt`)
4952
run: use.develop
50-
./scripts/develop.sh make $(RUN_ARGS)
53+
ENGINE=${ENGINE} && ./scripts/develop.sh make $(RUN_ARGS)
5154

5255
.PHONY: test
5356
## Run tests

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ make run fmt
5353
## Build the Docker image
5454

5555
Once the code changes have been tested and linted, build a new `modelmesh-runtime-adapter`
56-
Docker image.
56+
Container image. If you need to use another builder than `docker`, you can specify it by using the `ENGINE` variable:
5757

5858
```shell
59-
make build
59+
ENGINE=podman make build
6060
```
6161

6262
## Push the image to a container registry

scripts/build_docker.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,5 +103,5 @@ if [[ $DOCKER_TARGET == 'runtime' ]]; then
103103
docker_args+=("--build-arg=IMAGE_VERSION=${DOCKER_TAG}")
104104
fi
105105

106-
docker build . \
106+
${ENGINE:-docker} build . \
107107
"${docker_args[@]}"

scripts/develop.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,6 @@ else
7575
fi
7676

7777
# Run the develop container with local source mounted in
78-
docker run --rm \
78+
${ENGINE:-docker} run --rm \
7979
"${docker_run_args[@]}" \
8080
"${DOCKER_USER}/modelmesh-runtime-adapter-develop:${IMAGE_TAG}" "$@"

0 commit comments

Comments
 (0)