This command works fine and generates an image in ~1.3 Gb
docker build --build-arg PACKS="aws csv email excel git github gpg hubot vault xml" -t st2packs:1.0.5 st2packs-image
I am using Github Action and it uses docker buildx build command.
docker buildx build --build-arg PACKS="aws csv email excel git github gpg hubot vault xml" --tag st2packs:1.0.4 st2packs-image
This only produces 4Mb docker image with no packs copied.