-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
dsseng
wants to merge
1
commit into
moby:master
Choose a base branch
from
dsseng:scratch-arch
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BuildKit refers to platform set in the current LLB node for determining whether or not executing commands should use QEMU. This makes some build flows working fine without BuildKit to fail with it. This is of particular importance for cross-compilation cases. Make scratch image a no exception and allow platform to be set, therefore determining the architecture of binaries planned to be ran (e.g. if they are COPYed from contexts) Signed-off-by: Dmitry Sharshakov <[email protected]>
dsseng
commented
Jan 18, 2025
Comment on lines
+471
to
+474
platform := d.platform | ||
if platform == nil { | ||
platform = &platformOpt.targetPlatform | ||
} |
There was a problem hiding this comment.
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 |
dsseng
added a commit
to siderolabs/stagex
that referenced
this pull request
Jan 18, 2025
dsseng
added a commit
to siderolabs/stagex
that referenced
this pull request
Jan 18, 2025
dsseng
added a commit
to siderolabs/stagex
that referenced
this pull request
Jan 18, 2025
dsseng
added a commit
to siderolabs/stagex
that referenced
this pull request
Jan 18, 2025
dsseng
added a commit
to siderolabs/stagex
that referenced
this pull request
Jan 21, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
BuildKit refers to platform set in the current LLB node for determining whether or not executing commands should use QEMU. This makes some build flows working fine without BuildKit to fail with it. This is of particular importance for cross-compilation cases.
Make scratch image a no exception and allow platform to be set, therefore determining the architecture of binaries planned to be ran (e.g. if they are COPYed from contexts)
Example use case: siderolabs/stagex@eec19a8 - here we build for arm64 and amd64 targets, but use linux/386 compiler binary, as these are cross-compilation stages. So if scratch is used, then buildkit would use target platform and assume QEMU must be called to run /bin/sh, which crashed the build, since BuildKit called qemu-aarch64, which errored on i386 ELF file supplied. But with this patch I'm able to declare platform build happens in, even though I only add images later on (and for example stage3 pulls in multiplatform stage2, so in this case FROM stage2 directly won't work either)
Example build (listing logs with
linux/386->arm64
) https://github.com/siderolabs/stagex/actions/runs/12834542603/job/35792080087