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

Building and testing rules_docker on Apple Silicon #2036

Open
linzhp opened this issue Mar 1, 2022 · 9 comments
Open

Building and testing rules_docker on Apple Silicon #2036

linzhp opened this issue Mar 1, 2022 · 9 comments
Labels
Can Close? Will close in 30 days unless there is a comment indicating why not

Comments

@linzhp
Copy link
Collaborator

linzhp commented Mar 1, 2022

🚀 feature request

Relevant Rules

Description

Currently, the Go targets in rules_docker cannot build on Apple Silicon machines:

bazel build @io_bazel_rules_docker//container/go/...                        
DEBUG: /private/var/tmp/_bazel_zplin/d6323f9e3146540840037c805ccd73ff/external/bazel_toolchains/rules/rbe_repo/version_check.bzl:68:14: 
Current running Bazel is ahead of bazel-toolchains repo. Please update your pin to bazel-toolchains repo in your WORKSPACE file.
DEBUG: /private/var/tmp/_bazel_zplin/d6323f9e3146540840037c805ccd73ff/external/bazel_toolchains/rules/rbe_repo/checked_in.bzl:125:14: buildkite_config not using checked in configs; Bazel version 5.0.0 was picked/selected but no checked in config was found in map {"0.20.0": ["8.0.0"], "0.21.0": ["8.0.0"], "0.22.0": ["8.0.0", "9.0.0"], "0.23.0": ["8.0.0", "9.0.0"], "0.23.1": ["8.0.0", "9.0.0"], "0.23.2": ["9.0.0"], "0.24.0": ["9.0.0"], "0.24.1": ["9.0.0"], "0.25.0": ["9.0.0"], "0.25.1": ["9.0.0"], "0.25.2": ["9.0.0"], "0.26.0": ["9.0.0"], "0.26.1": ["9.0.0"], "0.27.0": ["9.0.0"], "0.27.1": ["9.0.0"], "0.28.0": ["9.0.0"], "0.28.1": ["9.0.0"], "0.29.0": ["9.0.0"], "0.29.1": ["9.0.0", "10.0.0"], "1.0.0": ["9.0.0", "10.0.0"], "1.0.1": ["10.0.0"], "1.1.0": ["10.0.0"], "1.2.0": ["10.0.0"], "1.2.1": ["10.0.0"], "2.0.0": ["10.0.0"], "2.1.0": ["10.0.0"], "2.1.1": ["10.0.0", "11.0.0"], "2.2.0": ["11.0.0"], "3.0.0": ["11.0.0"], "3.1.0": ["11.0.0"], "3.2.0": ["11.0.0"], "3.3.0": ["11.0.0"], "3.3.1": ["11.0.0"], "3.4.1": ["11.0.0"], "3.5.0": ["11.0.0"], "3.5.1": ["11.0.0"], "3.6.0": ["11.0.0"], "3.7.0": ["11.0.0"], "3.7.1": ["11.0.0"], "3.7.2": ["11.0.0"], "4.0.0": ["11.0.0"]}
ERROR: /Users/zplin/go/src/github.com/bazelbuild/rules_docker/container/go/cmd/digester/BUILD:31:10: While resolving toolchains for target //container/go/cmd/digester:digester: no matching toolchains found for types @io_bazel_rules_go//go:toolchain
ERROR: Analysis of target '//container/go/cmd/digester:digester' failed; build aborted: 
INFO: Elapsed time: 0.152s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (13 packages loaded, 0 targets configured)

As a result, end-to-end tests cannot run on Apple Silicon either:

testing/e2e.sh test_container_pull_with_auth
"docker rmi" requires at least 1 argument.
See 'docker rmi --help'.

Usage:  docker rmi [OPTIONS] IMAGE [IMAGE...]

