From f0cecfd5175364d4ab1b6e715f0c34539e9387da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bel=C3=A9n=20Albeza?= Date: Mon, 9 Sep 2024 16:51:15 +0200 Subject: [PATCH] :wrench: Install Rust+Cargo in devenv --- docker/devenv/Dockerfile | 23 +++++++++++++++++++++++ docker/devenv/files/bashrc | 3 +++ 2 files changed, 26 insertions(+) diff --git a/docker/devenv/Dockerfile b/docker/devenv/Dockerfile index 7182905a6..042e16d0e 100644 --- a/docker/devenv/Dockerfile +++ b/docker/devenv/Dockerfile @@ -8,6 +8,8 @@ ENV NODE_VERSION=v20.11.1 \ CLJKONDO_VERSION=2024.03.13 \ BABASHKA_VERSION=1.3.189 \ CLJFMT_VERSION=0.12.0 \ + RUSTUP_VERSION=1.27.1 \ + RUST_VERSION=1.81.0 \ LANG=en_US.UTF-8 \ LC_ALL=en_US.UTF-8 @@ -242,6 +244,27 @@ RUN set -ex; \ mv /tmp/mc /usr/local/bin/; \ chmod +x /usr/local/bin/mc; +# Install Rust toolchain +ENV RUSTUP_HOME=/usr/local/rustup \ + CARGO_HOME=/usr/local/cargo \ + PATH=/usr/local/cargo/bin:$PATH; + +RUN set -eux; \ + # Same steps as in Rust official Docker image https://github.com/rust-lang/docker-rust/blob/9f287282d513a84cb7c7f38f197838f15d37b6a9/1.81.0/bookworm/Dockerfile + dpkgArch="$(dpkg --print-architecture)"; \ + case "${dpkgArch##*-}" in \ + amd64) rustArch='x86_64-unknown-linux-gnu'; rustupSha256='6aeece6993e902708983b209d04c0d1dbb14ebb405ddb87def578d41f920f56d' ;; \ + arm64) rustArch='aarch64-unknown-linux-gnu'; rustupSha256='1cffbf51e63e634c746f741de50649bbbcbd9dbe1de363c9ecef64e278dba2b2' ;; \ + *) echo >&2 "unsupported architecture: ${dpkgArch}"; exit 1 ;; \ + esac; \ + url="https://static.rust-lang.org/rustup/archive/${RUSTUP_VERSION}/${rustArch}/rustup-init"; \ + wget "$url"; \ + echo "${rustupSha256} *rustup-init" | sha256sum -c -; \ + chmod +x rustup-init; \ + ./rustup-init -y --no-modify-path --profile minimal --default-toolchain $RUST_VERSION --default-host ${rustArch}; \ + rm rustup-init; \ + chmod -R a+w $RUSTUP_HOME $CARGO_HOME; + WORKDIR /home COPY files/nginx.conf /etc/nginx/nginx.conf diff --git a/docker/devenv/files/bashrc b/docker/devenv/files/bashrc index 745e3f901..dca37aadb 100644 --- a/docker/devenv/files/bashrc +++ b/docker/devenv/files/bashrc @@ -9,6 +9,9 @@ alias ls='ls --color -F' alias lsd='ls -d *(/)' alias lsf='ls -h *(.)' +# init Cargo / Rust env +. "/usr/local/cargo/env" + # include .bashrc if it exists if [ -f "$HOME/.bashrc.local" ]; then . "$HOME/.bashrc.local"