Skip to content

Commit 4b22c63

Browse files
committed
Add platform transition to main_image
1 parent e2a9f8c commit 4b22c63

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

examples/bzlmod/multi-platform/BUILD.bazel

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
load("@aspect_bazel_lib//lib:transitions.bzl", "platform_transition_filegroup")
12
load("@aspect_rules_py//py:defs.bzl", "py_image_layer")
23
load("@rules_oci//oci:defs.bzl", "oci_image", "oci_load")
34
load("@rules_python//python:defs.bzl", "py_binary")
@@ -19,7 +20,7 @@ py_binary(
1920
)
2021

2122
oci_image(
22-
name = "main_image",
23+
name = "_main_image",
2324
base = "@docker_io_python",
2425
entrypoint = ["/app/main"],
2526
tars = py_image_layer(
@@ -29,6 +30,20 @@ oci_image(
2930
),
3031
)
3132

33+
platform_transition_filegroup(
34+
name = "main_image",
35+
srcs = [":_main_image"],
36+
target_platform = select({
37+
"@platforms//cpu:arm64": "//platforms:linux_arm64",
38+
"@platforms//cpu:x86_64": "//platforms:linux_x86_64",
39+
}),
40+
)
41+
42+
# alias(
43+
# name = "main_image",
44+
# actual = "_main_image",
45+
# )
46+
3247
oci_load(
3348
name = "main_image.load",
3449
image = ":main_image",

examples/bzlmod/multi-platform/MODULE.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ module(
55
version = "0.0.1",
66
)
77

8+
bazel_dep(name = "aspect_bazel_lib", version = "2.19.4")
89
bazel_dep(name = "rules_python", version = "1.5.1")
910
bazel_dep(name = "rules_oci", version = "2.2.6")
1011
bazel_dep(name = "platforms", version = "1.0.0")

0 commit comments

Comments
 (0)