|
| 1 | +# syntax=docker.io/docker/dockerfile:1.19 |
| 2 | +# shellcheck shell=bash |
| 3 | + |
| 4 | +# see https://github.com/rust-lang/rustup/tags/ |
| 5 | +# renovate: datasource=github-releases depName=rust-lang/rustup |
| 6 | +ARG RUSTUP_INIT_VERSION='1.28.2' |
| 7 | + |
| 8 | +# see https://github.com/cargo-bins/cargo-binstall/releases |
| 9 | +# renovate: datasource=github-releases depName=cargo-bins/cargo-binstall |
| 10 | +ARG CARGO_BINSTALL_VERSION='1.15.9' |
| 11 | + |
| 12 | +# see https://github.com/esp-rs/espup/releases/ |
| 13 | +# renovate: datasource=github-releases depName=esp-rs/espup |
| 14 | +ARG ESPUP_VERSION='0.16.0' |
| 15 | + |
| 16 | +# see https://github.com/rust-lang/rust/releases |
| 17 | +# NB to make things simpler. keep this in sync with ESP_RUST_VERSION bellow. |
| 18 | +# renovate: datasource=github-tags depName=rust-lang/rust |
| 19 | +ARG RUST_VERSION='1.90.0' |
| 20 | + |
| 21 | +# see https://github.com/esp-rs/rust-build/releases |
| 22 | +# renovate: datasource=github-releases depName=esp-rs/rust-build |
| 23 | +ARG ESP_RUST_VERSION='1.90.0.0' |
| 24 | + |
| 25 | +# see https://crates.io/crates/espflash |
| 26 | +# see https://github.com/esp-rs/espflash/releases |
| 27 | +# renovate: datasource=github-releases depName=esp-rs/espflash |
| 28 | +ARG ESPFLASH_VERSION='4.2.0' |
| 29 | + |
| 30 | +# see https://crates.io/crates/esp-generate |
| 31 | +# see https://github.com/esp-rs/esp-generate/releases |
| 32 | +# renovate: datasource=github-releases depName=esp-rs/esp-generate |
| 33 | +ARG ESP_GENERATE_VERSION='1.0.0' |
| 34 | + |
| 35 | +# see https://github.com/devcontainers/images/tree/main/src/base-debian/history |
| 36 | +FROM mcr.microsoft.com/devcontainers/base:2.0.2-trixie |
| 37 | + |
| 38 | +RUN <<'EOF' |
| 39 | +#!/usr/bin/bash |
| 40 | +set -euxo pipefail |
| 41 | +export DEBIAN_FRONTEND=noninteractive |
| 42 | +apt-get update |
| 43 | +apt-get -y install --no-install-recommends \ |
| 44 | + bash-completion \ |
| 45 | + curl \ |
| 46 | + sudo \ |
| 47 | + unzip \ |
| 48 | + wget |
| 49 | +apt-get clean |
| 50 | +rm -rf /var/lib/apt/lists/* |
| 51 | +EOF |
| 52 | + |
| 53 | +USER vscode |
| 54 | + |
| 55 | +# install rustup. |
| 56 | +# see https://github.com/rust-lang/rustup/tags. |
| 57 | +# see https://rust-lang.github.io/rustup/installation/other.html#manual-installation |
| 58 | +# see https://github.com/rgl/my-ubuntu-ansible-playbooks/blob/main/roles/rust/files/install-rust.sh |
| 59 | +ARG RUSTUP_INIT_VERSION |
| 60 | +RUN <<'EOF' |
| 61 | +#!/usr/bin/bash |
| 62 | +set -euxo pipefail |
| 63 | +u="https://static.rust-lang.org/rustup/archive/${RUSTUP_INIT_VERSION}/x86_64-unknown-linux-gnu/rustup-init" |
| 64 | +t="$(mktemp -q -d)" |
| 65 | +wget -qO "$t/rustup-init" "$u" |
| 66 | +chmod +x "$t/rustup-init" |
| 67 | +"$t/rustup-init" \ |
| 68 | + -y \ |
| 69 | + --no-update-default-toolchain |
| 70 | +rm -rf "$t" |
| 71 | +EOF |
| 72 | +ENV PATH="$PATH:/home/vscode/.cargo/bin" |
| 73 | + |
| 74 | +# install rust. |
| 75 | +ARG RUST_VERSION |
| 76 | +RUN rustup default "$RUST_VERSION" |
| 77 | + |
| 78 | +# install cargo-binstall. |
| 79 | +# see https://github.com/cargo-bins/cargo-binstall. |
| 80 | +ARG CARGO_BINSTALL_VERSION |
| 81 | +RUN <<'EOF' |
| 82 | +#!/usr/bin/bash |
| 83 | +set -euxo pipefail |
| 84 | +u="https://github.com/cargo-bins/cargo-binstall/releases/download/v${CARGO_BINSTALL_VERSION}/cargo-binstall-x86_64-unknown-linux-gnu.tgz" |
| 85 | +t="$(mktemp -q -d)" |
| 86 | +wget -qO- "$u" | tar xzf - -C "$t" |
| 87 | +install "$t/cargo-binstall" ~/.cargo/bin |
| 88 | +rm -rf "$t" |
| 89 | +EOF |
| 90 | + |
| 91 | +# install espup. |
| 92 | +ARG ESPUP_VERSION |
| 93 | +RUN cargo binstall "espup@$ESPUP_VERSION" |
| 94 | + |
| 95 | +# install esp rust. |
| 96 | +ARG ESP_RUST_VERSION |
| 97 | +RUN <<'EOF' |
| 98 | +#!/usr/bin/bash |
| 99 | +set -euxo pipefail |
| 100 | +espup install \ |
| 101 | + --toolchain-version "$ESP_RUST_VERSION" \ |
| 102 | + --targets esp32 |
| 103 | +echo 'source "$HOME/export-esp.sh"' >>~/.bashrc |
| 104 | +EOF |
| 105 | + |
| 106 | +# install espflash. |
| 107 | +ARG ESPFLASH_VERSION |
| 108 | +RUN cargo binstall "espflash@$ESPFLASH_VERSION" |
| 109 | + |
| 110 | +# install esp-generate. |
| 111 | +ARG ESP_GENERATE_VERSION |
| 112 | +RUN cargo binstall "esp-generate@$ESP_GENERATE_VERSION" |
| 113 | + |
| 114 | +USER root |
| 115 | + |
| 116 | +RUN <<'EOF' |
| 117 | +#!/usr/bin/bash |
| 118 | +set -euxo pipefail |
| 119 | +# ensure /etc/profile is called at the top of the file, when running in a |
| 120 | +# login shell. |
| 121 | +sed -i '0,/esac/s/esac/&\n\nsource \/etc\/profile/' /home/vscode/.bashrc |
| 122 | +EOF |
| 123 | +COPY .devcontainer/inputrc /etc/inputrc |
| 124 | +COPY .devcontainer/login.sh /etc/profile.d/login.sh |
0 commit comments