Skip to content

[FR]: Support multi-architecture images build #2

@farcop

Description

@farcop

What is the current behavior?

Now it is unable to use multi-architecture base images in Dockerfile to build multi-architecture images

Describe the feature

I want to build multi-architecture images using rules_buildx.
E.g.

ARCHITECTURES = ["amd64", "arm64"]

[buildx(
    name = "image-installed-utils-{}".format(architecture),
    build_context = [
        context.oci_layout(
            "opensearchproject/opensearch:2.8.0",
            "@opensearch_linux_{}".format(architecture),
            q = "_{}".format(architecture),
        ),
    ],
    dockerfile = ":Dockerfile",
) for architecture in ARCHITECTURES]

Now I use patch with hack for rules_buildx to do so:

diff --git a/buildx/private/buildx_context.bzl b/buildx/private/buildx_context.bzl
index 03c1660..9c19707 100644
--- a/buildx/private/buildx_context.bzl
+++ b/buildx/private/buildx_context.bzl
@@ -47,8 +47,8 @@ oci_layout_buildx_workaround = rule(
     toolchains = ["@aspect_bazel_lib//lib:coreutils_toolchain_type"],
 )
 
-def _context_oci_layout(replace, layout):
-    name = str(replace).replace("/", "_").replace(":", "_")
+def _context_oci_layout(replace, layout, q = ""):
+    name = str(replace).replace("/", "_").replace(":", "_") + q
 
     # TODO: remove once https://github.com/docker/buildx/issues/2753 is solved and set store to layout directly.
     oci_layout_buildx_workaround(

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions