Multistage building is a feature that appeared with Docker 17.05. Prior to this version, if we wanted to ensure minimum image size and void compilers on final production images, we usually had to install the packages required for compiling, execute the binary's build, and then remove all non-required software, including used compilers, which are a real security problem in production.
Automating this kind of compilation was not easy, and sometimes, we needed to create our own scripts to reproduce those steps on every build, usually using third-party CI/CD orchestrations.
We can use many build definitions on a Dockerfile to create small and compiler-free images. These images will only include application libraries, executables, and configurations. All compilations steps will be done on another image and we will just include the resulting files in a new one. We could also use external images in this process. We will only copy the required files for...