Skip to content

Commit 0442751

Browse files
docker: install cargo-deny as a pinned prebuilt binary (#175)
The dev images built cargo-deny from source via `cargo install cargo-deny`. That compiled cargo-deny on every image build (multi-minute) and surfaced cargo-deny's own `profile.dev.package.{insta,similar}` warnings, which look like our config but are not. Install the pinned (0.19.8), checksum-verified prebuilt binary instead. The static musl build runs on glibc too, so all three images share one asset. Result: no source compile, no spurious warnings, and a reproducible, sha256-verified install (vs the previous unpinned `cargo install`). Each build self-checks with `cargo-deny --version`. Version/checksum are ARGs so they can be bumped (and tracked by Renovate).
1 parent 8e93246 commit 0442751

3 files changed

Lines changed: 37 additions & 4 deletions

File tree

docker/Dockerfile.alpine

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,20 @@ RUN apk add --no-cache \
1919
curl
2020

2121
RUN rustup component add clippy rustfmt \
22-
&& cargo install cargo-deny \
2322
&& curl -LsSf https://get.nexte.st/latest/linux-musl | tar zxf - -C /usr/local/cargo/bin
2423

24+
# cargo-deny: pinned, checksum-verified prebuilt binary. The static musl build
25+
# runs on glibc too, so every image shares one asset. Installing the binary
26+
# (instead of `cargo install cargo-deny`) skips a multi-minute source compile.
27+
ARG CARGO_DENY_VERSION=0.19.8
28+
ARG CARGO_DENY_SHA256=70e769ae3872e34d45132b17040859175e11401dc12dddb0303e0b8c7d088f3f
29+
RUN curl -LsSf "https://github.com/EmbarkStudios/cargo-deny/releases/download/${CARGO_DENY_VERSION}/cargo-deny-${CARGO_DENY_VERSION}-x86_64-unknown-linux-musl.tar.gz" -o /tmp/cargo-deny.tar.gz \
30+
&& echo "${CARGO_DENY_SHA256} /tmp/cargo-deny.tar.gz" | sha256sum -c - \
31+
&& tar zxf /tmp/cargo-deny.tar.gz -C /tmp \
32+
&& install -m 0755 "/tmp/cargo-deny-${CARGO_DENY_VERSION}-x86_64-unknown-linux-musl/cargo-deny" /usr/local/cargo/bin/cargo-deny \
33+
&& rm -rf /tmp/cargo-deny.tar.gz "/tmp/cargo-deny-${CARGO_DENY_VERSION}-x86_64-unknown-linux-musl" \
34+
&& cargo-deny --version
35+
2536
RUN adduser -D -s /bin/bash testuser \
2637
&& adduser -D -s /bin/sh testuser2 \
2738
&& addgroup testgroup \

docker/Dockerfile.debian

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,20 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
1616
&& rm -rf /var/lib/apt/lists/*
1717

1818
RUN rustup component add clippy rustfmt \
19-
&& cargo install cargo-deny \
2019
&& curl -LsSf https://get.nexte.st/latest/linux | tar zxf - -C /usr/local/cargo/bin
2120

21+
# cargo-deny: pinned, checksum-verified prebuilt binary. The static musl build
22+
# runs on glibc too, so every image shares one asset. Installing the binary
23+
# (instead of `cargo install cargo-deny`) skips a multi-minute source compile.
24+
ARG CARGO_DENY_VERSION=0.19.8
25+
ARG CARGO_DENY_SHA256=70e769ae3872e34d45132b17040859175e11401dc12dddb0303e0b8c7d088f3f
26+
RUN curl -LsSf "https://github.com/EmbarkStudios/cargo-deny/releases/download/${CARGO_DENY_VERSION}/cargo-deny-${CARGO_DENY_VERSION}-x86_64-unknown-linux-musl.tar.gz" -o /tmp/cargo-deny.tar.gz \
27+
&& echo "${CARGO_DENY_SHA256} /tmp/cargo-deny.tar.gz" | sha256sum -c - \
28+
&& tar zxf /tmp/cargo-deny.tar.gz -C /tmp \
29+
&& install -m 0755 "/tmp/cargo-deny-${CARGO_DENY_VERSION}-x86_64-unknown-linux-musl/cargo-deny" /usr/local/cargo/bin/cargo-deny \
30+
&& rm -rf /tmp/cargo-deny.tar.gz "/tmp/cargo-deny-${CARGO_DENY_VERSION}-x86_64-unknown-linux-musl" \
31+
&& cargo-deny --version
32+
2233
RUN useradd -m -s /bin/bash testuser \
2334
&& useradd -m -s /bin/sh testuser2 \
2435
&& groupadd testgroup \

docker/Dockerfile.fedora

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,19 @@ RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \
2424
--component clippy,rustfmt
2525
ENV PATH="/root/.cargo/bin:${PATH}"
2626

27-
RUN cargo install cargo-deny \
28-
&& curl -LsSf https://get.nexte.st/latest/linux | tar zxf - -C /root/.cargo/bin
27+
RUN curl -LsSf https://get.nexte.st/latest/linux | tar zxf - -C /root/.cargo/bin
28+
29+
# cargo-deny: pinned, checksum-verified prebuilt binary. The static musl build
30+
# runs on glibc too, so every image shares one asset. Installing the binary
31+
# (instead of `cargo install cargo-deny`) skips a multi-minute source compile.
32+
ARG CARGO_DENY_VERSION=0.19.8
33+
ARG CARGO_DENY_SHA256=70e769ae3872e34d45132b17040859175e11401dc12dddb0303e0b8c7d088f3f
34+
RUN curl -LsSf "https://github.com/EmbarkStudios/cargo-deny/releases/download/${CARGO_DENY_VERSION}/cargo-deny-${CARGO_DENY_VERSION}-x86_64-unknown-linux-musl.tar.gz" -o /tmp/cargo-deny.tar.gz \
35+
&& echo "${CARGO_DENY_SHA256} /tmp/cargo-deny.tar.gz" | sha256sum -c - \
36+
&& tar zxf /tmp/cargo-deny.tar.gz -C /tmp \
37+
&& install -m 0755 "/tmp/cargo-deny-${CARGO_DENY_VERSION}-x86_64-unknown-linux-musl/cargo-deny" /root/.cargo/bin/cargo-deny \
38+
&& rm -rf /tmp/cargo-deny.tar.gz "/tmp/cargo-deny-${CARGO_DENY_VERSION}-x86_64-unknown-linux-musl" \
39+
&& cargo-deny --version
2940

3041
RUN useradd -m -s /bin/bash testuser \
3142
&& useradd -m -s /bin/sh testuser2 \

0 commit comments

Comments
 (0)