Control Over Multistage Build Args

Hi
With a multistage build how to achieve a reusable logic approach as follows
Extract shared logic into a base image

FROM ubuntu
ONBUILD ARG LOGIC_PARAM
ONBUILD RUN # some action related to $LOGIC_PARAM

Prebuild this as local/some-reusable-logic

And then how to provide individual build args controlled from the image it self down to each stage separately as

FROM local/some-reusable-logic AS pipeA  # parameterize with LOGIC_PARAM=A
FROM local/some-reusable-logic AS pipeB  # parameterize with LOGIC_PARAM=B

FROM ubuntu
COPY --from= pipeA /target targetA
COPY --from= pipeB /target targetB

Thanks

I am afraid setting an arg for a stage is not possible. You can only set the arg for a build.

docker build --build-arg LOGIC_PARAM …` will not allow you to set different values for the same arg.

In the last 12 years, I have seen no one using ONBUILD in production. I only saw people playing around with it In my opinion ONBUILD violates the principle of least surprise.