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

Clean more files after dnf installing #844

Merged
merged 1 commit into from
Jul 8, 2022

Conversation

Fryguy
Copy link
Member

@Fryguy Fryguy commented Jul 8, 2022

This change reduces the UI worker image size from 2.063GB to 2.018GB
(44MB, 2.1%)

  • Add the removal of dnf logs, dnf history, and rpm __db lock files.
    This eliminates roughly 2-6MB per invocation.
  • Move the cleaning of dnf and rpm assets into a script, which makes it
    easier to use across layers and images.
  • Remove redundant rebuild of the rpm manifests, since ther are
    unnecessary unless rpm changes are made.
  • Collapse the modifications of the httpd package into the same layer as
    when it's installed.

Part of #736

EDIT: I forgot to mention this also has significant time savings as well. Locally, the rpm manifest generation steps can take ~100s (1m40s) x 5 images = ~500s (8m20s). After this PR, there are only 2 calls, so that's 200s (3m20s) for a savings of ~5min per build

@Fryguy Fryguy requested a review from bdunne as a code owner July 8, 2022 18:57
@@ -7,6 +7,7 @@ COPY container-assets/ /vddk/

RUN /vddk/extract-vmware-vddk

################################################################################
Copy link
Member Author

Choose a reason for hiding this comment

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

This makes it easier to see various multi-stage builds - I can remove from this PR if you want, but I figured it was fine.

@@ -35,6 +37,7 @@ RUN chmod -R g+w /etc/pki/ca-trust && \

COPY rpms/* /tmp/rpms/
COPY container-assets/create_local_yum_repo.sh /
COPY container-assets/clean_dnf_rpm /usr/local/bin/
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm open to renaming this script.

Copy link
Member

Choose a reason for hiding this comment

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

Naming is hard 😄

dnf clean all && \
rm -rf /var/cache/dnf

RUN rm -rf /tmp/rpms /create_local_yum_repo.sh /etc/yum.repos.d/local_rpm.repo
Copy link
Member Author

Choose a reason for hiding this comment

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

I wasn't sure why this was done here. Removing these doesn't change anything with respect to the file size, and one can get at them from one of the parent images.

Copy link
Member

Choose a reason for hiding this comment

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

🤷🏻‍♂️

Copy link
Member

Choose a reason for hiding this comment

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

I think we used to install something here, but it was moved up in the layers.

rm -rf /var/cache/dnf
clean_dnf_rpm

# Build the RPM manifest
Copy link
Member

Choose a reason for hiding this comment

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

I thought we were keeping this as close as possible to the end in case any other steps were added with dnf commands

Copy link
Member Author

Choose a reason for hiding this comment

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

I was actually considering moving the dumb-init and ADD calls up the file. If you're ok with that for this PR I can do that, and then this is at the "end" of the file again.

Copy link
Member Author

Choose a reason for hiding this comment

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

Even so, the only calls afterwards are an ADD, and the curl of dumb-init, so this is technically at the "end" of any dnf commands

Copy link
Member

Choose a reason for hiding this comment

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

I'm fine with moving them up, they're only used at runtime, not build time so the order doesn't matter.

Copy link
Member

Choose a reason for hiding this comment

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

Not for this PR, but dumb-init is up to v1.2.5 now, so we should probably update. Also, should we rely on pulling it from Github at every build or do you think we should keep a copy somewhere else (package it in an RPM)?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh yes I saw that - will have a follow-up PR

Copy link
Member Author

Choose a reason for hiding this comment

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

@bdunne Updated. I moved up both commands

chgrp root /var/log/httpd && \
chmod g+rwx /var/log/httpd

# Build the RPM manifest
Copy link
Member

Choose a reason for hiding this comment

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

Any reason to merge the other RUN steps but not this one?

Copy link
Member Author

@Fryguy Fryguy Jul 8, 2022

Choose a reason for hiding this comment

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

It doesn't save any space to merge the manifest one, though admittedly it would drop the need to duplicate the clean_dnf_rpm call. I'd like to leave it for now.

@@ -0,0 +1,11 @@
#!/bin/bash
Copy link
Member

Choose a reason for hiding this comment

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

Not for this PR, but I wonder if we should put this script in one of our RPMs and run it on the appliance to reduce image size there too

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh that's an interesting idea - agreed that we can do that in a follow up

This change reduces the UI worker image size from 2.063GB to 2.018GB
(44MB, 2.1%)

- Add the removal of dnf logs, dnf history, and rpm __db lock files.
  This eliminates roughly 2-6MB per invocation.
- Move the cleaning of dnf and rpm assets into a script, which makes it
  easier to use across layers and images.
- Remove redundant rebuild of the rpm manifests, since ther are
  unnecessary unless rpm changes are made.
- Collapse the modifications of the httpd package into the same layer as
  when it's installed.

Part of ManageIQ#736
@miq-bot
Copy link
Member

miq-bot commented Jul 8, 2022

Checked commit Fryguy@8d98b60 with ruby 2.6.9, rubocop 1.19.1, haml-lint 0.35.0, and yamllint
0 files checked, 0 offenses detected
Everything looks fine. 🍰

@Fryguy
Copy link
Member Author

Fryguy commented Jul 8, 2022

I forgot to mention this also has significant time savings as well. Locally, the rpm manifest generation steps can take ~100s (1m40s) x 5 images = ~500s (8m20s). After this PR, there are only 2 calls, so that's 200s (3m20s) for a savings of ~5min per build

Updated the OP with this information.

@bdunne bdunne merged commit 48ea480 into ManageIQ:master Jul 8, 2022
@Fryguy Fryguy deleted the smaller_images branch July 8, 2022 21:47
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.

3 participants