mintoolkit / mint

minT(oolkit): Mint awesome, secure and production ready containers just the way you need them! Don't change anything in your container image and minify it by up to 30x (and for compiled languages even more) making it secure too! (free and open source)
https://github.com/mintoolkit/mint
Apache License 2.0
184 stars 10 forks source link

Minifying an "ffmpeg" container - (from Discord) #42

Open kcq opened 4 months ago

kcq commented 4 months ago

User Report in Discord (Kevin)

Attempting to build a ffmpeg container. Original is 672M, when I attempt to slim it without adding in the necessary includes, the container shrinks down to ~125M, however, it doesnt contain the necessary includes so it does not work. I have come up with the following: slim build --include-path /usr/local/bin --include-path /usr/local/etc --include-path /usr/local/lib --include-path /usr/local/share/vulkan --include-path /usr/share/fonts --include-path /usr/share/libdrm --include-path /etc/OpenCL/vendors --include-bin /usr/bin/stat --include-bin /usr/sbin/groupadd --include-bin /usr/sbin/groupmod --include-bin /usr/sbin/usermod --include-bin /usr/bin/find --include-bin /usr/bin/grep --include-bin /usr/bin/id --include-bin /usr/bin/cut --include-bin /usr/bin/getent --include-bin /usr/bin/echo --include-bin /usr/bin/chmod --continue-after 1 --http-probe-off --tag kp/ffmpeg:slim --target kp/ffmpeg:latest which includes everything needed for it to work, and it does indeed work.

However, the container grows to 997M instead of shrinking.

What am I doing wrong? the include paths and files total around the difference between the 2 containers...

kp-emagine commented 4 months ago

Appreciate the reply :)

# the primary command
CMD [ "--help" ]

# our entrypoint
ENTRYPOINT [ "/myffmpeg" ]

I figured I'd need to include those binaries as they are in use with the /myffmpeg script. Here is the public container: https://hub.docker.com/r/kevinpirnie/ffmpeg

and just in case, I attached a zip of the "project" as well :)

ffmpeg.zip

kp-emagine commented 4 months ago

Tried slimming, by using this command: slim build --include-new false --include-path /usr/local/bin --include-path /usr/local/etc --include-path /usr/local/lib --include-path /usr/local/share/vulkan --include-path /usr/share/fonts --include-path /usr/share/libdrm --include-path /etc/OpenCL/vendors --include-bin /usr/bin/stat --include-bin /usr/sbin/groupadd --include-bin /usr/sbin/groupmod --include-bin /usr/sbin/usermod --include-bin /usr/bin/find --include-bin /usr/bin/grep --include-bin /usr/bin/id --include-bin /usr/bin/cut --include-bin /usr/bin/getent --include-bin /usr/bin/echo --include-bin /usr/bin/chmod --continue-after 1 --http-probe-off --tag kp/ffmpeg:slim --target kp/ffmpeg:latest, and same. "Slim'd" container ends up being ~900M

I am going to try using the Dockerfile instead of the --target and see what happens.

kp-emagine commented 4 months ago

Tried it by letting slim build the images based on the Dockerfile with:

slim build --include-new=false --include-path /usr/local/bin --include-path /usr/local/etc --include-path /usr/local/lib --include-path /usr/local/share/vulkan --include-path /usr/share/fonts --include-path /usr/share/libdrm --include-path /etc/OpenCL/vendors --include-bin /usr/bin/stat --include-bin /usr/sbin/groupadd --include-bin /usr/sbin/groupmod --include-bin /usr/sbin/usermod --include-bin /usr/bin/find --include-bin /usr/bin/grep --include-bin /usr/bin/id --include-bin /usr/bin/cut --include-bin /usr/bin/getent --include-bin /usr/bin/echo --include-bin /usr/bin/chmod --continue-after 1 --http-probe-off --tag kp/ffmpeg:slim --dockerfile Dockerfile .

Results are: Screenshot_1