mmh352 / ou-container-builder

0 stars 2 forks source link

Tidy up apt packages #31

Closed psychemedia closed 3 years ago

psychemedia commented 3 years ago

Apt installs can be tidied up and layer size reduced by adding an && apt-get clean && rm -rf /var/lib/apt/lists/* tidy up step.

Unwanted packages can be limited by a --no-install-recommmends switch in an apt-get command.

To impact on layer size, the apt-get clean needs running as part of every apt-get layer, which means that multiple layers need their own apt-get update.

However, just running it once does make for a slightly cleaner filesystem in the final container.

psychemedia commented 3 years ago

The clean may also clobber sources?

mmh352 commented 3 years ago

Clobber sources in what way?

psychemedia commented 3 years ago

Delete the path to them. I just checked, you don't, they go to /etc/apt/sources.list.d/ and the clean up cleans /var/lib/apt/lists/*.

The addition of the lists adds time to each apt-get update though. If you have the iterated Dockerfile builder that builds up from several files, and each apt-get step has its own apt-get update and clean step, and each adds its own sources, the source list could get very long and the apt-get update could take forever on the final step.

Most of the time this won't be an issue. Just noting what could happen, though.

mmh352 commented 3 years ago

Ok. Well, it is the classic memory vs processing time tradeoff.

psychemedia commented 3 years ago

Three options:

The no-recommends is a separate decision which could be set by the user via an optional install-recommends boolean (just need to decide the default) in the config file.

mmh352 commented 3 years ago

The base layer already comes with the necessary settings so that apt doesn't cache anything. Removing the /var/lib/apt/lists/* reduces the size by ~10MB on the big demo, so is really not worth it.