St2packs not building properly on Mac under Docker 20.10.5

I’ve been having a problem recently with building the st2packs in a Mac. It seems that the builder stage of the Dockerfile is not getting executed. After a lot of trial and error, we determined that the only way to get it to work was to add something like the last line here to the Dockerfile

FROM stackstorm/st2packs:builder AS builder

RUN /opt/stackstorm/st2/bin/st2-pack-install “aws”

FROM stackstorm/st2packs:runtime
COPY --from=builder /opt/stackstorm/packs /opt/stackstorm/packs

It seems that unless you explicitly reference the builder stage it does not get executed even though it is referenced in an ONBUILD clause in the runtime Dockerfile. I don’t know if this is specific to the Mac or due to some new change in Docker but we had the same problem on multiple machines.