Fat git-core catalog after slim
Expected Behavior
Image smaller than fat
Actual Behavior
cmd=build info=results status='MINIFIED' by='0.77X' size.original='461 MB' size.optimized='599 MB'
Steps to Reproduce the Problem
FROM hashicorp/terraform:latest as terraform
RUN apk --no-cache --update add bash git python3 py-pip docker
RUN pip install --no-cache-dir pre-commit
ENTRYPOINT ["/bin/bash"]
docker-slim build --remove-file-artifacts --preserve-path /usr/libexec/git-core/ --exec "git init" --http-probe=false -target test --tag test-slim
Fat image:
bash-5.1# du -shc /usr/libexec/git-core/
9.4M /usr/libexec/git-core/
9.4M total
Slim image:
bash-5.1# du -shc /usr/libexec/git-core/
386.5M /usr/libexec/git-core/
386.5M total
Why /usr/libexec/git-core/ don't copy dir from fat image?
Run script:
for x in $(stat /usr/libexec/git-core/git* | grep Inode | awk '{print $4}' | sort | uniq); do
find /usr/libexec/git-core/ -inum "$x" -print0 | while IFS= read -r -d '' file; do
if [ -z "$first_file" ]; then
first_file=$file
continue
fi
rm "$file"
ln -s "$first_file" "$file"
done
first_file=''
done
Fixing this issue. It's looks like docker slim have problem to work with hard link files.
Any ideas?
@pawelrosada yes, need to improve hard link handling (it's been on the todo list for a while :-)) will use this report as an opportunity to revisit the problem
Why /usr/libexec/git-core/ don't copy dir from fat image?
Need to double check the --preserve-path flag behavior with directories. --include-new=false might be usedful too if you don't want any new files that get created when the image is executed
Ran into this one as well - ended up with:
status='MINIFIED' by='0.64X' size.original='450 MB' size.optimized='698 MB'
When I got rid of /usr/libexec/git-core/ inclusion, the slim image went back to being smaller than the fat one. The issue occurs both with include-path and with preserve-path on the newest docker-slim version available.