Skip to content

Commit 6240872

Browse files
committed
Clean caches
1 parent ef0adcd commit 6240872

File tree

3 files changed

+30
-21
lines changed

3 files changed

+30
-21
lines changed

docker/debian/Dockerfile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ ln -fs /usr/share/zoneinfo/America/Los_Angeles /etc/localtime
2626
apt update
2727
apt upgrade -y
2828
apt install -y tzdata
29+
apt clean
30+
rm -rf /var/lib/apt/lists/*
2931
dpkg-reconfigure --frontend noninteractive tzdata
3032
EOF
3133

@@ -50,6 +52,8 @@ pkgs+=(pipx) # Package manager for Python applications.
5052
pkgs+=(wget) # Required build tool.
5153
apt update
5254
apt install -y --no-install-recommends "${pkgs[@]}"
55+
apt clean
56+
rm -rf /var/lib/apt/lists/*
5357
EOF
5458

5559
# Install Python-based tools.
@@ -95,9 +99,6 @@ EOF
9599
ENV CC=/usr/bin/gcc
96100
ENV CXX=/usr/bin/g++
97101

98-
# Clean up unnecessary files to reduce image size.
99-
RUN rm -rf /var/lib/apt/lists/* && apt clean
100-
101102
# Switch to the non-root user.
102103
USER ${NONROOT_USER}
103104
WORKDIR /home/${NONROOT_USER}
@@ -132,13 +133,12 @@ printf "%s\n%s\n" \
132133
| tee /etc/apt/sources.list.d/llvm.list
133134
apt update
134135
apt install -t llvm-toolchain-${DEBIAN_VERSION}-${CLANG_VERSION} -y --no-install-recommends clang-${CLANG_VERSION} llvm-${CLANG_VERSION}
136+
apt clean
137+
rm -rf /var/lib/apt/lists/*
135138
EOF
136139
ENV CC=/usr/bin/clang-${CLANG_VERSION}
137140
ENV CXX=/usr/bin/clang++-${CLANG_VERSION}
138141

139-
# Clean up unnecessary files to reduce image size.
140-
RUN rm -rf /var/lib/apt/lists/* && apt clean
141-
142142
# Switch to the non-root user.
143143
USER ${NONROOT_USER}
144144
WORKDIR /home/${NONROOT_USER}

docker/rhel/Dockerfile

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ COPY --from=rocky /usr/bin/flex /usr/bin/flex
4343
# Install Python-based tools.
4444
ARG CONAN_VERSION
4545
ARG GCOVR_VERSION
46-
RUN pip install conan==${CONAN_VERSION} && \
47-
pip install gcovr==${GCOVR_VERSION}
46+
RUN pip install --no-cache conan==${CONAN_VERSION} gcovr==${GCOVR_VERSION}
4847

4948
# Create the user to switch to, once all packages have been installed.
5049
ARG NONROOT_USER
@@ -55,13 +54,14 @@ FROM base AS gcc
5554

5655
# Install GCC.
5756
ARG GCC_VERSION
58-
RUN dnf install -y --setopt=tsflags=nodocs gcc-toolset-${GCC_VERSION}-gcc gcc-toolset-${GCC_VERSION}-gcc-c++
57+
RUN <<EOF
58+
dnf install -y --setopt=tsflags=nodocs gcc-toolset-${GCC_VERSION}-gcc gcc-toolset-${GCC_VERSION}-gcc-c++
59+
dnf -y clean all
60+
rm -rf /var/cache/dnf/*
61+
EOF
5962
ENV CC=/usr/bin/gcc
6063
ENV CXX=/usr/bin/g++
6164

62-
# Clean up unnecessary files to reduce image size.
63-
RUN dnf -y clean all
64-
6565
# Switch to the non-root user.
6666
USER ${NONROOT_USER}
6767
WORKDIR /home/${NONROOT_USER}
@@ -89,13 +89,14 @@ FROM base AS clang
8989

9090
# Install Clang. Note that in the RHEL UBIs, we cannot choose the Clang version
9191
# to install and we get what is available.
92-
RUN dnf install -y --setopt=tsflags=nodocs clang llvm
92+
RUN <<EOF
93+
dnf install -y --setopt=tsflags=nodocs clang llvm
94+
dnf -y clean all
95+
rm -rf /var/cache/dnf/*
96+
EOF
9397
ENV CC=/usr/bin/clang
9498
ENV CXX=/usr/bin/clang++
9599

96-
# Clean up unnecessary files to reduce image size.
97-
RUN dnf -y clean all
98-
99100
# Switch to the non-root user.
100101
USER ${NONROOT_USER}
101102
WORKDIR /home/${NONROOT_USER}

docker/ubuntu/Dockerfile

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ ln -fs /usr/share/zoneinfo/America/Los_Angeles /etc/localtime
1515
apt update
1616
apt upgrade -y
1717
apt install -y tzdata
18+
rm -rf /var/lib/apt/lists/* && apt clean
1819
dpkg-reconfigure --frontend noninteractive tzdata
1920
EOF
2021

@@ -39,6 +40,8 @@ pkgs+=(pipx) # Package manager for Python applications.
3940
pkgs+=(wget) # Required build tool.
4041
apt update
4142
apt install -y --no-install-recommends "${pkgs[@]}"
43+
apt clean
44+
rm -rf /var/lib/apt/lists/*
4245
EOF
4346

4447
# Install Python-based tools.
@@ -59,7 +62,11 @@ FROM base AS gcc
5962

6063
# Install GCC.
6164
ARG GCC_VERSION
62-
RUN apt install -y gcc-${GCC_VERSION} g++-${GCC_VERSION}
65+
RUN <<EOF
66+
apt install -y gcc-${GCC_VERSION} g++-${GCC_VERSION}
67+
apt clean
68+
rm -rf /var/lib/apt/lists/*
69+
EOF
6370
ENV CC=/usr/bin/gcc-${GCC_VERSION}
6471
ENV CXX=/usr/bin/g++-${GCC_VERSION}
6572

@@ -89,13 +96,14 @@ FROM base AS clang
8996

9097
# Install Clang.
9198
ARG CLANG_VERSION
92-
RUN apt install -y clang-${CLANG_VERSION} llvm-${CLANG_VERSION}
99+
RUN <<EOF
100+
apt install -y clang-${CLANG_VERSION} llvm-${CLANG_VERSION}
101+
apt clean
102+
rm -rf /var/lib/apt/lists/*
103+
EOF
93104
ENV CC=/usr/bin/clang-${CLANG_VERSION}
94105
ENV CXX=/usr/bin/clang++-${CLANG_VERSION}
95106

96-
# Clean up unnecessary files to reduce image size.
97-
RUN rm -rf /var/lib/apt/lists/* && apt clean
98-
99107
# Switch to the non-root user.
100108
USER ${NONROOT_USER}
101109
WORKDIR /home/${NONROOT_USER}

0 commit comments

Comments
 (0)