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

CI: reduce docker image sizes #105176

Merged
merged 1 commit into from
Dec 5, 2022
Merged

CI: reduce docker image sizes #105176

merged 1 commit into from
Dec 5, 2022

Conversation

klensy
Copy link
Contributor

@klensy klensy commented Dec 2, 2022

Reduces docker image sizes by using simple tips like: cleaning packet managers cache, squashing sequential installation steps into one.

For some images this gives ~40mb for apt-based images (not so much), but ~200mb(!) for centos one.

@rustbot
Copy link
Collaborator

rustbot commented Dec 2, 2022

r? @jyn514

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue. labels Dec 2, 2022
RUN apt-get update && \
apt-get install -y apt-transport-https software-properties-common && \
apt-transport-https software-properties-common && \
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This change forwards --no-install-recommends for this packages too.


# Install dependencies for chromium browser
RUN apt-get install -y \
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This change forwards --no-install-recommends for this packages too.

@Mark-Simulacrum
Copy link
Member

Can you say more about what motivates the reduction in size here? It seems clear we can do better, but what use case is this impacting?

In general the complexity of the Dockerfiles matters much more to me than saving a little bit of time on image downloads and such.

@klensy
Copy link
Contributor Author

klensy commented Dec 2, 2022

Motivation is reducing size/traffic (slightly faster download, lower required disk space), given that added complexity of changes is trivial(cleaning apt/yum cache is non intrusive change used by many docker images).

@jyn514
Copy link
Member

jyn514 commented Dec 2, 2022

r? @Mark-Simulacrum

@rustbot rustbot assigned Mark-Simulacrum and unassigned jyn514 Dec 2, 2022
@Mark-Simulacrum
Copy link
Member

I disagree that this is trivial. When we update to a new version of apt/yum, this directory path can change, and the costs of thinking about this if we do it is still constantly there. If it was a global setting somewhere ("give me container optimized defaults"), then this would be relatively speaking more reasonable, but if we have to do it across each of our builders that adds a good bit of overhead to maintaining them.

The savings of a few hundred megabytes at most are sort of nice, but they're also quite small - I don't think they justify having to think about this on every PR. Doing it as a one off isn't worth it either I think.

@klensy
Copy link
Contributor Author

klensy commented Dec 2, 2022

For apt: location /var/lib/apt/lists/ taken from man https://linux.die.net/man/8/apt-get, and looking at random google threads, it was here at least 10+ years, so it quite stable. Plus, this tip can be found at https://docs.docker.com/develop/develop-images/dockerfile_best-practices/

For yum: it's exactly option yum clean all

For pip: it's option too, no manual rm -rf: --no-cache-dir

@Mark-Simulacrum
Copy link
Member

OK. Well, I'm not convinced this is a good idea, but we can let it hit CI and see if anything breaks as a result of trying to be cautious here. It'll bounce at least a few times while we rebuild caches in any case, I suspect.

@bors r+ rollup=never

@bors
Copy link
Contributor

bors commented Dec 5, 2022

📌 Commit eadf69a has been approved by Mark-Simulacrum

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 5, 2022
@bors
Copy link
Contributor

bors commented Dec 5, 2022

⌛ Testing commit eadf69a with merge e1d8195...

@bors
Copy link
Contributor

bors commented Dec 5, 2022

☀️ Test successful - checks-actions
Approved by: Mark-Simulacrum
Pushing e1d8195 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Dec 5, 2022
@bors bors merged commit e1d8195 into rust-lang:master Dec 5, 2022
@rustbot rustbot added this to the 1.67.0 milestone Dec 5, 2022
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (e1d8195): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
3.0% [3.0%, 3.0%] 1
Regressions ❌
(secondary)
2.5% [2.5%, 2.5%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 3.0% [3.0%, 3.0%] 1

Cycles

This benchmark run did not return any relevant results for this metric.

@ComputerDruid
Copy link
Contributor

I noticed this seems to be adding a warning:

[WARNING]: Empty continuation line found in:
    RUN apt-get update && apt-get install -y --no-install-recommends   g++   gcc-multilib   make   ninja-build   file   curl   ca-certificates   python2.7   python3.9   git   cmake   sudo   gdb   llvm-13-tools   llvm-13-dev   libedit-dev   libssl-dev   pkg-config   zlib1g-dev   xz-utils   nodejs     apt-transport-https software-properties-common &&     curl -s "https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb" > packages-microsoft-prod.deb &&     dpkg -i packages-microsoft-prod.deb &&     apt-get update &&     apt-get install -y powershell     && rm -rf /var/lib/apt/lists/*
Warning: : Empty continuation lines will become errors in a future release.

For example in https://github.com/rust-lang/rust/actions/runs/3625431239/jobs/6113472422

@klensy
Copy link
Contributor Author

klensy commented Dec 6, 2022

@ComputerDruid it's about inline comments like here

nodejs \
# Install powershell so we can test x.ps1 on Linux
apt-transport-https software-properties-common && \

Should be fixed long ago moby/moby#35004, but idk why it still here.

@ComputerDruid
Copy link
Contributor

I think it's actually complaining about the empty line above the comment, not the comment itself

Aaron1011 pushed a commit to Aaron1011/rust that referenced this pull request Jan 6, 2023
CI: reduce docker image sizes

Reduces docker image sizes by using simple tips like: cleaning packet managers cache, squashing sequential installation steps into one.

For some images this gives ~40mb for apt-based images (not so much), but ~200mb(!) for centos one.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants