bazelbuild / rules_docker

Rules for building and handling Docker images with Bazel

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Incompatibility with rules_docker and current rules_go

chrislovecnm opened this issue · comments

bazel version:

$ bazel version
Build label: 0.26.1-homebrew

Note: I am using rules_go https://github.com/bazelbuild/rules_go/tree/8ea79bbd5e6ea09dc611c245d1dc09ef7ab7118a because I am trying to get cross compilation working again.

I am noticing an issue was introduced with the current 0.8.1 release. When using 0.8.1 and https://github.com/bazelbuild/rules_go/tree/8ea79bbd5e6ea09dc611c245d1dc09ef7ab7118a from rules_go I am getting the error:

ERROR: While resolving toolchains for target //:external_dns_image: no matching toolchains found for types @io_bazel_rules_docker//toolchains/docker:toolchain_type
ERROR: Analysis of target '//:external_dns_image' failed; build aborted: no matching toolchains found for types @io_bazel_rules_docker//toolchains/docker:toolchain_type

With rules_docker 0.8.0 I do not get this error when I am not cross compiling. When I use --platforms=@io_bazel_rules_go//go/toolchain:linux_amd64, 0.8.0 does not work as well.

I have tried to add the docker_toolchain_configure calls and also the calls to register the tool chains. Using the docker_toolchain_configure does not help. Using the register_toolchains call just give me a weird error that @gzip does not exist.

The repo that I am working out of is located here: https://github.com/chrislovecnm/external-dns/tree/work-on-bazel

Actually I am also getting the following error as well with 0.8.0:

 $ bazel build //...
INFO: Build option --platforms has changed, discarding analysis cache.
ERROR: While resolving toolchains for target //:external_dns_image: no matching toolchains found for types @io_bazel_rules_docker//toolchains/docker:toolchain_type
ERROR: Analysis of target '//:external_dns_image' failed; build aborted: no matching toolchains found for types @io_bazel_rules_docker//toolchains/docker:toolchain_type
INFO: Elapsed time: 0.220s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded, 143 targets configured)

When I am using the cross compilation flag: build --platforms=@io_bazel_rules_go//go/toolchain:linux_amd64

Let me add a bit of clarity.

rules_docker 0.8.0 works sorta when I do not specify build --platforms=@io_bazel_rules_go//go/toolchain:linux_amd64. Which of course is not gonna build a proper container because I am then compiling a darwiin binary, and creating a linux container. As soon as I use build --platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 I am getting the above error.

rules_docker 0.8.1 does not work at all ...

Here is the weird @gzip error I am getting as well:

$ bazel build //:external_dns_image
ERROR: /Users/chlove/Workspace/src/github.com/kubernetes-incubator/external-dns/BUILD.bazel:37:1: every rule of type _app_layer implicitly depends upon the target '@gzip//:gzip', but this target could not be found because of: no such package '@gzip//': The repository '@gzip' could not be resolved
ERROR: Analysis of target '//:external_dns_image' failed; build aborted: no such package '@gzip//': The repository '@gzip' could not be resolved

Hey @chrislovecnm ,
I don't think we made any changes to toolchains between 0.8.0 and 0.8.1.
The only thing we did change is how go dependencies are created (https://github.com/bazelbuild/rules_docker/pull/936/files). Can you bring your go imports + go toolchains declarations to the top of your WORKSPACE file to see if those changes somehow are affecting you? If so, I'll try to find a way to fix.

Both 0.8.0 and 0.8.1 do not work. So the changes are in the rules_go, or in rules_docker after rules docker 0.7.x. Also we have all the new challenges will how bazel loads the C++ toolchains as well.

It is not the bazel version. Just went back to 0.23.1 and had the same problem.

This seems to be an issue with the new rules_go, because I went back to 0.7 rules_docker.

responded on the rules_go issue.
For now, I'm going to close this with the statement, running go_image from a mac is not supported. If rules_go works on explicitly supporting (and testing) this then we can change the position from the rules_docker side.

It appears that the upstream rules_go bug is fixed: bazelbuild/rules_go#2089.

@nlopezgi now that the upstream issue is resolved, what would be needed to retest this?

It would be great to be able to remove this scary-looking blurb from the README.md:
https://github.com/bazelbuild/rules_docker/blame/master/README.md#L48-L52