Skip to content
Open
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### Makefile local overrides (e.g. proxy)
config.mk
buildx/config.mk

### dotenv template
python/.env

Expand Down
42 changes: 40 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,35 @@ KUBECONFIG_PERM ?= $(shell \
fi)


# Optional config overrides
-include config.mk
# Buildx proxy config: copy buildx/config.mk.example to buildx/config.mk and set
# HTTP_PROXY/HTTPS_PROXY so the buildx builder can load base image metadata.
-include buildx/config.mk

# Proxy for Docker buildx (BuildKit). Set in buildx/config.mk or env so the builder
# can load base image metadata (e.g. gcr.io/distroless/static).
HTTP_PROXY ?=
HTTPS_PROXY ?=
NO_PROXY ?=

# Docker buildx configuration
BUILDKIT_VERSION = v0.23.0
BUILDX_NO_DEFAULT_ATTESTATIONS=1
BUILDX_BUILDER_NAME ?= kagent-builder-$(BUILDKIT_VERSION)

# Driver options for buildx (proxy env is passed into the BuildKit container)
BUILDX_DRIVER_OPTS = --driver-opt network=host
ifneq ($(HTTP_PROXY),)
BUILDX_DRIVER_OPTS += --driver-opt env.HTTP_PROXY=$(HTTP_PROXY)
endif
ifneq ($(HTTPS_PROXY),)
BUILDX_DRIVER_OPTS += --driver-opt env.HTTPS_PROXY=$(HTTPS_PROXY)
endif
ifneq ($(NO_PROXY),)
BUILDX_DRIVER_OPTS += --driver-opt env.NO_PROXY=$(NO_PROXY)
endif

DOCKER_BUILDER ?= docker buildx
DOCKER_BUILD_ARGS ?= --push --platform linux/$(LOCALARCH)

Expand All @@ -34,16 +58,19 @@ KIND_IMAGE_VERSION ?= 1.35.0
CONTROLLER_IMAGE_NAME ?= controller
UI_IMAGE_NAME ?= ui
APP_IMAGE_NAME ?= app
APP_GO_IMAGE_NAME ?= app-go
KAGENT_ADK_IMAGE_NAME ?= kagent-adk

CONTROLLER_IMAGE_TAG ?= $(VERSION)
UI_IMAGE_TAG ?= $(VERSION)
APP_IMAGE_TAG ?= $(VERSION)
APP_GO_IMAGE_TAG ?= $(VERSION)
KAGENT_ADK_IMAGE_TAG ?= $(VERSION)

CONTROLLER_IMG ?= $(DOCKER_REGISTRY)/$(DOCKER_REPO)/$(CONTROLLER_IMAGE_NAME):$(CONTROLLER_IMAGE_TAG)
UI_IMG ?= $(DOCKER_REGISTRY)/$(DOCKER_REPO)/$(UI_IMAGE_NAME):$(UI_IMAGE_TAG)
APP_IMG ?= $(DOCKER_REGISTRY)/$(DOCKER_REPO)/$(APP_IMAGE_NAME):$(APP_IMAGE_TAG)
APP_GO_IMG ?= $(DOCKER_REGISTRY)/$(DOCKER_REPO)/$(APP_GO_IMAGE_NAME):$(APP_GO_IMAGE_TAG)
KAGENT_ADK_IMG ?= $(DOCKER_REGISTRY)/$(DOCKER_REPO)/$(KAGENT_ADK_IMAGE_NAME):$(KAGENT_ADK_IMAGE_TAG)

#take from go/go.mod
Expand Down Expand Up @@ -149,10 +176,14 @@ check-api-key:
echo "Warning: Unknown model provider '$(KAGENT_DEFAULT_MODEL_PROVIDER)'. Skipping API key check."; \
fi

.PHONY: buildx-rm
buildx-rm: ## Remove the buildx builder (e.g. to recreate with proxy: make buildx-rm buildx-create build-controller)
docker buildx rm $(BUILDX_BUILDER_NAME) -f || true

.PHONY: buildx-create
buildx-create:
docker buildx inspect $(BUILDX_BUILDER_NAME) 2>&1 > /dev/null || \
docker buildx create --name $(BUILDX_BUILDER_NAME) --platform linux/amd64,linux/arm64 --driver docker-container --use --driver-opt network=host || true
docker buildx create --name $(BUILDX_BUILDER_NAME) --platform linux/amd64,linux/arm64 --driver docker-container --use $(BUILDX_DRIVER_OPTS) || true
docker buildx use $(BUILDX_BUILDER_NAME) || true

.PHONY: build-all # for test purpose build all but output to /dev/null
Expand Down Expand Up @@ -211,11 +242,12 @@ prune-docker-images:
docker images --filter dangling=true -q | xargs -r docker rmi || :

.PHONY: build
build: buildx-create build-controller build-ui build-app
build: buildx-create build-controller build-ui build-app build-app-go
@echo "Build completed successfully."
@echo "Controller Image: $(CONTROLLER_IMG)"
@echo "UI Image: $(UI_IMG)"
@echo "App Image: $(APP_IMG)"
@echo "App Go Image: $(APP_GO_IMG)"
@echo "Kagent ADK Image: $(KAGENT_ADK_IMG)"
@echo "Tools Image: $(TOOLS_IMG)"

Expand All @@ -237,6 +269,7 @@ build-img-versions:
@echo controller=$(CONTROLLER_IMG)
@echo ui=$(UI_IMG)
@echo app=$(APP_IMG)
@echo app-go=$(APP_GO_IMG)
@echo kagent-adk=$(KAGENT_ADK_IMG)

.PHONY: lint
Expand Down Expand Up @@ -268,6 +301,11 @@ build-kagent-adk: buildx-create
build-app: buildx-create build-kagent-adk
$(DOCKER_BUILDER) build $(DOCKER_BUILD_ARGS) $(TOOLS_IMAGE_BUILD_ARGS) --build-arg KAGENT_ADK_VERSION=$(KAGENT_ADK_IMAGE_TAG) --build-arg DOCKER_REGISTRY=$(DOCKER_REGISTRY) -t $(APP_IMG) -f python/Dockerfile.app ./python

.PHONY: build-app-go
build-app-go: buildx-create
$(DOCKER_BUILDER) build $(DOCKER_BUILD_ARGS) $(TOOLS_IMAGE_BUILD_ARGS) --build-arg KAGENT_ADK_VERSION=$(KAGENT_ADK_IMAGE_TAG) --build-arg DOCKER_REGISTRY=$(DOCKER_REGISTRY) -t $(APP_GO_IMG) -f go-adk/Dockerfile ./go-adk


.PHONY: helm-cleanup
helm-cleanup:
rm -f ./$(HELM_DIST_FOLDER)/*.tgz
Expand Down
2 changes: 2 additions & 0 deletions go-adk/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.crt
*.dox
52 changes: 52 additions & 0 deletions go-adk/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
### STAGE 1: base image
ARG BASE_IMAGE_REGISTRY=cgr.dev
ARG BUILDPLATFORM
FROM --platform=$BUILDPLATFORM $BASE_IMAGE_REGISTRY/chainguard/go:latest AS builder
ARG TARGETARCH
ARG TARGETPLATFORM
# This is used to print the build platform in the logs
ARG BUILDPLATFORM

WORKDIR /workspace
# Copy the Go Modules manifests
COPY go.mod go.mod
COPY go.sum go.sum
# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
RUN --mount=type=cache,target=/root/go/pkg/mod,rw \
--mount=type=cache,target=/root/.cache/go-build,rw \
go mod download

# Copy the go source
COPY cmd cmd
COPY pkg pkg
# Build
# the GOARCH has not a default value to allow the binary be built according to the host where the command
# was called. For example, if we call make docker-build in a local env which has the Apple Silicon M1 SO
# the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore,
# by leaving it empty we can ensure that the container and binary shipped on it will have the same platform.
ARG LDFLAGS
RUN --mount=type=cache,target=/root/go/pkg/mod,rw \
--mount=type=cache,target=/root/.cache/go-build,rw \
echo "Building on $BUILDPLATFORM -> linux/$TARGETARCH" && \
CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -ldflags "$LDFLAGS" -o kagent-go-adk cmd/main.go

### STAGE 2: final image
# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
FROM gcr.io/distroless/static:nonroot
ARG TARGETPLATFORM

WORKDIR /
COPY --from=builder /workspace/kagent-go-adk /kagent-go-adk
USER 65532:65532
ARG VERSION

LABEL org.opencontainers.image.source=https://github.com/kagent-dev/kagent
LABEL org.opencontainers.image.description="Go-based Agent Development Kit (ADK) for Kagent"
LABEL org.opencontainers.image.authors="Kagent Creators 🤖"
LABEL org.opencontainers.image.version="$VERSION"

EXPOSE 8080

ENTRYPOINT ["/kagent-go-adk"]
33 changes: 33 additions & 0 deletions go-adk/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
.PHONY: build test vet clean help

# Default target
.DEFAULT_GOAL := build

# Build command that runs tests and go vet
build: vet test
@echo "Building..."
@go build ./...

# Run tests
test:
@echo "Running tests..."
@go test ./...

# Run go vet
vet:
@echo "Running go vet..."
@go vet ./...

# Clean build artifacts
clean:
@echo "Cleaning..."
@go clean ./...

# Help target
help:
@echo "Available targets:"
@echo " build - Run go vet, tests, and build (default)"
@echo " test - Run tests only"
@echo " vet - Run go vet only"
@echo " clean - Clean build artifacts"
@echo " help - Show this help message"
Loading
Loading