bazelbuild / rules_docker

Rules for building and handling Docker images with Bazel
Apache License 2.0
1.07k stars 692 forks source link

Can't build containers on macOS after upgrade to 0.23.0 #2009

Open eikemeier opened 2 years ago

eikemeier commented 2 years ago

🐞 bug report

Affected Rule

The issue is caused by the rule: java_image

Is this a regression?

Yes, the previous version in which this bug was not present was: 0.22.0

Description

When building a simple Java Docker image on macOS, the build fails with “No matching toolchains found”. It works on Linux, since the target and host platforms are identical.

🔬 Minimal Reproduction

See https://github.com/eikemeier/java-container

🔥 Exception or Error


bazel build //src/main/java/com/example/hello_world:hello_world_image
[...]
ERROR: [...]/java-container/src/main/java/com/example/hello_world/BUILD:16:11: While resolving toolchains for target //src/main/java/com/example/hello_world:hello_world_image.binary: No matching toolchains found for types @bazel_tools//tools/cpp:toolchain_type. [...]

🌍 Your Environment

Operating System:

  
macOS Catalina 10.15.7
  

Output of bazel version:

  
5.0.0
  

Rules_docker version:

  
0.23.0
  

Anything else relevant?

See also https://github.com/bazelbuild/rules_docker/issues/1988#issuecomment-1016465174

dragonsinth commented 2 years ago

Same for go_image; 0.22.0 works, 0.23.0 doesn't. According to git bisect, seems to be introduced in: Transition container image target platform (#1963) 76c708fc979c1bfb65b4db300c654be08f096874

pcmoritz commented 2 years ago

Same for py3_image, 0.22.0 works and 0.23.0 doesn't. Hopefully this can be fixed soon :)

psalaberria002 commented 2 years ago

Is anyone looking into this issue? Any workaround other than going back to 0.22?

shs96c commented 2 years ago

We've had to prepare a cross-compiling C toolchain to use on macOS in order to make this work. Ultimately, we picked one based on musl, since that's most likely to work on most linux variants, but we've also had to patch rules_go to force go_binary to statically link when building for a docker image. Getting this working properly has been a pretty significant piece of work.

If anyone is following in our footsteps, we started off from musl-cross-make

github-actions[bot] commented 2 years ago

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!

kylekurz commented 2 years ago

I don't think this is closable, I'm still locked to 0.22 waiting on a fix for this.

github-actions[bot] commented 1 year ago

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!

kylekurz commented 1 year ago

As before, this is still an unaddressed issue and should not be closed.

trungdinhth commented 1 year ago

With py3_image, for 0.25 we are still having this problem.