From 43e76b44c2d6a5a84b66e456aaaa92913b613672 Mon Sep 17 00:00:00 2001 From: Leandro Lisboa Penz Date: Mon, 24 Jan 2022 19:30:06 -0300 Subject: [PATCH] Dockerfile: build docker image "from scratch" instad of "from rust" RUSTC_BOOTSTRAP=1 doesn't work so well anymore in stable, so we had to migrate to nightly - which required us to install the toolchain in an image that already has one. If we install rust manually in a debian-slim, we save ~500MB. We are also pinning nightly to a version where coverage works. Ref: https://github.com/rust-lang/rust/issues/93054 --- Dockerfile | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7294b4e..a8b3d20 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,8 +2,33 @@ # This file is subject to the terms and conditions defined in # file 'LICENSE', which is part of this source code package. -FROM rust:slim -RUN set -e -x; \ +# Adapted from https://github.com/rust-lang/docker-rust/blob/master/Dockerfile-slim.template + +FROM debian:bullseye-slim + +ENV RUSTUP_HOME=/usr/local/rustup \ + CARGO_HOME=/usr/local/cargo \ + PATH=/usr/local/cargo/bin:$PATH + +RUN set -eux; \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + ca-certificates \ + gcc \ + libc6-dev \ + wget \ + ; \ + wget https://sh.rustup.rs -O rustup-init; \ + bash rustup-init -y --no-modify-path --profile minimal --default-toolchain nightly-2022-01-14; \ + rm rustup-init; \ + chmod -R a+w $RUSTUP_HOME $CARGO_HOME; \ + rustup --version; \ + cargo --version; \ + rustc --version; \ + apt-get remove -y --auto-remove \ + wget \ + ; \ + rm -rf /var/lib/apt/lists/*; \ rustup component add llvm-tools-preview; \ cargo install cargo-llvm-cov