Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use multi-stage build #230

Open
taliesins opened this issue May 15, 2024 · 1 comment
Open

Use multi-stage build #230

taliesins opened this issue May 15, 2024 · 1 comment

Comments

@taliesins
Copy link

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
Copy link
Member

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:

haproxy/3.0/Dockerfile

Lines 82 to 92 in 8db4f30

apt-mark auto '.*' > /dev/null; \
[ -z "$savedAptMark" ] || apt-mark manual $savedAptMark; \
find /usr/local -type f -executable -exec ldd '{}' ';' \
| awk '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1) { next }; gsub("^/(usr/)?", "", so); printf "*%s\n", so }' \
| sort -u \
| xargs -r dpkg-query --search \
| cut -d: -f1 \
| sort -u \
| xargs -r apt-mark manual \
; \
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants