11load ("@aspect_bazel_lib//lib:testing.bzl" , "assert_archive_contains" )
2- load ("@aspect_bazel_lib//lib:transitions.bzl" , "platform_transition_filegroup" )
32load ("@container_structure_test//:defs.bzl" , "container_structure_test" )
43load ("@rules_go//go:def.bzl" , "go_binary" , "go_library" , "go_test" )
5- load ("@rules_oci//oci:defs.bzl" , "oci_image" , "oci_load" , "oci_push" )
4+ load ("@rules_img//img:image.bzl" , "image_index" , "image_manifest" )
5+ load ("@rules_img//img:load.bzl" , "image_load" )
6+ load ("@rules_img//img:push.bzl" , "image_push" )
67load ("@tar.bzl" , "mutate" , "tar" )
78
89go_library (
@@ -41,26 +42,26 @@ assert_archive_contains(
4142 expected = ["app" ],
4243)
4344
44- oci_image (
45- name = "image " ,
45+ image_manifest (
46+ name = "_image " ,
4647 # This is defined by an oci.pull() call in /MODULE.bazel
4748 base = "@distroless_base" ,
4849 entrypoint = ["/app" ],
4950 # Link the resulting image back to the repository where the build is defined.
5051 labels = {
5152 "org.opencontainers.image.source" : "https://github.com/aspect-build/bazel-examples" ,
5253 },
53- tars = [":app_layer" ],
54+ layers = [":app_layer" ],
5455)
5556
5657# This is the target that should be released to the target platform
57- platform_transition_filegroup (
58- name = "transitioned_image " ,
59- srcs = [":image " ],
60- target_platform = select ({
61- "@platforms//cpu:arm64" : "@ rules_go//go/toolchain:linux_arm64" ,
62- "@platforms//cpu:x86_64" : "@ rules_go//go/toolchain:linux_amd64" ,
63- }) ,
58+ image_index (
59+ name = "image " ,
60+ manifests = [":_image " ],
61+ platforms = [
62+ "@rules_go//go/toolchain:linux_arm64" ,
63+ "@rules_go//go/toolchain:linux_amd64" ,
64+ ] ,
6465)
6566
6667# $ bazel run //oci_go_image:load
@@ -69,11 +70,11 @@ platform_transition_filegroup(
6970# - "Hello World",
7071# + "Hello Go",
7172# )
72- oci_load (
73+ image_load (
7374 name = "load" ,
7475 # Use the image built for the target platform
75- image = ":transitioned_image " ,
76- repo_tags = [ "gcr.io/example:latest" ] ,
76+ image = ":image " ,
77+ tag = "gcr.io/example:latest" ,
7778)
7879
7980container_structure_test (
@@ -87,12 +88,13 @@ container_structure_test(
8788 ],
8889)
8990
90- oci_push (
91+ image_push (
9192 name = "push" ,
92- image = ":transitioned_image" ,
93- remote_tags = [
94- "latest" ,
93+ image = ":image" ,
94+ registry = "ttl.sh" ,
95+ repository = "/aspect-build/oci_go_image_example" ,
96+ tags = [
9597 "24h" ,
98+ "latest" ,
9699 ],
97- repository = "ttl.sh/aspect-build/oci_go_image_example" ,
98100)
0 commit comments