Skip to content

Commit

Permalink
Auto merge of rust-lang#105176 - klensy:docker-smol, r=Mark-Simulacrum
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bors committed Dec 5, 2022
2 parents 203c876 + eadf69a commit e1d8195
Show file tree
Hide file tree
Showing 19 changed files with 43 additions and 27 deletions.
3 changes: 2 additions & 1 deletion src/ci/docker/host-aarch64/aarch64-gnu/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-ins
gdb \
libssl-dev \
pkg-config \
xz-utils
xz-utils \
&& rm -rf /var/lib/apt/lists/*

COPY scripts/sccache.sh /scripts/
RUN sh /scripts/sccache.sh
Expand Down
3 changes: 2 additions & 1 deletion src/ci/docker/host-x86_64/dist-i686-linux/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ RUN yum upgrade -y && \
wget \
xz \
zlib-devel.i686 \
zlib-devel.x86_64
zlib-devel.x86_64 \
&& yum clean all

RUN mkdir -p /rustroot/bin && ln -s /usr/bin/cmake3 /rustroot/bin/cmake

Expand Down
3 changes: 2 additions & 1 deletion src/ci/docker/host-x86_64/dist-x86_64-freebsd/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
xz-utils \
wget \
libssl-dev \
pkg-config
pkg-config \
&& rm -rf /var/lib/apt/lists/*

COPY scripts/freebsd-toolchain.sh /tmp/
RUN /tmp/freebsd-toolchain.sh x86_64
Expand Down
3 changes: 2 additions & 1 deletion src/ci/docker/host-x86_64/dist-x86_64-illumos/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ RUN apt-get update && \
apt-get install -y --no-install-recommends \
libgmp-dev \
libmpfr-dev \
libmpc-dev
libmpc-dev \
&& rm -rf /var/lib/apt/lists/*

COPY scripts/illumos-toolchain.sh /tmp/

Expand Down
3 changes: 2 additions & 1 deletion src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ RUN yum upgrade -y && \
wget \
xz \
zlib-devel.i686 \
zlib-devel.x86_64
zlib-devel.x86_64 \
&& yum clean all

RUN mkdir -p /rustroot/bin && ln -s /usr/bin/cmake3 /rustroot/bin/cmake

Expand Down
3 changes: 2 additions & 1 deletion src/ci/docker/host-x86_64/dist-x86_64-musl/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-ins
gdb \
patch \
libssl-dev \
pkg-config
pkg-config \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /build/

Expand Down
3 changes: 2 additions & 1 deletion src/ci/docker/host-x86_64/i686-gnu-nopt/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
gdb \
zlib1g-dev \
lib32z1-dev \
xz-utils
xz-utils \
&& rm -rf /var/lib/apt/lists/*


COPY scripts/sccache.sh /scripts/
Expand Down
3 changes: 2 additions & 1 deletion src/ci/docker/host-x86_64/i686-gnu/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
gdb \
zlib1g-dev \
lib32z1-dev \
xz-utils
xz-utils \
&& rm -rf /var/lib/apt/lists/*


COPY scripts/sccache.sh /scripts/
Expand Down
8 changes: 4 additions & 4 deletions src/ci/docker/host-x86_64/mingw-check/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
xz-utils \
libssl-dev \
pkg-config \
mingw-w64
mingw-w64 \
&& rm -rf /var/lib/apt/lists/*

RUN curl -sL https://nodejs.org/dist/v16.9.0/node-v16.9.0-linux-x64.tar.xz | tar -xJ
ENV PATH="/node-v16.9.0-linux-x64/bin:${PATH}"
# Install es-check
# Pin its version to prevent unrelated CI failures due to future es-check versions.
RUN npm install [email protected] -g
RUN npm install [email protected] -g
RUN npm install [email protected] [email protected] -g

COPY scripts/sccache.sh /scripts/
RUN sh /scripts/sccache.sh

COPY host-x86_64/mingw-check/reuse-requirements.txt /tmp/
RUN pip3 install --no-deps --require-hashes -r /tmp/reuse-requirements.txt
RUN pip3 install --no-deps --no-cache-dir --require-hashes -r /tmp/reuse-requirements.txt

COPY host-x86_64/mingw-check/validate-toolstate.sh /scripts/
COPY host-x86_64/mingw-check/validate-error-codes.sh /scripts/
Expand Down
3 changes: 2 additions & 1 deletion src/ci/docker/host-x86_64/test-various/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-ins
ovmf \
qemu-efi-aarch64 \
qemu-system-arm \
qemu-system-x86
qemu-system-x86 \
&& rm -rf /var/lib/apt/lists/*

RUN curl -sL https://nodejs.org/dist/v15.14.0/node-v15.14.0-linux-x64.tar.xz | \
tar -xJ
Expand Down
3 changes: 2 additions & 1 deletion src/ci/docker/host-x86_64/wasm32/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-ins
sudo \
gdb \
xz-utils \
bzip2
bzip2 \
&& rm -rf /var/lib/apt/lists/*

COPY scripts/emscripten.sh /scripts/
RUN bash /scripts/emscripten.sh
Expand Down
3 changes: 2 additions & 1 deletion src/ci/docker/host-x86_64/x86_64-gnu-aux/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
llvm-dev \
libfreetype6-dev \
libexpat1-dev \
tidy
tidy \
&& rm -rf /var/lib/apt/lists/*

COPY scripts/sccache.sh /scripts/
RUN sh /scripts/sccache.sh
Expand Down
3 changes: 2 additions & 1 deletion src/ci/docker/host-x86_64/x86_64-gnu-debug/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
pkg-config \
xz-utils \
lld \
clang
clang \
&& rm -rf /var/lib/apt/lists/*

COPY scripts/sccache.sh /scripts/
RUN sh /scripts/sccache.sh
Expand Down
3 changes: 2 additions & 1 deletion src/ci/docker/host-x86_64/x86_64-gnu-distcheck/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
gdb \
xz-utils \
libssl-dev \
pkg-config
pkg-config \
&& rm -rf /var/lib/apt/lists/*

COPY scripts/sccache.sh /scripts/
RUN sh /scripts/sccache.sh
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
pkg-config \
zlib1g-dev \
xz-utils \
nodejs
nodejs \
&& rm -rf /var/lib/apt/lists/*

COPY scripts/sccache.sh /scripts/
RUN sh /scripts/sccache.sh
Expand Down
8 changes: 4 additions & 4 deletions src/ci/docker/host-x86_64/x86_64-gnu-llvm-13/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
pkg-config \
zlib1g-dev \
xz-utils \
nodejs
nodejs \

# Install powershell so we can test x.ps1 on Linux
RUN apt-get update && \
apt-get install -y apt-transport-https software-properties-common && \
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
apt-get install -y powershell \
&& rm -rf /var/lib/apt/lists/*

COPY scripts/sccache.sh /scripts/
RUN sh /scripts/sccache.sh
Expand Down
3 changes: 2 additions & 1 deletion src/ci/docker/host-x86_64/x86_64-gnu-nopt/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-ins
gdb \
libssl-dev \
pkg-config \
xz-utils
xz-utils \
&& rm -rf /var/lib/apt/lists/*

COPY scripts/sccache.sh /scripts/
RUN sh /scripts/sccache.sh
Expand Down
6 changes: 3 additions & 3 deletions src/ci/docker/host-x86_64/x86_64-gnu-tools/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
libssl-dev \
sudo \
xz-utils \
tidy
tidy \

# Install dependencies for chromium browser
RUN apt-get install -y \
gconf-service \
libasound2 \
libatk1.0-0 \
Expand Down Expand Up @@ -56,7 +55,8 @@ RUN apt-get install -y \
libnss3 \
lsb-release \
xdg-utils \
wget
wget \
&& rm -rf /var/lib/apt/lists/*

COPY scripts/sccache.sh /scripts/
RUN sh /scripts/sccache.sh
Expand Down
3 changes: 2 additions & 1 deletion src/ci/docker/host-x86_64/x86_64-gnu/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
gdb \
libssl-dev \
pkg-config \
xz-utils
xz-utils \
&& rm -rf /var/lib/apt/lists/*

COPY scripts/sccache.sh /scripts/
RUN sh /scripts/sccache.sh
Expand Down

0 comments on commit e1d8195

Please sign in to comment.