Skip to content

Reduce package weight #107

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

Merged
merged 1 commit into from
May 14, 2025
Merged

Conversation

baude
Copy link
Member

@baude baude commented Mar 26, 2025

Reduce number of unnecessary packages in our image through the use of installing without weak dependencies for subscription-manager and qemu-user-static.

Remove man pages as the man binary is not present anyways.

Removed several weak RPM dependencies and reduced qemu-user-static arches to x86 and aarch64

@baude
Copy link
Member Author

baude commented Mar 26, 2025

@vrothberg @cgwalters mind trying the images assuming they get posted here and make sure we're still good for bootc use cases

@dustymabe wdyt ?

@mohanboddu
Copy link

LGTM

# Install ansible for post-install configuration
RUN rpm-ostree install subscription-manager gvisor-tap-vsock-gvforwarder qemu-user-static ansible-core && \
# Remove unwanted packages
# Remove man pages (man binary is not present)
Copy link
Member

Choose a reason for hiding this comment

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

The remove comments would be easier for me to brain-parse above line 63. Can we move it down?

@vrothberg
Copy link
Member

@vrothberg @cgwalters mind trying the images assuming they get posted here and make sure we're still good for bootc use cases

Sure, I can run some smoke tests. The changes should be fine.

Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

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

This doesn't seem to work, the resulting images are larger
about 60 MB on x86_64 and 100 MB on aarch64

@dustymabe
Copy link

@dustymabe wdyt ?

Seems reasonable

@baude baude changed the title [WIP]Reduce package weight Reduce package weight Apr 24, 2025
@baude
Copy link
Member Author

baude commented Apr 24, 2025

@Luap99 i would like to move forward with this if you don't object. I realize there is no space savings yet. I think that can come in a secondary step.

@cgwalters
Copy link

https://docs.fedoraproject.org/en-US/bootc/building-custom-base/ is an important reference here if you want to actually remove content from the base image. See especially https://docs.fedoraproject.org/en-US/bootc/building-custom-base/#_optimizing_container_images

@baude
Copy link
Member Author

baude commented Apr 24, 2025

https://docs.fedoraproject.org/en-US/bootc/building-custom-base/ is an important reference here if you want to actually remove content from the base image. See especially https://docs.fedoraproject.org/en-US/bootc/building-custom-base/#_optimizing_container_images

Are you specifically speaking about the rechunking?

@Luap99
Copy link
Member

Luap99 commented Apr 24, 2025

Well there is a difference between there is no size benefit and we are adding 50MB+ to the images with that, so how can that be?
It just strikes me as totally odd that a motivation of reducing the image size is resulting in increasing the image size now. So what do we actually gain by merging this then?

@baude
Copy link
Member Author

baude commented Apr 24, 2025

Because my theory is once we get the second step in, it will be smaller. but we can just live with it today and not do any of this stuff.

@Luap99
Copy link
Member

Luap99 commented Apr 24, 2025

Because my theory is once we get the second step in, it will be smaller. but we can just live with it today and not do any of this stuff.

And the second step is what? And why would this need to be merged before said second step is ready?
I don't mind doing this change general but I do mind doing changes that say they do X when they happen to do the opposite instead. There is no explanation as of why this is needed if it doesn’t reduce the size? It is not like this is a big change were breaking it down in several small PRs would help reviewing.

Also not directly related but this is switching to using dnf and there is also not explanation why dnf is used in the commit or comments either. For proper history it is always useful to know why something was changed.

@baude
Copy link
Member Author

baude commented Apr 25, 2025

well the commit message does say reduce the number of packages not reduce the size firstly. If they don't need to be there, then why install them?

The second step is the rechunking of the images which should allow for us to see a reduction in overall image size. I'm not going to debate with you anymore.

@baude baude changed the title Reduce package weight DNM: Reduce package weight Apr 25, 2025
Reduce number of unnecessary packages in our image through the use of
installing without weak dependencies for subscription-manager and
qemu-user-static.

Remove man pages as the man binary is not present anyways.

Signed-off-by: Brent Baude <bbaude@redhat.com>
@baude baude changed the title DNM: Reduce package weight Reduce package weight Apr 30, 2025
@baude
Copy link
Member Author

baude commented Apr 30, 2025

ok, with the rechunk PR merged, I think we have something viable for merge now.

Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

openshift-ci bot commented Apr 30, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: baude, Luap99

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@cgwalters
Copy link

ok, with the rechunk PR merged, I think we have something viable for merge now.

The rechunking worked well for you? What did you think?

@baude
Copy link
Member Author

baude commented Apr 30, 2025

The rechunking worked well for you? What did you think?

We had a nice savings on the OCI image for sure. That was excellent. The savings on the disk image is somehow minimal which I don't fully understand.

# Remove man pages (man binary is not present)
RUN dnf install -y --setopt=install_weak_deps=false \
subscription-manager device-mapper qemu-user-static-aarch64 qemu-user-static-x86 && \
dnf install -y gvisor-tap-vsock-gvforwarder ansible-core && \

Choose a reason for hiding this comment

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

Curious about the ansible-core install, is there a motivation for that?

BTW, a pattern I recommend here (until dnf gains some declarative interface or we do https://gitlab.com/fedora/bootc/osbuild-cfg or equivalent) is the "dnf | xargs" trick like

$ cat packages.txt
# Needed to configure RHEL
subscription-manager
# Because we want to...
ansible-core

Then in your dockerfile RUN grep -vEe '^#' packages.txt | xargs dnf -y install.

This allows one to have a super lightweight format with comments so the comments can say why the package is installed etc.

Copy link
Member

Choose a reason for hiding this comment

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

Curious about the ansible-core install, is there a motivation for that?

containers/podman#25043

As for chaining the format I agree we should do that do have a clear comment why each package is needed but I guess we can consider this out of scope for this change.

@Luap99
Copy link
Member

Luap99 commented May 14, 2025

/lgtm

@openshift-ci openshift-ci bot added the lgtm label May 14, 2025
@openshift-merge-bot openshift-merge-bot bot merged commit 6c363d4 into containers:main May 14, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants