diff --git a/rust-training-esp32c3/Dockerfile b/rust-training-esp32c3/Dockerfile index 28dcb91..f9c0879 100644 --- a/rust-training-esp32c3/Dockerfile +++ b/rust-training-esp32c3/Dockerfile @@ -4,8 +4,8 @@ FROM espressif/rust-std-training USER esp ENV USER=esp -RUN git clone https://github.com/ferrous-systems/espressif-trainings.git espressif-trainings \ - && rm -rf espressif-trainings/book +RUN git clone https://github.com/esp-rs/std-training.git std-training \ + && rm -rf std-training/book ENV IDF_TOOLS_PATH=/home/esp/.espressif RUN echo "source /home/esp/.espressif/frameworks/esp-idf/export.sh > /dev/null 2>&1" >> ~/.bashrc @@ -14,15 +14,21 @@ ENV PATH=${PATH}:/home/esp/.cargo/bin COPY sdkconfig.defaults /home/esp/ COPY cfg.toml /home/esp/ COPY compile.sh /home/esp/ +COPY fetch.sh /home/esp/ RUN mkdir -p /home/esp/build-in /home/esp/build-out +RUN WOKWI_MCU=esp32-c3 ./fetch.sh advanced/button-interrupt +RUN WOKWI_MCU=esp32-c3 ./fetch.sh advanced/i2c-driver +RUN WOKWI_MCU=esp32-c3 ./fetch.sh advanced/i2c-sensor-reading +RUN WOKWI_MCU=esp32-c3 ./fetch.sh intro/hardware-check +RUN WOKWI_MCU=esp32-c3 ./fetch.sh intro/http-client +RUN WOKWI_MCU=esp32-c3 ./fetch.sh intro/http-server +RUN WOKWI_MCU=esp32-c3 ./fetch.sh intro/mqtt/exercise + + ENV HEXI_SRC_DIR="/home/esp/build-in" ENV HEXI_SRC_FILES="*.rs" ENV HEXI_BUILD_CMD="bash /home/esp/compile.sh" ENV HEXI_OUT_HEX="/home/esp/build-out/project.bin" ENV HEXI_OUT_ELF="/home/esp/build-out/project.elf" - -EXPOSE 8080 -COPY --from=wokwi/mini-hexi /wokwi-hexi /wokwi-hexi -CMD /wokwi-hexi diff --git a/rust-training-esp32c3/fetch.sh b/rust-training-esp32c3/fetch.sh new file mode 100755 index 0000000..579cafe --- /dev/null +++ b/rust-training-esp32c3/fetch.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +set -ef + +echo "Compiling $1" + +cd /home/esp/std-training/$1 + +if [ -f cfg.toml.example ]; then + # Rename file to cfg.toml + cp cfg.toml.example cfg.toml + # Replace defaults + sed -i 's/wifi_ssid = "FBI Surveillance Van"/wifi_ssid = "Wokwi-GUEST"/g' cfg.toml + sed -i 's/wifi_psk = "hunter2"/wifi_psk = ""/g' cfg.toml + sed -i 's/mqtt_user = "horse"/mqtt_user = "user"/g' cfg.toml + sed -i 's/mqtt_pass = "CorrectHorseBatteryStaple"/mqtt_pass = "pass"/g' cfg.toml + sed -i 's/mqtt_host = "yourpc.local"/mqtt_host = "host"/g' cfg.toml +fi + +$HOME/.cargo/bin/cargo clean +$HOME/.cargo/bin/cargo build --release