Skip to content

Commit

Permalink
Make the builder configurable in the Makefile
Browse files Browse the repository at this point in the history
chore: 	Some developers might not have docker installed anymore.
	Thus it would be easier to have it configurable instead
	to do changes locally to build using, i.e, `podman` or
	`buildah`.
	It can be called by `make BUILDER=podman build`

Signed-off-by: Spolti <[email protected]>
  • Loading branch information
spolti authored and ckadner committed Nov 30, 2023
1 parent 61dc700 commit 70ac1e0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 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.
BUILDER ?= 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 container image, run 'make $(RUN_ARGS)')
endif
endif

Expand All @@ -36,24 +38,24 @@ google/api/%.proto:
@test -f $@ || wget --inet4-only -q -O $@ https://raw.githubusercontent.com/googleapis/googleapis/master/$@

.PHONY: build
## Build runtime Docker image
## Build runtime container image
build:
docker build -t ${IMG_NAME}:latest --target runtime .
${BUILDER} 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 .
${BUILDER} build -t ${IMG_NAME}-develop:latest --target develop .

.PHONY: develop
## Run interactive shell inside developer container
develop: build.develop
./scripts/develop.sh
BUILDER=${BUILDER} && ./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)
BUILDER=${BUILDER} && ./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 `BUILDER` parameter:

```bash
make BUILDER=podman 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
4 changes: 2 additions & 2 deletions scripts/develop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ usage() {
exit 1
}

arg="$1"
arg="$2"
case $arg in
-h | --help)
usage
Expand Down Expand Up @@ -60,6 +60,6 @@ else
fi

# Run the develop container with local source mounted in
docker run --rm \
${BUILDER:-docker} run --rm \
"${docker_run_args[@]}" \
kserve/rest-proxy-develop:latest "$@"

0 comments on commit 70ac1e0

Please sign in to comment.