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

Reduce size of docker containers #14214

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

saiarcot895
Copy link
Contributor

Why I did it

How I did it

Remove apt package lists, unify container layer cleanup code, remove unnecessary -dev packages from the sonic-telemetry container

How to verify it

Which release branch to backport (provide reason below if selected)

  • 201811
  • 201911
  • 202006
  • 202012
  • 202106
  • 202111
  • 202205
  • 202211

Description for the changelog

Ensure to add label/tag for the feature raised. example - PR#2174 under sonic-utilities repo. where, Generic Config and Update feature has been labelled as GCU.

Link to config_db schema for YANG module changes

A picture of a cute animal (not mandatory but encouraged)

Remove the apt package lists (`/var/lib/apt/lists`) from the docker
containers. This saves about 100MB.

Also, make a macro to clean up the apt and python cache that can then be
used in all of the containers. This helps make the cleanup be consistent
across all containers.

Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>
libswsscommon-dev is a dev package, and shouldn't be needed at runtime.

Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>
@k-v1
Copy link
Contributor

k-v1 commented Mar 13, 2023

BTW you can find the same cleanup code in src/sonic-build-hooks/scripts/post_run_cleanup.
So I'm not sure this PR will affect size of docker containers.

@saiarcot895
Copy link
Contributor Author

Ah, I was comparing the size of the containers in 202205 (where the PR that added that script is not present) and the current master branch, so that would explain it. I'll modify this PR, since there's some additional changes to be done for some space savings.

@k-v1
Copy link
Contributor

k-v1 commented Mar 13, 2023

For master branch it's something like this:

  • build docker
  • 1st cleanup in Dockerfile
  • collect_version_files in post_run_buildinfo
  • 2nd cleanup in post_run_cleanup

Some time ago I wanted to remove 1st cleanup but this leads to modifying version files. So I decided don't change this.

Copy link

@ankit-gautam23 ankit-gautam23 left a comment

Choose a reason for hiding this comment

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

LGTM

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.

None yet

3 participants