How to exclude a specific binary file from optimization process?
Hello,
How to exclude a specific binary file from optimization process? For example I just want to keep some binary file with path /usr/sbin/run or something like this🤔
Thanks, Best regards
@ammnt You have a few options. There's a number of --include-* flags you can use.
To make sure you keep a given binary you can use the --include-bin flag where you'd specify the full path to that binary (example: mint slim --target yourappimage:latest --include-bin=/usr/bin/jq). You can use the --include-exe flag if your binary can be found in the PATH environment variable, so you don't have to specify the full path to the app binary (example: mint slim --target yourappimage:latest --include-exe=jq).
The generic --include-path flag can be used to keep a specific file or directory in the output container image. Note that you can't do --include-path=/ to include everything :-)
Alternatively you can run a so called probe that exercises your binary in a call. You can do it with the --exec flag (here's an example that does it for curl: mint slim --target archlinux:latest --http-probe=false --exec "curl checkip.amazonaws.com).
@kcq, thanks a lot for your answer👍
@kcq, I'm sorry, but I still can't preserve netcat binary and healthcheck therefore:
Slim results:
Dive report:
As you see - netcat binary is gone and HEALTHCHECK directive isn't working anymore. What I have to do to fix this?
I have added this parameters and looks like it works fine now:
--preserve-path /usr/bin/nc --include-path /usr/bin/nc --preserve-path /usr/lib/libmd.so.0 --include-path /usr/lib/libmd.so.0 --preserve-path /usr/lib/libbsd.so.0 --include-path /usr/lib/libbsd.so.0
@ammnt Let me try to repro it with Netcat to see what's going on.