Hilscher Community Forum
Multi-stage builds for slim container images - Printable Version

+- Hilscher Community Forum (https://forum.hilscher.com)
+-- Forum: netPI 3 - Docker featuring Industrial Raspberry Pi 3 platform (https://forum.hilscher.com/forum-1.html)
+--- Forum: Software (https://forum.hilscher.com/forum-5.html)
+--- Thread: Multi-stage builds for slim container images (/thread-377.html)



Multi-stage builds for slim container images - Armin@netPI - February-7th-2019

These days it was time to think about Docker's multi-stage build feature and to provide an example of how it works.

Multi-stage builds are always then of any interest if applications need to be compiled first before getting them to an executeable state and as such be installed in the final container image ... but without all the necessary development tools, environments and compilers. This keeps the image small and away from all unnecessary data needed during compilation times only.

We found that the bluetooth registry on DockerHub would be best for a demonstration. Its Dockerfile contains two FROM commands the build process turns into two separate builds. Build STEP 1 creates a temporary container and compiles the bluetooth stack ... Build STEP 2 builds the final output container that is just copying the required outputs files of STEP 1.

Happy testing
Armin