Support for passing through raw buildkit policies#1628
Conversation
|
Notes from @tonistiigi from slack: https://dockercommunity.slack.com/archives/C7S7A40MP/p1679946536583609?thread_ts=1679946076.766389&cid=C7S7A40MP Recording them here in case the Slack history disappears:
last point is similar to #1675 |
|
@AkihiroSuda Afaics, the points from the last comment have not been updated yet. |
|
@cpuguy83 are you still interested in looking at this? We're coming up to a buildx release soon, I imagine you'd probably want this in? If you're busy, I can try and carry this with @tonistiigi's suggested points 🎉 |
|
I think I've mostly got it. Sent you a message in slack but I'll post here as well:
|
3469444 to
ebbb602
Compare
|
Updated this with the requested changes. Note that while policies will apply to bakes it does not currently print that information with |
|
If we decide to remove the experimental or expose this more visibly, then it should show up in |
|
I think we still need a couple changes - we need to avoid calling I'm also not convinced on the env name - I'd personally prefer to use a combination of our already existing |
This adds an env var which can be used to pass in a path to a file to read a buildkit source poliy from. This is applied to any build is executed with the env set. It is also applied to bakes (which are calling build behind the scenes). Signed-off-by: Brian Goff <cpuguy83@gmail.com>
|
Updated with the changes from your fixup commit. |
| p := os.Getenv("EXPERIMENTAL_BUILDKIT_SOURCE_POLICY") | ||
| if p == "" { | ||
| return nil, nil | ||
| } | ||
|
|
||
| data, err := os.ReadFile(p) |
There was a problem hiding this comment.
If I wanted to update this to also allow passing the policy itself via environment variable,
-
would such a change be considered?
-
should that be implemented with this same variable (some kind of fallback either after reading the file or after trying to parse the JSON string?) or via a different variable?
😇
There was a problem hiding this comment.
would such a change be considered?
I think this could be a bit messy to pass a big json/proto value with env. Any other option that would avoid creating temp file if that is the issue?
There was a problem hiding this comment.
I guess something like EXPERIMENTAL_BUILDKIT_SOURCE_POLICY=<(... generate policy here ...) docker buildx build ... would probably work, given we read the entire file all at once and don't make any assumptions about it being an actual file (like trying to seek or something).
While we consider coming up with a nice DX for policies, allow passing through the raw buildkit format.