bazelbuild / bazel-toolchains

Repository that hosts Bazel toolchain configs for remote execution and related support tools.
Apache License 2.0
184 stars 96 forks source link

Add support for --docker_platform flag #994

Closed lamcw closed 1 year ago

lamcw commented 1 year ago

When generating configs on a Mac (esp. ones with Apple silicon) using a Linux image, the docker daemon raises a warning

$ docker create --rm [a_linux_amd64_image] sleep infinity
The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
ff56913949408cfbad8d5b6d29888a741c2e1f2f3767695c78e75886619725ca

The rbe_config_gen expects the docker create command to return the container ID (which is 64 characters in length). The above warning breaks the contract and therefore will fail the config generation.

A possible solution is to add a --docker_platform flag to rbe_config_gen so that when it invokes docker create, a matching platform can be used to create the container (e.g. rbe_config_gen --docker_platform=linux/amd64 runs docker create --rm --platform linux/amd64 ...).

Closes #993

lamcw commented 1 year ago

Hey @smukherj1 @DaveGay sorry for the ping, can you PTAL at this PR?

DaveGay commented 1 year ago

Change looks good but buildkite doesn't seem to like it?

lamcw commented 1 year ago

@DaveGay the error is in master as well https://buildkite.com/bazel/bazel-toolchains/builds/26184#0189d288-690f-431f-8e65-12afd8d9526c

Can we merge this and fix the buildifier error in a follow up PR?