Docker Bake platform-specific adjustments

When building images, some platform-specific configurations are often required. For example, when working with uv, arm* builds require some flags to be set to prevent CPU thrashing during dependency installation.

How does one apply platform-specific changes to multiu-platform build stages in the Docker Bake HCL/yaml syntax?

You can use built-in variables:

https://github.com/docker/buildx/blob/master/docs/bake-reference.md#built-in-variables

The following variables are built-ins that you can use with Bake without having to define them.

Variable Description
BAKE_CMD_CONTEXT Holds the main context when building using a remote Bake file.
BAKE_LOCAL_PLATFORM Returns the current platform’s default platform specification (e.g. linux/amd64).

And there are variables in a Dockerfile

https://docs.docker.com/build/building/variables/#multi-platform-build-arguments

Then you can write conditions in scripts.

Is it what you were looking for?