containers icon indicating copy to clipboard operation
containers copied to clipboard

Cleanup after Ubuntu apt and pip installs

Open jgarver opened this issue 8 months ago • 6 comments

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 avatar Apr 24 '25 11:04 jgarver

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

wojiushixiaobai avatar Apr 29 '25 16:04 wojiushixiaobai

I like that. Let me try it. Thanks!

jgarver avatar Apr 29 '25 16:04 jgarver

The Fedora 41 image uses cache mounts.

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

osteffenrh avatar Jun 24 '25 07:06 osteffenrh

@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.

jgarver avatar Jun 24 '25 12:06 jgarver

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

osteffenrh avatar Jun 24 '25 12:06 osteffenrh

@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!

osteffenrh avatar Sep 18 '25 09:09 osteffenrh