Created
September 12, 2025 15:22
-
-
Save LarsFronius/ecb221a022bdea5ec8676daabdfd76e9 to your computer and use it in GitHub Desktop.
Dockerfile for esp-mbedtls project
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FROM ubuntu:24.04 | |
| # Set environment variables | |
| ENV DEBIAN_FRONTEND=noninteractive | |
| ENV CARGO_TERM_COLOR=always | |
| ENV CARGO_INCREMENTAL=0 | |
| ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse | |
| ENV ESPUP_EXPORT_FILE=/root/exports | |
| # Install system dependencies | |
| RUN apt-get update && apt-get install -y \ | |
| curl \ | |
| git \ | |
| build-essential \ | |
| cmake \ | |
| python3 \ | |
| python3-pip \ | |
| pkg-config \ | |
| libssl-dev \ | |
| unzip \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Set up working directory | |
| WORKDIR /workspace | |
| # Install Rust with rustup | |
| RUN curl --proto '=https' --tlsv1.2 --retry 10 --retry-connrefused \ | |
| --location --silent --show-error --fail https://sh.rustup.rs | \ | |
| sh -s -- --default-toolchain none -y | |
| # Add Cargo to PATH | |
| ENV PATH="/root/.cargo/bin:$PATH" | |
| ENV CARGO_HOME="/root/.cargo" | |
| # Install stable Rust toolchain with required components | |
| RUN rustup toolchain install stable \ | |
| --target $(uname -m)-unknown-linux-gnu \ | |
| --component rust-src \ | |
| --component rustfmt \ | |
| --profile minimal \ | |
| --no-self-update | |
| # Set stable as default | |
| RUN rustup default stable | |
| # Install nightly Rust toolchain for ESP32 targets | |
| RUN rustup toolchain install nightly \ | |
| --target riscv32imc-unknown-none-elf \ | |
| --component rust-src \ | |
| --component rustfmt \ | |
| --profile minimal \ | |
| --allow-downgrade \ | |
| --no-self-update | |
| # Download and install ldproxy | |
| RUN curl -LO https://github.com/esp-rs/embuild/releases/latest/download/ldproxy-$(uname -m)-unknown-linux-gnu.zip && \ | |
| unzip -o ldproxy-$(uname -m)-unknown-linux-gnu.zip -d "$CARGO_HOME/bin" && \ | |
| chmod +x "$CARGO_HOME/bin/ldproxy"* && \ | |
| rm ldproxy-$(uname -m)-unknown-linux-gnu.zip | |
| # Download and install espup | |
| RUN curl -LO https://github.com/esp-rs/espup/releases/latest/download/espup-$(uname -m)-unknown-linux-gnu.zip && \ | |
| unzip -o espup-$(uname -m)-unknown-linux-gnu.zip -d "$CARGO_HOME/bin" && \ | |
| chmod +x "$CARGO_HOME/bin/espup"* && \ | |
| rm espup-$(uname -m)-unknown-linux-gnu.zip | |
| # Install ESP toolchain using espup | |
| RUN bash -c 'source "$CARGO_HOME/env" && espup install -l debug --targets all -e' | |
| # Set environment variables for ESP toolchain | |
| ENV LIBCLANG_PATH="/root/.rustup/toolchains/esp/xtensa-esp32-elf-clang/esp-19.1.2_20250225/esp-clang/lib" | |
| ENV CLANG_PATH="/root/.rustup/toolchains/esp/xtensa-esp32-elf-clang/esp-19.1.2_20250225/esp-clang/bin/clang" | |
| ENV HOST_TARGET="$(uname -m)-unknown-linux-gnu" | |
| # Set nightly as default for ESP development | |
| RUN rustup default nightly | |
| # Create a script to source ESP environment variables | |
| RUN echo '#!/bin/bash' > /usr/local/bin/source-esp-env && \ | |
| echo 'source /root/exports 2>/dev/null || true' >> /usr/local/bin/source-esp-env && \ | |
| echo 'exec "$@"' >> /usr/local/bin/source-esp-env && \ | |
| chmod +x /usr/local/bin/source-esp-env | |
| WORKDIR "/workspace" | |
| # Set the entrypoint to source ESP environment | |
| ENTRYPOINT ["/usr/local/bin/source-esp-env"] | |
| # Default command | |
| CMD ["/bin/bash"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment