Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow setting platform for scratch image #5670

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions frontend/dockerfile/dockerfile2llb/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,9 +468,12 @@ func toDispatchState(ctx context.Context, dt []byte, opt ConvertOpt) (*dispatchS
if d.base == nil && !d.dispatched && !d.resolved {
d.resolved = reachable // avoid re-resolving if called again after onbuild
if d.stage.BaseName == emptyImageName {
d.state = llb.Scratch()
d.image = emptyImage(platformOpt.targetPlatform)
d.platform = &platformOpt.targetPlatform
platform := d.platform
if platform == nil {
platform = &platformOpt.targetPlatform
}
Comment on lines +471 to +474
Copy link
Author

Choose a reason for hiding this comment

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

Unsure if that's needed

Suggested change
platform := d.platform
if platform == nil {
platform = &platformOpt.targetPlatform
}
platform := d.platform
if platform == nil {
platform = &platformOpt.targetPlatform
}
d.platform = platform

d.state = llb.Scratch().Platform(*platform)
d.image = emptyImage(*platform)
if d.unregistered {
d.dispatched = true
}
Expand Down Expand Up @@ -511,7 +514,7 @@ func toDispatchState(ctx context.Context, dt []byte, opt ConvertOpt) (*dispatchS
if img != nil {
d.image = *img
} else {
d.image = emptyImage(platformOpt.targetPlatform)
d.image = emptyImage(*platform)
}
d.state = st.Platform(*platform)
d.platform = platform
Expand Down
Loading