Skip to content

[github] remove more caches after downloading things #133129

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

Conversation

gburgessiv
Copy link
Member

This is generally good practice if the caches won't be reused (though arguably pedantic for the stage1-toolchain stage).

docker history on comparable images showed that this saves a few hundred MB on stage1, and ~60MB on the apt-get layer of ci-container-agent.

This is generally good practice if the caches won't be reused (though
arguably pedantic for the `stage1-toolchain` stage).

`docker history` on comparable images showed that this saves a few
hundred MB on stage1, and ~60MB on the `apt-get` layer of
`ci-container-agent`.
@llvmbot
Copy link
Member

llvmbot commented Mar 26, 2025

@llvm/pr-subscribers-github-workflow

Author: George Burgess IV (gburgessiv)

Changes

This is generally good practice if the caches won't be reused (though arguably pedantic for the stage1-toolchain stage).

docker history on comparable images showed that this saves a few hundred MB on stage1, and ~60MB on the apt-get layer of ci-container-agent.


Full diff: https://github.com/llvm/llvm-project/pull/133129.diff

1 Files Affected:

  • (modified) .github/workflows/containers/github-action-ci/Dockerfile (+9-3)
diff --git a/.github/workflows/containers/github-action-ci/Dockerfile b/.github/workflows/containers/github-action-ci/Dockerfile
index bd3720017b7f7..11e020ad6ebef 100644
--- a/.github/workflows/containers/github-action-ci/Dockerfile
+++ b/.github/workflows/containers/github-action-ci/Dockerfile
@@ -14,9 +14,13 @@ RUN apt-get update && \
     python3 \
     git \
     curl \
-    zlib1g-dev
+    zlib1g-dev && \
+    apt-get clean && \
+    rm -rf /var/lib/apt/lists/*
 
-RUN curl -O -L https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-$LLVM_VERSION.tar.gz && tar -xf llvmorg-$LLVM_VERSION.tar.gz
+RUN curl -O -L https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-$LLVM_VERSION.tar.gz && \
+  tar -xf llvmorg-$LLVM_VERSION.tar.gz && \
+  rm -f llvmorg-$LLVM_VERSION.tar.gz
 
 WORKDIR /llvm-project-llvmorg-$LLVM_VERSION
 
@@ -65,7 +69,9 @@ RUN apt-get update && \
     python3-pip \
     ccache \
     file \
-    tzdata
+    tzdata && \
+    apt-get clean && \
+    rm -rf /var/lib/apt/lists/*
 
 # Install sccache as it is needed by most of the project test workflows and
 # cannot be installed by the ccache action when executing as a non-root user.

Copy link
Contributor

@boomanaiden154 boomanaiden154 left a comment

Choose a reason for hiding this comment

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

Seems reasonable enough to me.

I believe there are some workflows that use this container and run apt-get inside of it. Theoretically they should be also running apt-get update just in case the containers get too out of date. I'll need to double check.

Copy link
Contributor

@boomanaiden154 boomanaiden154 left a comment

Choose a reason for hiding this comment

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

LGTM. None of the other workflows run apt-get, so this should be good to go.

A 60MB savings on the agent image is pretty nice.

@gburgessiv
Copy link
Member Author

Nice - thanks for the review!

@gburgessiv gburgessiv merged commit 78d7dd2 into llvm:main Mar 26, 2025
14 checks passed
@gburgessiv gburgessiv deleted the github-remove-apt-caches-after-updating-linux-ci-container branch May 2, 2025 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants