|
| 1 | +ARG VARIANT=bookworm-slim |
| 2 | +FROM debian:${VARIANT} |
| 3 | +ENV DEBIAN_FRONTEND=noninteractive |
| 4 | +ENV LC_ALL=C.UTF-8 |
| 5 | +ENV LANG=C.UTF-8 |
| 6 | + |
| 7 | +# Arguments |
| 8 | +ARG CONTAINER_USER=esp |
| 9 | +ARG CONTAINER_GROUP=esp |
| 10 | +ARG PROJECT_DIR |
| 11 | +ARG ESP_BOARD=all |
| 12 | +ARG GITHUB_TOKEN |
| 13 | + |
| 14 | +# Install dependencies |
| 15 | +RUN apt-get update \ |
| 16 | + && apt-get install -y pkg-config curl gcc clang libudev-dev unzip xz-utils \ |
| 17 | + git wget flex bison gperf python3 python3-pip python3-venv cmake ninja-build ccache libffi-dev libssl-dev dfu-util libusb-1.0-0 \ |
| 18 | + && apt-get clean -y && rm -rf /var/lib/apt/lists/* /tmp/library-scripts |
| 19 | + |
| 20 | +# Set users |
| 21 | +RUN adduser --disabled-password --gecos "" ${CONTAINER_USER} |
| 22 | +USER ${CONTAINER_USER} |
| 23 | +WORKDIR /home/${CONTAINER_USER} |
| 24 | +RUN mkdir -p ${PROJECT_DIR}/target ${PROJECT_DIR}/.embuild |
| 25 | + |
| 26 | +# Install rustup |
| 27 | +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- \ |
| 28 | + --default-toolchain none -y --profile minimal |
| 29 | + |
| 30 | +# Update envs |
| 31 | +ENV PATH=${PATH}:/home/${CONTAINER_USER}/.cargo/bin |
| 32 | + |
| 33 | +# Install extra crates |
| 34 | +RUN ARCH=$($HOME/.cargo/bin/rustup show | grep "Default host" | sed -e 's/.* //') && \ |
| 35 | + curl -L "https://github.com/esp-rs/espup/releases/latest/download/espup-${ARCH}" -o "${HOME}/.cargo/bin/espup" && \ |
| 36 | + chmod u+x "${HOME}/.cargo/bin/espup" && \ |
| 37 | + curl -L "https://github.com/esp-rs/espflash/releases/latest/download/cargo-espflash-${ARCH}.zip" -o "${HOME}/.cargo/bin/cargo-espflash.zip" && \ |
| 38 | + unzip "${HOME}/.cargo/bin/cargo-espflash.zip" -d "${HOME}/.cargo/bin/" && \ |
| 39 | + rm "${HOME}/.cargo/bin/cargo-espflash.zip" && \ |
| 40 | + chmod u+x "${HOME}/.cargo/bin/cargo-espflash" && \ |
| 41 | + curl -L "https://github.com/esp-rs/espflash/releases/latest/download/espflash-${ARCH}.zip" -o "${HOME}/.cargo/bin/espflash.zip" && \ |
| 42 | + unzip "${HOME}/.cargo/bin/espflash.zip" -d "${HOME}/.cargo/bin/" && \ |
| 43 | + rm "${HOME}/.cargo/bin/espflash.zip" && \ |
| 44 | + chmod u+x "${HOME}/.cargo/bin/espflash" && \ |
| 45 | + curl -L "https://github.com/esp-rs/embuild/releases/latest/download/ldproxy-${ARCH}.zip" -o "${HOME}/.cargo/bin/ldproxy.zip" && \ |
| 46 | + unzip "${HOME}/.cargo/bin/ldproxy.zip" -d "${HOME}/.cargo/bin/" && \ |
| 47 | + rm "${HOME}/.cargo/bin/ldproxy.zip" && \ |
| 48 | + chmod u+x "${HOME}/.cargo/bin/ldproxy" && \ |
| 49 | + curl -L "https://github.com/esp-rs/esp-web-flash-server/releases/latest/download/web-flash-${ARCH}.zip" -o "${HOME}/.cargo/bin/web-flash.zip" && \ |
| 50 | + unzip "${HOME}/.cargo/bin/web-flash.zip" -d "${HOME}/.cargo/bin/" && \ |
| 51 | + rm "${HOME}/.cargo/bin/web-flash.zip" && \ |
| 52 | + chmod u+x "${HOME}/.cargo/bin/web-flash" |
| 53 | + |
| 54 | +# Install Xtensa Rust |
| 55 | +RUN if [ -n "${GITHUB_TOKEN}" ]; then export GITHUB_TOKEN=${GITHUB_TOKEN}; fi \ |
| 56 | + && ${HOME}/.cargo/bin/espup install\ |
| 57 | + --targets "${ESP_BOARD}" \ |
| 58 | + --log-level debug \ |
| 59 | + --export-file /home/${CONTAINER_USER}/export-esp.sh |
| 60 | + |
| 61 | +# Set default toolchain |
| 62 | +RUN rustup default esp |
| 63 | + |
| 64 | +# Activate ESP environment |
| 65 | +RUN echo "source /home/${CONTAINER_USER}/export-esp.sh" >> ~/.bashrc |
| 66 | + |
| 67 | +CMD [ "/bin/bash" ] |
0 commit comments