slimtoolkit / slim

Slim(toolkit): 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)
Apache License 2.0
18.98k stars 707 forks source link

About choosing the right option'(--include-path/--preserve-path) #527

Closed rlia closed 1 year ago

rlia commented 1 year ago

I use Slim for machine learning images. Currently, I am out to create a working image using --preserve-path.

I would like to know the clear difference between --include-path and --preserve-path for a more appropriate use of slim. (Also, why is there more than one --include-**?)

I often have problems with this, especially around libraries such as Shared Objects. I would like to see what options are available to make dynamic detection work more appropriately. (I am using strace to check for missing files.)

I am currently reading the source code, but if you have any tips I would be happy to hear them.

Thank you. https://github.com/slimtoolkit/slim/discussions/240

rlia commented 1 year ago

Thank you for your support comment !! https://github.com/slimtoolkit/slim/discussions/240#discussioncomment-6113568

You have helped me understand the options.

I was confused because sometimes I could not fully detect dependencies, for example when using opencv with python. I will be able to further investigate based on the information you provided.

kcq commented 1 year ago

let me know how it goes and what dependencies give you the most headache. might be interesting to research what's going on there to simplify the process and the user experience there

kcq commented 1 year ago

Just to add a bit more context for others stumbling on this issue in the future... The --include-bin and --include-exe flags are more useful when you need to ensure you keep the target binary file in your minified image and all of its dynamic dependencies. The basic --include-path flag doesn't do that (it only includes the target file you point at). If the target file is a shared library or an executable it's likely it dynamically loads other library (e.g., libc, which most binaries/shared objects depend on). --include-bin allows you to point only at your target and then Slim will also auto-include any dynamic dependencies in the target.