Skip to content

Fix the make build command and add main tag to the latest image #127

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 38 additions & 43 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,20 @@ CONTAINER_TOOL ?= docker
SHELL = /usr/bin/env bash -o pipefail
.SHELLFLAGS = -ec

.PHONY: all
all: build
GIT_TAG ?= $(shell git describe --tags --dirty --always)
PLATFORMS ?= linux/amd64,linux/arm64
DOCKER_BUILDX_CMD ?= docker buildx
IMAGE_BUILD_CMD ?= $(DOCKER_BUILDX_CMD) build
IMAGE_BUILD_EXTRA_OPTS ?=
IMAGE_REGISTRY ?= us-central1-docker.pkg.dev/k8s-staging-images/llm-instance-gateway
IMAGE_NAME := epp
IMAGE_REPO ?= $(IMAGE_REGISTRY)/$(IMAGE_NAME)
IMAGE_TAG ?= $(IMAGE_REPO):$(GIT_TAG)

# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
BASE_IMAGE ?= gcr.io/distroless/static:nonroot
BUILDER_IMAGE ?= golang:$(GO_VERSION)

##@ General

Expand Down Expand Up @@ -108,47 +120,30 @@ verify: vet fmt-verify manifests generate ## ci-lint add back when all lint erro

##@ Build

.PHONY: build
build: manifests generate fmt vet ## Build manager binary.
go build -o bin/manager cmd/main.go

.PHONY: run
run: manifests generate fmt vet ## Run a controller from your host.
go run ./cmd/main.go

# If you wish to build the manager image targeting other platforms you can use the --platform flag.
# (i.e. docker build --platform linux/arm64). However, you must enable docker buildKit for it.
# More info: https://docs.docker.com/develop/develop-images/build_enhancements/
.PHONY: docker-build
docker-build: ## Build docker image with the manager.
$(CONTAINER_TOOL) build -t ${IMG} .

.PHONY: docker-push
docker-push: ## Push docker image with the manager.
$(CONTAINER_TOOL) push ${IMG}

# PLATFORMS defines the target platforms for the manager image be built to provide support to multiple
# architectures. (i.e. make docker-buildx IMG=myregistry/mypoperator:0.0.1). To use this option you need to:
# - be able to use docker buildx. More info: https://docs.docker.com/build/buildx/
# - have enabled BuildKit. More info: https://docs.docker.com/develop/develop-images/build_enhancements/
# - be able to push the image to your registry (i.e. if you do not set a valid value via IMG=<myregistry/image:<tag>> then the export will fail)
# To adequately provide solutions that are compatible with multiple platforms, you should consider using this option.
PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x,linux/ppc64le
.PHONY: docker-buildx
docker-buildx: ## Build and push docker image for the manager for cross-platform support
# copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile
sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross
- $(CONTAINER_TOOL) buildx create --name api-builder
$(CONTAINER_TOOL) buildx use api-builder
- $(CONTAINER_TOOL) buildx build --push --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile.cross .
- $(CONTAINER_TOOL) buildx rm api-builder
rm Dockerfile.cross

.PHONY: build-installer
build-installer: manifests generate kustomize ## Generate a consolidated YAML with CRDs and deployment.
mkdir -p dist
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
$(KUSTOMIZE) build config/default > dist/install.yaml
# Build the container image
.PHONY: image-local-build
image-local-build:
BUILDER=$(shell $(DOCKER_BUILDX_CMD) create --use)
$(MAKE) image-build PUSH=$(PUSH)
$(DOCKER_BUILDX_CMD) rm $$BUILDER

.PHONY: image-local-push
image-local-push: PUSH=--push
image-local-push: image-local-build

.PHONY: image-build
image-build:
$(IMAGE_BUILD_CMD) -t $(IMAGE_TAG) \
--platform=$(PLATFORMS) \
--build-arg BASE_IMAGE=$(BASE_IMAGE) \
--build-arg BUILDER_IMAGE=$(BUILDER_IMAGE) \
$(PUSH) \
$(IMAGE_BUILD_EXTRA_OPTS) ./

.PHONY: image-push
image-push: PUSH=--push
image-push: image-build


##@ Docs

Expand Down
28 changes: 18 additions & 10 deletions cloudbuild.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
# See https://cloud.google.com/cloud-build/docs/build-config
timeout: 3000s
# A build step specifies an action that you want Prow to perform.
# For each build step, Prow executes a job.
steps:
- name: gcr.io/cloud-builders/docker
# see https://github.com/kubernetes/test-infra/tree/master/config/jobs/image-pushing
- name: gcr.io/k8s-testimages/gcb-docker-gcloud:v20220830-45cbff55bc
entrypoint: make
args:
- build
- --tag=us-central1-docker.pkg.dev/k8s-staging-images/llm-instance-gateway/epp:$_GIT_TAG
- .
- image-push
env:
- GIT_TAG=$_GIT_TAG
- EXTRA_TAG=$_PULL_BASE_REF
- DOCKER_BUILDX_CMD=/buildx-entrypoint
substitutions:
_GIT_TAG: '12345'
# this prevents errors if you don't use both _GIT_TAG
# or any new substitutions added in the future.
# _GIT_TAG will be filled with a git-based tag for the image, of the form vYYYYMMDD-hash, and
# can be used as a substitution
_GIT_TAG: '0.0.0'
# _PULL_BASE_REF will contain the ref that was pushed to trigger this build -
# a branch like 'main' or 'release-0.2', or a tag like 'v0.2'.
_PULL_BASE_REF: 'main'
options:
substitution_option: ALLOW_LOOSE
# this will push these images, or cause the build to fail if they weren't built.
images:
- 'us-central1-docker.pkg.dev/k8s-staging-images/llm-instance-gateway/epp:$_GIT_TAG'
4 changes: 2 additions & 2 deletions pkg/manifests/ext_proc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ spec:
containers:
- name: inference-gateway-ext-proc
# TODO(https://github.com/kubernetes-sigs/llm-instance-gateway/issues/34) Update the image and args.
image: <BUILT-IMAGE>
image: us-central1-docker.pkg.dev/k8s-staging-images/llm-instance-gateway/epp:main
args:
- -serverPoolName
- "vllm-llama2-7b-pool"
Expand Down Expand Up @@ -108,4 +108,4 @@ spec:
targetRef:
group: gateway.networking.k8s.io
kind: HTTPRoute
name: llm-route
name: llm-route