Skip to content

solver: route gateway dockerfile.v0 source to builtin frontend#6643

Merged
tonistiigi merged 1 commit intomoby:masterfrom
crazy-max:gateway-builtin-syntax
Apr 8, 2026
Merged

solver: route gateway dockerfile.v0 source to builtin frontend#6643
tonistiigi merged 1 commit intomoby:masterfrom
crazy-max:gateway-builtin-syntax

Conversation

@crazy-max
Copy link
Copy Markdown
Member

@crazy-max crazy-max commented Apr 1, 2026

alternative to and closes #6594

BuildKit treats gateway.v0 requests with source=dockerfile.v0 as requests for the built-in Dockerfile frontend. The request is normalized before frontend dispatch, so the solve is handled and recorded as dockerfile.v0 instead of remaining a gateway.v0 request.

This keeps the behavior aligned with the actual request shape that Buildx sends today. It also makes provenance and history reflect the built-in Dockerfile frontend correctly.

@crazy-max crazy-max force-pushed the gateway-builtin-syntax branch 2 times, most recently from 7067599 to 75e48b4 Compare April 1, 2026 20:46
@crazy-max crazy-max requested a review from tonistiigi April 1, 2026 20:58
@crazy-max crazy-max added this to the v0.30.0 milestone Apr 1, 2026
@crazy-max crazy-max marked this pull request as ready for review April 1, 2026 20:58
Comment thread frontend/gateway/gateway.go Outdated
return nil, errors.Errorf("no source specified for gateway")
}

if cmdline := strings.TrimSpace(opts["cmdline"]); cmdline == "dockerfile.v0" {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this checking cmdline instead of just source == "dockerfile.v0

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think cmdline is stricter than source. Buildx sets source to the first token of BUILDKIT_SYNTAX and keeps the original value in cmdline, so checking only source would also treat values like dockerfile.v0 foo as the builtin selector. I keyed it off strings.TrimSpace(cmdline) == "dockerfile.v0" to keep the special case limited to the exact selector and avoid changing behavior for malformed values. If you prefer source == "dockerfile.v0" for simplicity, I can switch it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The contract is that gateway will load whatever is in the source option. cmdline is just a way to pass arguments that are not parsed by buildkit itself. So I think we should only use source.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

@crazy-max crazy-max force-pushed the gateway-builtin-syntax branch from 75e48b4 to cc113e9 Compare April 2, 2026 08:43
@crazy-max crazy-max requested a review from tonistiigi April 2, 2026 08:43
@crazy-max crazy-max force-pushed the gateway-builtin-syntax branch from cc113e9 to 80b841c Compare April 2, 2026 09:07
@crazy-max crazy-max changed the title gateway: route dockerfile.v0 cmdline to builtin frontend gateway: route dockerfile.v0 source to builtin frontend Apr 2, 2026

var pred provenancetypes.ProvenancePredicateSLSA1
require.NoError(t, json.Unmarshal(dt, &pred))
require.Empty(t, pred.BuildDefinition.ExternalParameters.Request.Frontend)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is empty correct here? Shouldn't it be dockerfile.v0?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hum yeah you're right, I changed this. The previous test was going through c.Build(..., frontendFunc), so it was the client-frontend wrapper path and Request.Frontend stayed empty for that reason, not because the gateway handoff was correct. I changed the test to run a top-level gateway.v0 solve with source=dockerfile.v0 so the recorded frontend is dockerfile.v0, which is the thing we actually want here.

@crazy-max crazy-max force-pushed the gateway-builtin-syntax branch from 80b841c to f68d2a8 Compare April 3, 2026 15:43
@tonistiigi
Copy link
Copy Markdown
Member

Check CI. For this to be correct in provenance I think the switch needs to be before the request is routed to frontend.

@crazy-max crazy-max force-pushed the gateway-builtin-syntax branch from f68d2a8 to 2d1526c Compare April 7, 2026 09:00
@crazy-max crazy-max force-pushed the gateway-builtin-syntax branch 3 times, most recently from d212c08 to 8351b9a Compare April 7, 2026 13:06
@crazy-max crazy-max requested a review from tonistiigi April 7, 2026 13:25
@crazy-max crazy-max force-pushed the gateway-builtin-syntax branch 2 times, most recently from 318a5bf to a94c493 Compare April 7, 2026 14:50
@crazy-max crazy-max changed the title gateway: route dockerfile.v0 source to builtin frontend solver: route gateway dockerfile.v0 source to builtin frontend Apr 7, 2026
Comment thread solver/llbsolver/solver.go Outdated
}

func (s *Solver) Solve(ctx context.Context, id string, sessionID string, req frontend.SolveRequest, exp ExporterRequest, ent []entitlements.Entitlement, post []Processor, internal bool, srcPol *spb.Policy, policySession string) (_ *client.SolveResponse, err error) {
if req.Frontend == "gateway.v0" && req.FrontendOpt[frontend.KeySource] == "dockerfile.v0" {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we should check if there is no named context set for dockerfile.v0?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch! I added a guard so the shortcut only applies when there is no context:dockerfile.v0 override, including the platform context:dockerfile.v0::... form

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
@crazy-max crazy-max force-pushed the gateway-builtin-syntax branch from a94c493 to 3f3c957 Compare April 8, 2026 11:13
@tonistiigi tonistiigi merged commit a243ce4 into moby:master Apr 8, 2026
192 checks passed
@crazy-max crazy-max deleted the gateway-builtin-syntax branch April 8, 2026 18:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants