diff --git a/Docker/Dockerfile b/Docker/Dockerfile new file mode 100644 index 0000000..7d4b323 --- /dev/null +++ b/Docker/Dockerfile @@ -0,0 +1,48 @@ +FROM eclipse-temurin:11-jdk-jammy AS builder + +RUN set -ex && \ + apt-get update && \ + apt-get install -y git cmake xz-utils python3 python3-serial + +RUN curl -L "https://downloads.arduino.cc/arduino-1.8.19-linux64.tar.xz" -o /tmp/arduino-ide.tar.xz +RUN tar -xf /tmp/arduino-ide.tar.xz --directory ~/ + +RUN cd ~/arduino* && \ + ./install.sh && \ + ./arduino --pref "boardsmanager.additional.urls=https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json" --save-prefs && \ + ./arduino --install-boards esp32:esp32:2.0.9 + +RUN git clone --recurse-submodules https://github.com/technyon/Arduino-CMake-Toolchain.git ~/Arduino-CMake-Toolchain + +COPY icon /usr/src/nuki_hub/icon +COPY include /usr/src/nuki_hub/include +COPY lib /usr/src/nuki_hub/lib +COPY networkDevices /usr/src/nuki_hub/networkDevices +COPY CMakeLists.txt /usr/src/nuki_hub +COPY index.html /usr/src/nuki_hub +COPY *.h /usr/src/nuki_hub +COPY *.cpp /usr/src/nuki_hub + +RUN mkdir -p /usr/src/nuki_hub/build + +RUN cd /usr/src/nuki_hub/build && \ + echo "# Espressif ESP32 Partition Table" > partitions.csv && \ + echo "# Name, Type, SubType, Offset, Size, Flags" >> partitions.csv && \ + echo "nvs, data, nvs, 0x9000, 0x5000," >> partitions.csv && \ + echo "otadata, data, ota, 0xe000, 0x2000," >> partitions.csv && \ + echo "app0, app, ota_0, 0x10000, 0x1E0000," >> partitions.csv && \ + echo "app1, app, ota_1, 0x1F0000,0x1E0000," >> partitions.csv && \ + echo "spiffs, data, spiffs, 0x3D0000,0x30000," >> partitions.csv + +RUN set -ex && \ + cd /usr/src/nuki_hub/build && \ + cmake -D CMAKE_TOOLCHAIN_FILE=~/Arduino-CMake-Toolchain/Arduino-toolchain.cmake .. && \ + make + +FROM builder AS runtime + +COPY --from=builder /usr/src/nuki_hub/build/nuki_hub.bin /usr/src/nuki_hub/build/release/nuki_hub.bin +COPY --from=builder /usr/src/nuki_hub/build/nuki_hub.partitions.bin /usr/src/nuki_hub/build/release/nuki_hub.partitions.bin +COPY --from=builder /root/.arduino15/packages/esp32/hardware/esp32/2.0.9/tools/partitions/boot_app0.bin /usr/src/nuki_hub/build/release/boot_app0.bin + +CMD ["/bin/bash"] \ No newline at end of file diff --git a/Docker/README.md b/Docker/README.md new file mode 100644 index 0000000..17caad5 --- /dev/null +++ b/Docker/README.md @@ -0,0 +1,10 @@ +# Build with Docker + +You can build this project using Docker. Just run the following commands in the console: + +```console +cd Docker +./build_with_docker.sh +``` + +once the script is complete you will find the nuki_nub binary in the `nuki_hub/build/release` folder. diff --git a/Docker/build_with_docker.sh b/Docker/build_with_docker.sh new file mode 100755 index 0000000..8ec1712 --- /dev/null +++ b/Docker/build_with_docker.sh @@ -0,0 +1,6 @@ +set -ex +docker build -f ./Dockerfile -t nuki_hub .. +docker create --name nuki_hub nuki_hub +rm -rf ../build +docker cp nuki_hub:/usr/src/nuki_hub/build/ ../ +docker rm -f nuki_hub