#Buildkit resources
1 messages Ā· Page 1 of 1 (latest)
[2017] Buildkit introduction blog post. https://blog.mobyproject.org/introducing-buildkit-17e056cc5317
Turning on the CrazyMax signal š @plush compass
Project README of course: https://github.com/moby/buildkit/blob/master/README.md
There is an architecture diagram somewhere, but I can never find it
Thereās an examples/ directory showing how to assemble and invoke Buildkit DAGs directly from the Go API. Itās pretty unreadable TBH, a good reminder of why Cue+Buildkit is such a superior combination. https://github.com/moby/buildkit/blob/master/examples/gobuild/main.go
@faint cedar not sure if you still watch this channel⦠But if you do we would welcome any suggestions š
The build cache can even be exported to a registry, where it can be pulled on-demand by subsequent invocations on any host.
š¤Æ
have we explored that yet?
Yes š It has drawbacks, but current plan is to rely on that for CI embedding
They have a cache exporter that works specifically with Github Actionās persistent storage API
cc @lapis yarrow @plush compass
(Main drawbacks are that exporting is an additional action in the DAG, and canāt be parallelized, so it adds to the total run time. And some remote cache exporters donāt support āmax modeā, meaning they donāt actually cache everything. This can result in only caching results from the last run, greatly reducing utility of the cache.)
This dev guide can be useful too. Will see if we can port (and update it) to the repo in /docs.
I was gonna try to find some resources around Buildkit. Thanks for pulling these together!
LLB protobuf definitions if anyone else is curious š https://github.com/moby/buildkit/blob/master/solver/pb/ops.proto
A thought just occured to me: does Cue support native Protobuf import? š cc @timid gust
@royal wigeon Hmm.... I think so. Can't remember if that work is done, or just in progress.
https://cuelang.org/docs/usecases/generate/#extract-data-definition-from-existing-sources
CUE can currently extract definitions from:
Go code
Protobuf definitions.
Converting CUE constraints to and from definitions in other languages.
Nice! So could I for example cue get github.com/moby/buildkit/solver/pb ?
Or cue import ?
Looks like it's through the API for now: https://cuelang.org/docs/integrations/protobuf/#extract-cue-from-a-standalone-proto-file
Yeah it doesnāt really say how
@royal wigeon
Ah cue import does mention proto support! Will try that
Nice!
@timid gust it seems to be OK with the proto file, but failing on import (the proto file has dependencies on other proto files)
Dropping for now, I donāt really need it for my proof of concept. Copy-pasting bits and pieces is fine for my immediate purpose.
@royal wigeon š -I, --proto_path stringArray paths in which to search for imports
TIL, buildkit LLB does not define distinct operations for loading a local directory, remote docker image or remote git ref. Itās all OpSource with a URI-formatted identifier. Supported URL schemes are local://, docker-image://, git://, https://
Interesting.
Top-level op:
// Op represents a vertex of the LLB DAG.
message Op {
// inputs is a set of input edges.
repeated Input inputs = 1;
oneof op {
ExecOp exec = 2;
SourceOp source = 3;
FileOp file = 4;
BuildOp build = 5;
}
Platform platform = 10;
WorkerConstraints constraints = 11;
}
Source op:
// SourceOp specifies a source such as build contexts and images.
message SourceOp {
// TODO: use source type or any type instead of URL protocol.
// identifier e.g. local://, docker-image://, git://, https://...
string identifier = 1;
// attrs are defined in attr.go
map<string, string> attrs = 2;
}
Note this doesnāt map 1-1 to the corresponding Go API
Which I am more familiar with
For example hereās the llb.Git() call which is roughly equivalent to our op.#FetchGit. You can see how it maps git-specific parameters do the more generic llb āsourceā op: https://github.com/moby/buildkit/blob/be8ab28a0ab1f7eafa4c551a86d5aafaed7c99c2/client/llb/source.go#L210-L287
Iām wondering if we should target the Go API, or underlying LLB format, in our CUE bindings? cc @plush compass @faint cedar @flat nacelle
I guess the LLB format is more stable by necessity⦠But some aspects of the proto API seem awkward, with the Go API hiding some of the awkwardness⦠For example llb.Git() takes a remote which can be eg. ssh:// or https://. But SourceOp must prefix all git remotes with git:// so how where does the information go about the original scheme? The answer seems to be ādonāt look to closelyā š