Remove one or more images
9639f55a2c962719389fc290439ec41b9f583d7322397f20b1485ed47e5f2b86
Error: No such image: bazel/image:image
ERROR: /private/var/tmp/_bazel_zplin/aa79edc14e712d12745728305b89bbcc/external/io_bazel_rules_docker/container/go/cmd/join_layers/BUILD:19:10: While resolving toolchains for target @io_bazel_rules_docker//container/go/cmd/join_layers:join_layers: no matching toolchains found for types @io_bazel_rules_go//go:toolchain
ERROR: Analysis of target '@io_bazel_rules_docker//tests/container:push_test' failed; build aborted: 
INFO: Elapsed time: 2.059s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (12 packages loaded, 669 targets configured)
FAILED: Build did NOT complete successfully (12 packages loaded, 669 targets configured)

Describe the solution you'd like

Probably involving upgrading rules_go and some bug fixing in testing/e2e.sh.

Describe alternatives you've considered

Have you considered any alternative solutions or workarounds?
@chajath
Copy link

chajath commented Jul 18, 2022

I've worked around by installing the latest gazelle dependencies in my WORKSPACE

@gillesmag
Copy link

I came across this issue as well and fixed it as described in this thread.

@stabai
Copy link

stabai commented Aug 12, 2022

I just encountered this (on Mac M1 as well). From what I can tell, this looks like a regression in rules_go v0.34.0. I get the error in that version, but I also tried the 5 previous releases and those work fine. I've filed bazel-contrib/rules_go#3269 in that repo to track my particular issue, though I'm not sure it has the same root cause.

@zhangw
Copy link

zhangw commented Sep 17, 2022

I've worked around by installing the latest gazelle dependencies in my WORKSPACE

Yes, It works.

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had any activity for 180 days. It will be closed if no further activity occurs in 30 days.
Collaborators can add an assignee to keep this open indefinitely. Thanks for your contributions to rules_docker!

@github-actions github-actions bot added the Can Close? Will close in 30 days unless there is a comment indicating why not label Mar 17, 2023
@avarun42
Copy link

This issue is still present

@github-actions github-actions bot removed the Can Close? Will close in 30 days unless there is a comment indicating why not label Mar 18, 2023
@icaromag
Copy link

I can confirm that the issue still present.


http_archive(
    name = "io_bazel_rules_docker",
    sha256 = "b1e80761a8a8243d03ebca8845e9cc1ba6c82ce7c5179ce2b295cd36f7e394bf",
    urls = ["https://github.com/bazelbuild/rules_docker/releases/download/v0.25.0/rules_docker-v0.25.0.tar.gz"],
)

load("@io_bazel_rules_docker//repositories:repositories.bzl", container_repositories = "repositories")

container_repositories()

load("@io_bazel_rules_docker//repositories:deps.bzl", container_deps = "deps")

container_deps()

load("@io_bazel_rules_docker//go:image.bzl", _go_image_repos = "repositories")

_go_image_repos()

@icaromag
Copy link

To be able to build, I needed to add the following to my .bazelrc:

build --@io_bazel_rules_docker//transitions:enable=false

After that, you can build but it. If this error pops up:

WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested...

It indicates that the binary you're trying to run was built for a different architecture than the one you're currently using. Specifically, the binary was built for amd64 (aka x86_64), but your system is arm64.

So, the solution is to use this for building and running:

bazel build --platforms=@io_bazel_rules_go//go/toolchain:linux_arm64 //:bananas
bazel run --platforms=@io_bazel_rules_go//go/toolchain:linux_arm64 //:bananas

Or just edit your .bazelrc ✨

Copy link

This issue has been automatically marked as stale because it has not had any activity for 180 days. It will be closed if no further activity occurs in 30 days.
Collaborators can add an assignee to keep this open indefinitely. Thanks for your contributions to rules_docker!

@github-actions github-actions bot added the Can Close? Will close in 30 days unless there is a comment indicating why not label Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Can Close? Will close in 30 days unless there is a comment indicating why not
Projects
None yet
Development

No branches or pull requests

7 participants