Skip to content

Commit 1f6c273

Browse files
committed
use kaniko as build backend
Signed-off-by: Radek Ježek <[email protected]>
1 parent 26d0056 commit 1f6c273

File tree

5 files changed

+60
-10
lines changed

5 files changed

+60
-10
lines changed

apps/beeai-sdk/src/beeai_sdk/platform/provider_build.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ async def get(self: ProviderBuild | str, *, client: PlatformClient | None = None
6868

6969
async def delete(self: ProviderBuild | str, *, client: PlatformClient | None = None) -> None:
7070
# `self` has a weird type so that you can call both `instance.delete()` or `ProviderBuild.delete("123")`
71-
provider_id = self if isinstance(self, str) else self.id
71+
provider_build_id = self if isinstance(self, str) else self.id
7272
async with client or get_platform_client() as client:
73-
_ = (await client.delete(f"/api/v1/provider_builds/{provider_id}")).raise_for_status()
73+
_ = (await client.delete(f"/api/v1/provider_builds/{provider_build_id}")).raise_for_status()
7474

7575
@staticmethod
7676
async def list(

apps/beeai-server/src/beeai_server/infrastructure/kubernetes/provider_build_manager.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ async def create_job(
8888
git_host_upper=provider_build.source.host.upper(),
8989
git_org=provider_build.source.org,
9090
git_repo=provider_build.source.repo,
91+
git_path=provider_build.source.path or ".",
9192
git_ref=provider_build.source.commit_hash,
9293
destination=str(provider_build.destination),
9394
),

apps/beeai-server/tests/e2e/agents/test_agent_builds.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Copyright 2025 © BeeAI a Series of LF Projects, LLC
22
# SPDX-License-Identifier: Apache-2.0
3-
3+
import asyncio
44
import json
55
import logging
66

@@ -27,7 +27,12 @@ async def test_remote_agent_build_and_start(
2727
build = await ProviderBuild.create(location=test_configuration.test_agent_build_repo)
2828
async for message in build.stream_logs():
2929
logger.debug(json.dumps(message))
30-
build = await build.get()
30+
31+
for _ in range(10):
32+
build = await build.get()
33+
if build.status != BuildState.IN_PROGRESS:
34+
break
35+
await asyncio.sleep(0.5)
3136

3237
assert build.status == BuildState.COMPLETED
3338
with subtests.test("run example agent"):

helm/templates/config/provider_templates.yaml

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ data:
104104
image: ghcr.io/i-am-bee/alpine/git:v2.49.1
105105
command: [ "/bin/sh" ]
106106
env:
107-
- name: GIT_HOST_TOKEN
107+
- name: GIT_TOKEN
108108
valueFrom:
109109
secretKeyRef:
110110
name: beeai-platform-secret
@@ -115,14 +115,14 @@ data:
115115
- |
116116
echo "Cloning repository..."
117117
# Check if GitHub token is available for this host
118-
if [ -n "$GIT_HOST_TOKEN" ]; then
118+
if [ -n "$GIT_TOKEN" ]; then
119119
echo "Using authenticated clone for {{`{{ git_host }}`}}"
120120
else
121121
echo "Using unauthenticated clone for {{`{{ git_host }}`}}"
122122
fi
123123
git clone --depth 1 \
124124
--revision {{`{{ git_ref }}`}} \
125-
"https://$GIT_HOST_TOKEN@{{`{{ git_host }}`}}/{{`{{ git_org }}`}}/{{`{{ git_repo }}`}}.git" \
125+
"https://$GIT_TOKEN@{{`{{ git_host }}`}}/{{`{{ git_org }}`}}/{{`{{ git_repo }}`}}.git" \
126126
/tmp/repo
127127
mv "/tmp/repo/{{`{{ git_path }}`}}"/* /workspace/ 2>/dev/null || true
128128
mv "/tmp/repo/{{`{{ git_path }}`}}"/.[^.]* /workspace/ 2>/dev/null || true
@@ -131,7 +131,8 @@ data:
131131
volumeMounts:
132132
- name: workspace
133133
mountPath: /workspace
134-
# Build image
134+
# Build image with BuildKit
135+
{{- if eq .Values.providerBuilds.buildBackend "buildkit" }}
135136
- name: buildkit
136137
image: ghcr.io/i-am-bee/moby/buildkit:v0.24.0-rootless
137138
env:
@@ -157,8 +158,6 @@ data:
157158
- type=inline
158159
- --import-cache
159160
- type=registry,ref={{`{{destination}}`}}{{- if .Values.providerBuilds.buildRegistry.insecure }},registry.insecure=true{{- end }}
160-
# To push the image to a registry, add
161-
# `--output type=image,name=docker.io/username/image,push=true`
162161
securityContext:
163162
# Needs Kubernetes >= 1.19
164163
seccompProfile:
@@ -182,6 +181,45 @@ data:
182181
mountPath: /docker/config.json
183182
subPath: .dockerconfigjson
184183
readOnly: true
184+
{{- else if eq .Values.providerBuilds.buildBackend "kaniko" }}
185+
# Build image with Kaniko (no securityContext required)
186+
- name: kaniko-build
187+
image: ghcr.io/kaniko-build/dist/chainguard-dev-kaniko/executor:v1.25.2-slim
188+
args:
189+
- --context=/workspace
190+
- --dockerfile=Dockerfile
191+
- --no-push
192+
- --tar-path=/tmp/image.tar
193+
volumeMounts:
194+
- name: workspace
195+
mountPath: /workspace
196+
- name: image-tar
197+
mountPath: /tmp
198+
# Main container: Step 3 Push the intermediary image
199+
- name: crane-push
200+
image: ghcr.io/i-am-bee/alpine/crane:0.20.6
201+
args:
202+
- push
203+
- /tmp/image.tar
204+
- {{`{{ destination }}`}}
205+
{{- if .Values.providerBuilds.buildRegistry.insecure }}
206+
- --insecure
207+
{{- end }}
208+
volumeMounts:
209+
- name: image-tar
210+
mountPath: /tmp
211+
- name: docker-config
212+
mountPath: /root/.docker/config.json
213+
subPath: .dockerconfigjson
214+
readOnly: true
215+
resources:
216+
requests:
217+
memory: "256Mi"
218+
cpu: "200m"
219+
limits:
220+
memory: "512Mi"
221+
cpu: "500m"
222+
{{- end }}
185223
- name: run-agent
186224
image: "{{`{{ destination }}`}}"
187225
restartPolicy: Always # This makes it a daemon sidecar container
@@ -247,8 +285,13 @@ data:
247285
volumes:
248286
- name: workspace
249287
emptyDir: { }
288+
{{- if eq .Values.providerBuilds.buildBackend "buildkit" }}
250289
- name: buildkitd
251290
emptyDir: { }
291+
{{- else if eq .Values.providerBuilds.buildBackend "kaniko" }}
292+
- name: image-tar
293+
emptyDir: { }
294+
{{- end }}
252295
- name: docker-config
253296
secret:
254297
secretName: {{ .Values.providerBuilds.buildRegistry.secretName }}

helm/values.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ imagePullSecrets: [ ]
7979

8080
providerBuilds:
8181
enabled: false
82+
buildBackend: "kaniko" # Options: "buildkit" or "kaniko"
8283
buildRegistry:
8384
registryPrefix: "beeai-platform-registry-svc.default:5001" # This must include a dot
8485
imageFormat: "{registry_prefix}/{org}/{repo}/{path}:{commit_hash}"

0 commit comments

Comments
 (0)