-
-
Notifications
You must be signed in to change notification settings - Fork 165
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
Use platform transition in the oci_image_index rule #531
Conversation
The current way of listing images makes Bazel build images for a platform that is not the configured target platform, defined by --platforms. This commit changes the behaviour and applies a transition so that the images are built for the configured target platform. New way: oci_image_index( name = "app", image = ":app_linux", platforms = [ "@io_bazel_rules_go//go/toolchain:linux_amd64", "@io_bazel_rules_go//go/toolchain:linux_arm64", ] ) Old way: oci_image_index( name = "app", image = [ ":app_linux_amd64", ":app_linux_arm64" ], ) For backwards compatibility, the old way is still possible to use.
Our original intent here was to minimize the code in rules_oci that needs to understand what the user is doing, we liked that transitions occur explicitly. OTOH I do see how this syntax sugar makes it nicer.
I'm not sure I follow this existing bug you suggest - don't we build for the same platforms before and after this change? The same targets get transitioned in the same way? |
Consider the following example: cc_binary(
name = "binary_linux_arm64",
)
pkg_tar(
name = "app_tar_linux_arm64",
srcs = [":binary_linux_arm64"],
)
oci_image(
name = "app_image_linux_arm64",
tars = [":app_tar_linux_arm64"],
)
oci_image_index(
name = "app_index",
images = [
":app_image_linux_arm64"
],
) I would normally only have a target called The idea here is that all the cc_binary(
name = "binary",
)
pkg_tar(
name = "app_tar",
srcs = [":binary"],
)
oci_image(
name = "app_image",
tars = [":app_tar"],
) The |
Let's keep the discussion about the plan forward in #228. Are the failing tests due to this change? My feeling is that it is something unrelated. Anyway, some tests should be added for this new functionality. |
Can we close this since we don't have to land a change for this? |
Okay, i am going to close this for house keeping purposes. Thank you for putting time into this. |
The current way of listing images makes Bazel build images for a platform that is not the configured target platform, defined by --platforms. This commit changes the behaviour and applies a transition so that the images are built for the configured target platform.
New way:
Old way:
For backwards compatibility, the old way is still possible to use.