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

Remove apt cache for each layer #286

Closed
wants to merge 4 commits into from

Conversation

robin-reckmann
Copy link
Contributor

Remove cached apt-related files after each build step that includes apt package installations. This reduces the size of the final docker image from 6.61GB to 5.85GB.
Note: It does NOT affect the size of the final system.img

@andiradulescu
Copy link
Collaborator

andiradulescu commented Aug 7, 2024

Wouldn't it be better to not remove /var/lib/apt at all between steps and just delete it in the last Dockerfile.agnos step? This way we can call apt update just once at the beginning e.g. in base_setup.sh.

@robin-reckmann
Copy link
Contributor Author

In the end it's a tradeoff between docker image size and build speed. If you e.g. don't remove these files in the base_setup but only in the end, then they will still stay in the base_setup layer. Separating update and install could also lead to potential caching issues. (see here https://docs.docker.com/build/building/best-practices/ ).

@andiradulescu
Copy link
Collaborator

see here https://docs.docker.com/build/building/best-practices/

Very nice write up!

@robin-reckmann robin-reckmann marked this pull request as ready for review August 7, 2024 14:13
@adeebshihadeh
Copy link
Contributor

It's not clear to me this tradeoff is worth it. Where is the individual layer size a problem?

@robin-reckmann
Copy link
Contributor Author

This is also done in #308 in a better way. Closing.

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