Skip to content

Commit d0ac5dd

Browse files
authored
Reduce image size (#76)
* Reduce image size * Fix run.sh `+nightly` is actually not compatible with a pinned version of nightly. But since our way of installing rust set the pinned nightly toolchain as default anyway, we don't need it anymore. * try debian ? * Try debian-slim
1 parent d74d3a5 commit d0ac5dd

File tree

2 files changed

+56
-4
lines changed

2 files changed

+56
-4
lines changed

Dockerfile

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# always build this using the latest stable release
2-
FROM rust:1.70.0 as build
2+
FROM rust:1.71.0 as build
33

44

55
ARG JQ_VERSION=1.6
@@ -34,8 +34,60 @@ COPY local-registry/* ./
3434
RUN ${wd}/bin/generate-registry.sh
3535

3636
# As of Dec 2019, we need to use the nightly toolchain to get JSON test output
37-
FROM rust:1.70.0 AS test
38-
RUN rustup toolchain add nightly
37+
# tracking issue: https://github.com/rust-lang/rust/issues/49359
38+
39+
# Official docker images with pinned nightly versions are not provided, but we
40+
# want to pin the nightly version to avoid unnecessary cache misses. To achieve
41+
# this, we copy the source of the official rust docker images and replace the
42+
# version tag with a nightly one, pinned to a specific date.
43+
44+
# official Dockerfile source:
45+
# https://github.com/rust-lang/docker-rust/blob/master/1.71.0/bookworm/slim/Dockerfile
46+
47+
################ start-copy-pasta ################
48+
49+
FROM debian:bookworm-slim
50+
51+
ENV RUSTUP_HOME=/usr/local/rustup \
52+
CARGO_HOME=/usr/local/cargo \
53+
PATH=/usr/local/cargo/bin:$PATH \
54+
RUST_VERSION=nightly-2023-07-18
55+
# ~~~~~~~~^~~~~~~~~~
56+
# pin version here
57+
58+
RUN set -eux; \
59+
apt-get update; \
60+
apt-get install -y --no-install-recommends \
61+
ca-certificates \
62+
gcc \
63+
libc6-dev \
64+
wget \
65+
; \
66+
dpkgArch="$(dpkg --print-architecture)"; \
67+
case "${dpkgArch##*-}" in \
68+
amd64) rustArch='x86_64-unknown-linux-gnu'; rustupSha256='0b2f6c8f85a3d02fde2efc0ced4657869d73fccfce59defb4e8d29233116e6db' ;; \
69+
armhf) rustArch='armv7-unknown-linux-gnueabihf'; rustupSha256='f21c44b01678c645d8fbba1e55e4180a01ac5af2d38bcbd14aa665e0d96ed69a' ;; \
70+
arm64) rustArch='aarch64-unknown-linux-gnu'; rustupSha256='673e336c81c65e6b16dcdede33f4cc9ed0f08bde1dbe7a935f113605292dc800' ;; \
71+
i386) rustArch='i686-unknown-linux-gnu'; rustupSha256='e7b0f47557c1afcd86939b118cbcf7fb95a5d1d917bdd355157b63ca00fc4333' ;; \
72+
*) echo >&2 "unsupported architecture: ${dpkgArch}"; exit 1 ;; \
73+
esac; \
74+
url="https://static.rust-lang.org/rustup/archive/1.26.0/${rustArch}/rustup-init"; \
75+
wget "$url"; \
76+
echo "${rustupSha256} *rustup-init" | sha256sum -c -; \
77+
chmod +x rustup-init; \
78+
./rustup-init -y --no-modify-path --profile minimal --default-toolchain $RUST_VERSION --default-host ${rustArch}; \
79+
rm rustup-init; \
80+
chmod -R a+w $RUSTUP_HOME $CARGO_HOME; \
81+
rustup --version; \
82+
cargo --version; \
83+
rustc --version; \
84+
apt-get remove -y --auto-remove \
85+
wget \
86+
; \
87+
rm -rf /var/lib/apt/lists/*;
88+
89+
################ end-copy-pasta ################
90+
3991
ENV wd /opt/test-runner
4092
RUN mkdir -p ${wd}/bin
4193
WORKDIR ${wd}

bin/run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ if jq --exit-status '.custom?."test-in-release-mode"?' "$solution_path"/.meta/co
3939
release="--release"
4040
fi
4141

42-
timeout -v 15s cargo +nightly test \
42+
timeout -v 15s cargo test \
4343
--offline \
4444
$release \
4545
-- \

0 commit comments

Comments
 (0)