Using the built binary of a docker image in another docker image
What you need is to use the build pattern or the multistage features of docker

https://docs.docker.com/develop/develop-images/multistage-build/

With that, you can use as many images as you need depending on your build process