Skip to content
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

How to use container_structure_test with oci_image on MacOS #359

Closed
farcop opened this issue Jul 16, 2023 · 0 comments
Closed

How to use container_structure_test with oci_image on MacOS #359

farcop opened this issue Jul 16, 2023 · 0 comments

Comments

@farcop
Copy link

farcop commented Jul 16, 2023

I use https://github.com/bazel-contrib/rules_oci/tree/main/examples/multi_arch code to build go project.

Then I add container_structure_test to test is that binary is runnable.

multi_arch(
    name = "images",
    image = ":image",
    platforms = [
        "//:linux_arm64",
        "//:linux_amd64",
    ],
)

oci_image_index(
    name = "index",
    images = [
        ":images",
    ],
)

oci_tarball(
    name = "tarball",
    image = ":image",
    repo_tags = ["%s:latest" % KCP_MODULE],
)

container_structure_test(
    name = "container_test",
    configs = ["container_test.yaml"],
    image = ":image",
)

oci_push(
    name = "push_index",
    image = ":index",
    remote_tags = ["test"],
    repository = image_repository(KCP_MODULE),
    visibility = ["//visibility:public"],
)

If I run test on Mac M1 I have exec format error.

The problem is that container_structure_test use linux arm64 binary on darwin arm64.

Binary @ image

% docker run -it --entrypoint /bin/sh registry.my.com/image:test
/opt/backup-controller $ file backup-controller
backup-controller: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), statically linked, Go BuildID=redacted, stripped

Binary @ oci_tarball output

% docker run -it --entrypoint /bin/sh backup-controller:latest                           
~/backup-controller $ file backup-controller
backup-controller: Mach-O 64-bit arm64 executable, flags:<|DYLDLINK|PIE>

How to use container_structure_test with oci_image in the right way?

@farcop farcop closed this as not planned Won't fix, can't repro, duplicate, stale Jul 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant