-
Notifications
You must be signed in to change notification settings - Fork 18
Add multi-architecture support for Docker images and workflows #841
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,8 @@ | ||
| # Image configuration | ||
| REGISTRY ?= ghcr.io/kelos-dev | ||
| VERSION ?= latest | ||
| IMAGE_DIRS ?= cmd/kelos-controller cmd/kelos-spawner cmd/kelos-token-refresher cmd/kelos-webhook-server cmd/ghproxy claude-code codex gemini opencode cursor | ||
| IMAGE_DIRS ?= cmd/kelos-controller cmd/kelos-spawner cmd/kelos-token-refresher cmd/ghproxy cmd/kelos-webhook-server claude-code codex gemini opencode cursor | ||
| LOCAL_ARCH ?= $(shell go env GOARCH) | ||
|
|
||
| # Version injection for the kelos CLI – only set ldflags when an explicit | ||
| # version is given so that dev builds fall through to runtime/debug info. | ||
|
|
@@ -79,20 +80,39 @@ build: ## Build binaries (use WHAT=cmd/kelos to build specific binary). | |
| run: ## Run a controller from your host. | ||
| go run ./cmd/kelos-controller | ||
|
|
||
| IMAGE_PLATFORMS ?= linux/$(LOCAL_ARCH) | ||
| IMAGE_ARCHES = $(shell echo "$(IMAGE_PLATFORMS)" | tr ',' '\n' | cut -d'/' -f2 | tr '\n' ' ') | ||
| PUSH ?= false | ||
|
|
||
| .PHONY: image | ||
| image: ## Build docker images (use WHAT to build specific image). | ||
| image: ## Build docker images (use WHAT, IMAGE_PLATFORMS, PUSH=true to customize). | ||
| @for dir in $(filter cmd/%,$(or $(WHAT),$(IMAGE_DIRS))); do \ | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: |
||
| GOOS=linux GOARCH=amd64 $(MAKE) build WHAT=$$dir; \ | ||
| name=$$(basename $$dir); \ | ||
| for arch in $(IMAGE_ARCHES); do \ | ||
| GOOS=linux GOARCH=$$arch $(MAKE) build WHAT=$$dir; \ | ||
| mv bin/$$name bin/$${name}-linux-$$arch; \ | ||
| done; \ | ||
| done | ||
| @for arch in $(IMAGE_ARCHES); do \ | ||
| GOOS=linux GOARCH=$$arch $(MAKE) build WHAT=cmd/kelos-capture; \ | ||
| mv bin/kelos-capture bin/kelos-capture-linux-$$arch; \ | ||
| done | ||
| @GOOS=linux GOARCH=amd64 $(MAKE) build WHAT=cmd/kelos-capture | ||
| @for dir in $(or $(WHAT),$(IMAGE_DIRS)); do \ | ||
| docker build -t $(REGISTRY)/$$(basename $$dir):$(VERSION) -f $$dir/Dockerfile .; \ | ||
| docker buildx build --platform $(IMAGE_PLATFORMS) \ | ||
| $(if $(filter true,$(PUSH)),--push,--load) \ | ||
| -t $(REGISTRY)/$$(basename $$dir):$(VERSION) \ | ||
| -f $$dir/Dockerfile .; \ | ||
| done | ||
|
|
||
| .PHONY: push | ||
| push: ## Push docker images (use WHAT to push specific image). | ||
| .PHONY: manifest | ||
| SOURCE_VERSION ?= $(VERSION) | ||
|
|
||
| manifest: ## Create and push multi-arch manifest from per-arch images (use WHAT, IMAGE_PLATFORMS, SOURCE_VERSION). | ||
| @for dir in $(or $(WHAT),$(IMAGE_DIRS)); do \ | ||
| docker push $(REGISTRY)/$$(basename $$dir):$(VERSION); \ | ||
| name=$$(basename $$dir); \ | ||
| docker buildx imagetools create \ | ||
| -t $(REGISTRY)/$$name:$(VERSION) \ | ||
| $(foreach arch,$(IMAGE_ARCHES),$(REGISTRY)/$$name:$(SOURCE_VERSION)-$(arch) ); \ | ||
| done | ||
|
|
||
| RELEASE_PLATFORMS ?= linux/amd64 linux/arm64 darwin/amd64 darwin/arm64 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| FROM gcr.io/distroless/static:nonroot | ||
| ARG TARGETARCH | ||
| WORKDIR / | ||
| COPY bin/kelos-controller . | ||
| COPY bin/kelos-controller-linux-${TARGETARCH} kelos-controller | ||
| USER 65532:65532 | ||
| ENTRYPOINT ["/kelos-controller"] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| FROM gcr.io/distroless/static:nonroot | ||
| ARG TARGETARCH | ||
| WORKDIR / | ||
| COPY bin/kelos-spawner . | ||
| COPY bin/kelos-spawner-linux-${TARGETARCH} kelos-spawner | ||
| USER 65532:65532 | ||
| ENTRYPOINT ["/kelos-spawner"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug:
cmd/ghproxyandcmd/kelos-webhook-serverare back inIMAGE_DIRS, but their Dockerfiles weren't updated for multi-arch. The image build loop (line 89) renames binaries tobin/$name-linux-$arch, sobin/ghproxyno longer exists — onlybin/ghproxy-linux-amd64. Their Dockerfiles stillCOPY bin/ghproxy .andCOPY bin/kelos-webhook-server ., which will fail.Needs the same
ARG TARGETARCH+ renamed COPY treatment as the other Dockerfiles: