Skip to content
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

dnf clean after dnf install in Dockerfiles #948

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

PeterDaveHello
Copy link
Contributor

This ensures that dnf doesn't leave unnecessary temporary files in the Docker images, thereby reducing their size.

Regarding the change in image size, it seems there isn't much difference for the rawhide and f39 builds. However, the f38 and el8 builds have shown significant improvement.

For the image size changes, see the result below.

Before:

REPOSITORY                                   TAG                  IMAGE ID       CREATED             SIZE
dockerfile.rawhide                           latest               2df081b6ec73   About an hour ago   519MB
dockerfile.f39                               latest               1d39a1d366ac   About an hour ago   519MB
dockerfile.f37                               latest               f86a5711c973   About an hour ago   832MB
dockerfile.el8                               latest               7ac668a725be   About an hour ago   571MB

After:

REPOSITORY                                   TAG                  IMAGE ID       CREATED             SIZE
dockerfile.rawhide-dnf-clean                 latest               e035b545c15b   About an hour ago   519MB
dockerfile.f39-dnf-clean                     latest               c35b262f3830   About an hour ago   519MB
dockerfile.f37-dnf-clean                     latest               15e78792159d   About an hour ago   441MB
dockerfile.el8-dnf-clean                     latest               59fa63bde3fe   About an hour ago   405MB

@codecov-commenter
Copy link

Codecov Report

Patch has no changes to coverable lines.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

📢 Thoughts on this report? Let us know!.

@caronc
Copy link
Owner

caronc commented Sep 10, 2023

Thanks for these changes. It's worth noting that there are test build environments only (for unit tests). So there isn't a huge gain from your great finds.

Shrink this docker container and we've got more of a rewarding outcome

@@ -48,13 +48,15 @@ RUN ( \
dnf install -y rpm-build rpmlint python3-pip python3-virtualenv rubygem-ronn \
dnf-plugins-core 'dnf-command(config-manager)' \
'dnf-command(builddep)' sudo rsync rpmdevtools; \
dnf config-manager --set-enabled powertools;
dnf config-manager --set-enabled powertools; \
dnf clean all;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This clean all is not needed, it slows down the second dnf install below

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be! Depends on the network environment and the upstream server being used.

The better way may be to merge those installs, so that the process will be fast, and the image will be slow?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants