-
-
Notifications
You must be signed in to change notification settings - Fork 68
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
Reduce size of images #339
base: dev
Are you sure you want to change the base?
Conversation
Very good job @lap1nou ! |
Nice catch ! |
@lap1nou any idea why the files you removed on your PR were still here? |
Greetings, @ShutdownRepo yes I think it's a Docker specificity, while you are indeed removing them, this happens in another layer (because it's another RUN command in the Dockerfile, each command create another layer), but the file are still present in one of the layer so this take space in the final Docker image. References:
I'm not a Docker expert so I might be wrong, altough the size of the image do indeed shrink with these changes. Regards. |
Indeed, Docker store every file of the layer at the end of each RUN commands, so removing them in the last layer is not enough. Thanks @lap1nou for the PR, don't hesitates to submit more if you have time to dive into it ;) |
Instead of merging this PR , I think a refactoring of the function It means that the function post_install should :
It could also be a new dedicated function like |
I agree @gbe, However I have to say that removing |
Hey, Here is some more space we could save:
I need your feedback to know which of these optimisations I can apply to this PR, I already tested them a bit offline and it seems to work fine. My |
I had already suggested in a previous PR to remove the .git folders but @ShutdownRepo wants to keep them so users can pull the latest versions if needed. |
agreed let's do that
Let's do 2 (bundler) and 3 (npm prune)
Yes, imo we need to keep Anyways, thank you @gbe and @lap1nou for sharing your insight and investing your time in this thread!! Reducing the size of the images is important for the project and its users. |
Good I'm going to apply all of this, the bundler thing could be applied in the clean layer function but not the npm one. To answer your question @ShutdownRepo, #!/bin/bash
# Find all .git folders and calculate their sizes
total_size=0
while IFS= read -r -d '' git_folder; do
git_size=$(du -b -s "$git_folder" | awk '{print $1}')
total_size=$(echo $total_size + $git_size | bc)
done < <(find / -type d -name ".git" -print0 2>/dev/null)
# Display the total size in human-readable format
echo "Total size of all .git folders: $total_size" |
Maybe the |
You could also do a shallow clone with |
It's already in the code ! |
Woops, sorry, my bad. |
Description
Greetings,
This PR aims to reduce the size of the image (by around 775 MB) by removing files that aren't used and that take place in the layers of the final image.
Image size before: ~25,34 GB, after: ~24,374 GB, I used
dive
(https://github.com/wagoodman/dive) to know which file was wasting space.I also have other optimisations that could reduce the size of the image, I can create another PR if this one is merged.
Regards.
Related issues
N/A
Point of attention
I only ran
dive
on theweb
image, I will probably use it on thefull
image if you find this PR interesting in order to find more optimizations.