docker-library / haproxy

Docker Official Image packaging for HAProxy
http://www.haproxy.org/
GNU General Public License v2.0
346 stars 158 forks source link

Use multi-stage build #230

Open taliesins opened 1 month ago

taliesins commented 1 month ago

To minimize the size of the image we probably want to build haproxy in one container and then copy the build outputs into the next container. This way the build tools are not in the haproxy container (smaller/safer image).

https://docs.docker.com/build/building/multi-stage/ https://github.com/b4tman/docker-squid/blob/master/Dockerfile

yosifkit commented 1 month ago

To which apt-installed dependencies are you referring to in the final image? The Dockerfile goes to great lengths to ensure that only packages that are linked to are kept after building haproxy, so things like gcc and make are definitely removed:

https://github.com/docker-library/haproxy/blob/8db4f308c73a105b2f05c55f144486ccddb2c8af/3.0/Dockerfile#L82-L92