Skip to content

Commit

Permalink
Merge pull request #290 from lucaoliano/docker
Browse files Browse the repository at this point in the history
add docker build script
  • Loading branch information
technyon authored Feb 6, 2024
2 parents de117f5 + 6c079d1 commit ba0fa55
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 0 deletions.
48 changes: 48 additions & 0 deletions Docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
10 changes: 10 additions & 0 deletions Docker/README.md
Original file line number Diff line number Diff line change
@@ -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.
6 changes: 6 additions & 0 deletions Docker/build_with_docker.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit ba0fa55

Please sign in to comment.