mirror of
https://github.com/kvcache-ai/AgentENV.git
synced 2026-11-05 01:17:36 +00:00
[PR #254] [MERGED] feat: build templates with managed BuildKit workers #295
Labels
No labels
bug
documentation
enhancement
enhancement
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
kvcache-ai/AgentENV#295
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/kvcache-ai/AgentENV/pull/254
Author: @yingdi-shan
Created: 9/7/2026
Status: ✅ Merged
Merged: 9/11/2026
Merged by: @yingdi-shan
Base:
main← Head:feat/buildkit-integration📝 Commits (6)
3b8c195feat: build templates with managed BuildKit workers077b995fix(buildkit): simplify workers and complete build validatione0d2ffafeat(release): bundle BuildKit client with aenv CLI0b514f3test(buildkit): wait for idle node metrics before baseline2cecd36fix(buildkit): preserve template API and publish images on server51c966afix(buildkit): bound build and tunnel concurrency📊 Changes
76 files changed (+6953 additions, -731 deletions)
View changed files
📝
.github/workflows/integration-tests.yml(+19 -12)📝
.github/workflows/release.yml(+25 -9)📝
Cargo.lock(+7 -10)📝
Makefile(+12 -1)📝
build.rs(+10 -0)➕
config/buildkit-version(+1 -0)📝
config/default.toml(+11 -0)📝
crates/aenv/Cargo.toml(+2 -2)➕
crates/aenv/src/client/buildkit.rs(+199 -0)📝
crates/aenv/src/client/mod.rs(+6 -0)📝
crates/aenv/src/commands/build.rs(+388 -512)📝
crates/aenv/src/main.rs(+2 -2)📝
crates/aenv/src/progress.rs(+60 -0)📝
deploy/docker-compose.yml(+6 -0)📝
docs/src/concepts/templates.md(+173 -21)📝
docs/src/configuration/reference.md(+17 -0)📝
docs/src/deployment/docker-compose.md(+9 -0)📝
docs/src/getting-started/aenv-cli.md(+49 -8)➕
scripts/buildkit/README.md(+61 -0)➕
scripts/buildkit/fixture/.dockerignore(+1 -0)...and 56 more files
📄 Description
What
Build Dockerfile contexts with BuildKit in managed microVMs and automatically publish the resulting runnable template on the server. The CLI streams context and BuildKit traffic; successful completion needs no client image-submission request.
Why
Support standard Dockerfile semantics, multi-stage builds, instruction-cache reuse, and persistent cache mounts while preserving the existing template API and remote storage format.
Related issue
Closes #147. Split from #247 alongside #252 (volume deletion) and #253 (OCI UID/GID startup).
Scope and non-goals
BuildKit image import, worker/cache lifecycle, node and gateway APIs, CLI packaging, configuration, tests, and documentation. CLI argument compatibility is outside this change. General volume deletion and OCI account resolution remain in the companion PRs; stage selection, SSH forwarding, remote/stdin contexts, and cross-platform emulation remain outside this flow.
Design and behavior changes
POST /v3/templatesallocates template/build IDs with its unchanged request and response.PUT /templates/{templateID}/builds/{buildID}/builderclaims the waiting build and prepares its worker. It returns the uniqueimageNameto use with the BuildKit image exporter. Already-started builds return409.building, then use authenticated WebSocketGETon the builder resource for native BuildKit traffic.readyorerror.DELETEon the builder cancels before publication; publication already in progress finishes independently of the client.The existing declarative build endpoint keeps its behavior. There is no competing build-creation collection or digest-submission endpoint. Gateway allocation records the build's node binding; subsequent builder and status requests follow it.
Prepared builder snapshots are reused by configuration. Every build receives a separate writable cache child. Cache-head updates and retirements are atomic, cleanup retries retain ownership, and failed/cancelled builds retain the previous seed. Build deadlines and recovery release abandoned workers; public sandbox operations hide builders. Stop BuildKit and checkpoint its cache before stopping the worker. Preserve image startup, health checks, and configuration; package a private
aenv-buildctlbeside the CLI.Compatibility and operations
template-buildnamespace. Startupshellis optional; old records retain Bash behavior and round-trip without adding it.Validation
make fmtmake clippymake test-unitmake -C services test fmt-check vetmake agentenv-serverCommands and results:
Focused coverage includes real-repository
404/409allocation, preserving a template namedbuilds, legacy snapshot serialization, stale history rejection, exporter descriptor selection, failed builds, history reconnection, and final Solve-response delivery during publication.Live tests use an isolated node with a 2-vCPU, 2048-MiB builder and an 8192-MiB cache. The client-exit regression kills the CLI immediately after a successful BuildKit solve and verifies that the server publishes a runnable template without any image-submission request. Successful cases verify worker and volume cleanup, leaving one ready cache seed.
Risks and reviewer notes
Concurrent builders multiply resource use. Cache sharing follows the repository's API-key trust boundary, and publication time depends on storage throughput. Review the completion watcher in
src/image/buildkit/history.rs, builder lifecycle insrc/api/impls/image_build/, and gateway allocation/routing.Merge #252 and #253 first for optimized deletion and numeric image users. The current live run covers the standalone BuildKit branch; numeric-user and combined-branch validation must be repeated with #253. Full Rust integration suites, a live multi-node gateway deployment, and throughput benchmarks were not run for this revision.
Checklist
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.