Skip to content

Cleanup after Ubuntu apt and pip installs#111

Open
jgarver wants to merge 1 commit intotianocore:mainfrom
jgarver:dev/jake/cleanup-after-apt
Open

Cleanup after Ubuntu apt and pip installs#111
jgarver wants to merge 1 commit intotianocore:mainfrom
jgarver:dev/jake/cleanup-after-apt

Conversation

@jgarver
Copy link
Copy Markdown
Contributor

@jgarver jgarver commented Apr 24, 2025

Description

For each apt install, we should update, install and clean all in the same RUN. This avoids carrying around apt temporary files in intermediate layers.

Also, during pip installs, do not cache temporary files.

Containers Affected

Ubuntu-22
Ubuntu-24

@jgarver jgarver force-pushed the dev/jake/cleanup-after-apt branch 2 times, most recently from 1de527d to e07604f Compare April 24, 2025 12:00
For each apt install, we should update, install and clean all in the
same RUN.  This avoids carrying around apt temporary files in
intermediate layers.

Also, during pip installs, do not cache temporary files.

This change reduced the Ubuntu-22 image size by approximately 0.5GB.
@jgarver jgarver force-pushed the dev/jake/cleanup-after-apt branch from e07604f to e4e036f Compare April 24, 2025 12:59
@jgarver jgarver marked this pull request as ready for review April 24, 2025 13:55
@wojiushixiaobai
Copy link
Copy Markdown
Contributor

Maybe Use cache mounts.

RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
  --mount=type=cache,target=/var/lib/apt,sharing=locked \
  apt update && apt-get --no-install-recommends install -y gcc
RUN --mount=type=cache,target=/root/.cache/pip \
    pip install -r requirements.txt

@jgarver
Copy link
Copy Markdown
Contributor Author

jgarver commented Apr 29, 2025

I like that. Let me try it. Thanks!

@osteffenrh
Copy link
Copy Markdown
Contributor

The Fedora 41 image uses cache mounts.

Any intention to update this PR or can it be closed?

@jgarver
Copy link
Copy Markdown
Contributor Author

jgarver commented Jun 24, 2025

@osteffenrh I plan to update it, but it's not a priority right now. I need to migrate us to Ubuntu24, so I'll definitely be revisiting this. My guess is it'll be in the August time frame. If you want to close it, I'll re-open it when I get back to it.

@osteffenrh
Copy link
Copy Markdown
Contributor

@jgarver, no rush. Let's leave this open then. Thanks!

@wojiushixiaobai wojiushixiaobai mentioned this pull request Jun 29, 2025
@osteffenrh
Copy link
Copy Markdown
Contributor

@jgarver, I just merged #115 which adds cahce mounts to the apt cache directories.
Can you check how that overlaps with this PR and if needed update it or close?
Thanks!

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.

3 participants