feat(build): let --build-context replace the runtime image
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 45/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- docker, go
- Ambito
- build-system, devops
Direzione di ricerca
Start with pkg/build/build.go, pkg/build/context.go, and pkg/agentkit2llb/agent/convert.go to trace how the runtime image becomes the LLB base; check BuildKit's dockerui.NamedContext API for loading a named context per platform. Then review pkg/build/build_test.go and the agent LLB tests, and run go test ./... and make lint. Done means the context and conflict behavior are tested, the bake targets and both docs are updated, and existing Makefile targets still work.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Problem
Every agent image starts from a runtime image, for example ghcr.io/orka-agents/agentkit/serve-pydantic-ai:latest. Today the only way to use a different one is --build-arg adapter=<image>. That has to be an image BuildKit can download, or one in Docker's local image store when you use Docker's default builder.
This causes four problems:
- The dev loop needs
--load.make build-servebuilds the runtime image and loads it into Docker asagentkit-serve:test.make build-test-agentthen points at it withadapter=agentkit-serve:test.- This only works with Docker's default builder. A container or remote builder (
docker buildx create ...) can't see local images, so you must push the runtime image to a registry first.
- No offline option. You can't use a runtime image saved in a local folder (an OCI layout) without running a registry.
- Mirrors are awkward. Teams that mirror images have to pass the full mirror image name on every build, outside Docker's usual way of swapping images.
- Tests can't easily use a fresh runtime image. Integration tests (#65) need to use a runtime image they just built, without pushing it anywhere.
Docker's standard answer is named build contexts: --build-context <name>=<source>. The source can be:
docker-image://<image>: another image, for example from a mirror;oci-layout://<folder>@sha256:<digest>: an image saved in a local folder, with no registry;target:<name>in adocker buildx bakefile: an image built earlier in the same bake run.
The Dockerfile frontend uses this to swap FROM images. dalec uses it to swap its build images (see dalec's targets docs, section "Named Build Contexts").
What
AgentKit looks for a build context named agentkit-runtime. If one is given, it's used as the runtime image instead of downloading the default.
# Use a mirror
docker buildx build -f agentkitfile.yaml . \
--build-context agentkit-runtime=docker-image://mirror.example.com/agentkit/serve-pydantic-ai@sha256:<digest>
# Use an image saved in a local folder, no registry needed
docker buildx build -f agentkitfile.yaml . \
--build-context agentkit-runtime=oci-layout://./serve-pydantic-ai@sha256:<digest>
- Multi-platform builds work. BuildKit also allows a separate context per platform (
agentkit-runtime::linux/arm64), and itsdockeruihelper handles this automatically. - No silent winner. If both
--build-context agentkit-runtimeand--build-arg adapterare given, fail with a clear message. - Settings unchanged. The image settings AgentKit writes stay the same. AgentKit already writes its own entrypoint, user, env and labels instead of copying them from the runtime image.
- One-command dev loop. Add a
docker-bake.hclso the runtime image and a test agent build together on any builder, without--load:
The AgentKit frontend image (target "serve-pydantic-ai" { dockerfile = "runtimes/pydantic-ai/Dockerfile" } target "test-agent-pydantic-ai" { dockerfile = "test/agentkitfile-hello.yaml" contexts = { agentkit-runtime = "target:serve-pydantic-ai" } args = { BUILDKIT_SYNTAX = "agentkit:test" } }BUILDKIT_SYNTAX) still has to be reachable by the builder. On a remote builder, that means pushing it to a registry. Swapping the frontend image itself is not part of this issue.
Out of scope
- Checking that the given image really is a runtime image for the file's runtime.
adapter=isn't checked today either. - Accepting the default image's own name as the context name, as dalec and Dockerfiles do. It's a possible follow-up.
- Changes to PR #52 (separate base and harness images). That PR could use the same mechanism for its two images, for example
agentkit-baseandagentkit-harness.
Why
- The dev loop works on any builder, including remote ones, without
--loador pushing runtime images. - Builds work offline from a local image folder.
- It uses the mechanism Docker users already know for swapping images.
- Integration tests (#65) can test fresh, unpushed runtime images.
How
Where things are
| File | What it does |
|---|---|
pkg/build/router.go |
RuntimeConfig.AdapterRef(opts) returns the adapter build arg or the default runtime image. |
pkg/build/build.go |
handleAgent() gets the runtime image name, then buildImage() builds each platform. |
pkg/agentkit2llb/agent/convert.go |
Agentkit2LLB(agent, adapterRef, platform) starts from llb.Image(adapterRef, llb.Platform(*platform)) and adds /agent/agent.yaml. |
pkg/build/context.go |
Already uses BuildKit's dockerui package. |
BuildKit frontend/dockerui/config.go |
(*dockerui.Client).NamedContext(name, dockerui.ContextOpt{Platform: p}) returns nil when no such context was given. (*NamedContext).Load(ctx) returns the image as an *llb.State. |
Makefile |
build-serve, build-test-agent and friends. Keep them working. |
Steps
- Look for the context. In
buildImage()(once per platform):- create
bc, err := dockerui.NewClient(c)and callbc.NamedContext("agentkit-runtime", dockerui.ContextOpt{Platform: platform}); - if it isn't
nil, callLoad(ctx)and use the returned state as the base. - Create the
dockeruiclient once and pass it down rather than creating one per platform.
- create
- Pass a starting point, not a name. Change
Agentkit2LLBto take the basellb.Stateinstead of an image name. Callers buildllb.Image(adapterRef, llb.Platform(...))themselves when no context was given. Leave the image settings code as it is. - Conflict check. If the context and the
adapterbuild arg are both set, return an error naming both. - Bake file.
- Add
docker-bake.hclwith a runtime-image target for each runtime and a test-agent target for each runtime, wired together withcontexts. - Mention it in
docs/development.md. Keep the existing make targets working.
- Add
- Name in one place. Keep the context name as a constant in
pkg/utils/const.gonext to the other build constants.
Tests
- Unit tests (
pkg/build/build_test.go,pkg/agentkit2llb/agent):- with no context, the base is the default runtime image, as today;
- with both the context and
adapter, the build fails with a clear message; Agentkit2LLBuses the given base state.
- End to end:
docker buildx bake test-agent-pydantic-aion adocker-containerbuilder (docker buildx create --driver docker-container --use) builds without loading or pushing the runtime image;- export a runtime image to a folder (
--output type=oci,dest=./serve,tar=false) and build an agent from it withoci-layout://; - a two-platform build with a context per platform.
- Integration tests: once #65 exists, add a real-BuildKit test there.
Run:
go test ./...
make lint
Docs
docs/agentkitfile.md, where it describes--build-arg adapter: add--build-context agentkit-runtime=...with the mirror and local-folder examples, plus the conflict rule.docs/development.md: the bake-based dev loop.
Done when
--build-context agentkit-runtime=<source>works withdocker-image://andoci-layout://sources, and with baketarget:sources.- Multi-platform builds work with per-platform contexts.
- Giving both the context and
adapterfails with a clear message. - The bake dev loop builds a test agent on a
docker-containerbuilder without--loadand without pushing the runtime image. - The docs cover the new option and the dev loop.
- Lingua principale
- Python
- Stelle
- 7
- Fork
- 5
- Merge medio
- 3h 39m
- PR unite (30g)
- 1
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di orka-agents/agentkit
-
fix(pydantic-ai): CI fails with newest pydantic-ai (unexpected 'history' argument)Forse già presa @gambtho l’ha presa 30 giorni fa. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
orka-agents/agentkit#77 ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
orka-agents/agentkit#76 · 3 commenti ·
-
area/build area/orka area/runtime blocked enhancement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
orka-agents/agentkit#69 ·
-
area/build area/orka area/runtime enhancement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 68/100
orka-agents/agentkit#68 ·
-
area/build enhancement testing
Difficoltà 5/5 Più di una settimana Idoneità per principianti 42/100
orka-agents/agentkit#65 ·
Tutte le issue di orka-agents/agentkit
Issue simili
-
【文档错误】创建镜像空间步骤中的截图标注与文字描述不一致Apertaenhancement
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 62/100
DaoCloud/DaoCloud-docs#7839 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
sav-oss-org/ptusa_main#1610 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno
-
bug status/accepted type/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
microsoft/apm#4925 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
sagemathinc/sagebrush#1701 ·
I maintainer di solito rispondono entro 1 giorno