So I have issues building my docker container for arm/v6 because a tool I use for dependency management (Poetry to be specific) depends on some python wheels that do not exist / are not prebuilt on arm/v6. I only use this tool in one stage to generate a file (requirements.txt) to use with pip in a later stage. Is it possible to run a single stage on e.g. x86, copy over this generated file and run all of the other stages with arm/v6?
With buildkit there are a set of predefined arguments you can use, along with the --platform
parameter to FROM
to select a specific platform from a multi-platform image:
FROM --platform=$BUILDPLATFORM your_base:tag as build
...
FROM your_run:tag as release
COPY --from=build requirements.txt .
...
This will use the current build host platform for the build stage, and the target platform for the release stage. There are other build args documented in the Dockerfile documentation.
For more details on these features, see Docker's multi-platform build documentation.