1+ FROM python:3.13-bookworm AS base
2+
3+ ENV PIP_ROOT_USER_ACTION=ignore
4+
5+ # Apt dependencies
6+ RUN apt-get update && apt-get install -y \
7+ jq jdupes build-essential \
8+ libgpiod-dev libyaml-cpp-dev libbluetooth-dev libusb-1.0-0-dev libi2c-dev libuv1-dev \
9+ libx11-dev libinput-dev libxkbcommon-x11-dev \
10+ openssl libssl-dev libulfius-dev liborcania-dev \
11+ git git-lfs gettext cmake mtools floppyd dosfstools ninja-build \
12+ parted zip \
13+ && rm -rf /var/lib/apt/lists/*
14+
15+ FROM base AS repo
16+ ARG BUILD_REPO="https://github.com/fobe-projects/micropython.git"
17+ ARG BUILD_REF="main"
18+
19+ WORKDIR /workspace
20+
21+ RUN git config --global --add safe.directory /workspace \
22+ && git config --global protocol.file.allow always \
23+ && git clone --depth 1 --filter=tree:0 "${BUILD_REPO}" /workspace \
24+ && cd /workspace && git checkout "${BUILD_REF}" \
25+ && git repack -d
26+
27+ RUN pip3 install --upgrade pip setuptools wheel build huffman poetry
28+
29+ FROM repo AS port
30+
31+ ARG ARM_TOOLCHAIN_EABI_VERSION="14.2.rel1"
32+ ARG ARM_TOOLCHAIN_ELF_VERSION="13.3.rel1"
33+ ARG BUILD_PLATFORM
34+
35+ RUN if [ "${BUILD_PLATFORM}" != "esp32" ] && [ "${BUILD_PLATFORM}" != "zephyr" ] && [ "${BUILD_PLATFORM}" != "none" ]; then \
36+ ARCH=$(dpkg --print-architecture) && \
37+ if [ "$ARCH" = "arm64" ]; then \
38+ TOOLCHAIN_URL="https://developer.arm.com/-/media/Files/downloads/gnu/$ARM_TOOLCHAIN_EABI_VERSION/binrel/arm-gnu-toolchain-$ARM_TOOLCHAIN_EABI_VERSION-aarch64-arm-none-eabi.tar.xz" ; \
39+ elif [ "$ARCH" = "amd64" ]; then \
40+ TOOLCHAIN_URL="https://developer.arm.com/-/media/Files/downloads/gnu/$ARM_TOOLCHAIN_EABI_VERSION/binrel/arm-gnu-toolchain-$ARM_TOOLCHAIN_EABI_VERSION-x86_64-arm-none-eabi.tar.xz" ; \
41+ else \
42+ echo "Unsupported architecture: $ARCH" ; \
43+ exit 1; \
44+ fi && \
45+ mkdir -p /usr/local/arm-none-eabi && \
46+ curl -fsSL "$TOOLCHAIN_URL" | tar -xJ -C /usr/local/arm-none-eabi --strip-components=1 && \
47+ for f in /usr/local/arm-none-eabi/bin/arm-none-eabi-*; do \
48+ ln -sf "$f" /usr/local/bin/$(basename "$f" ); \
49+ done \
50+ fi
51+
52+ # Nordic
53+ RUN if [ "${BUILD_PLATFORM}" = "nrf" ]; then \
54+ ARCH=$(dpkg --print-architecture) && \
55+ if [ "$ARCH" = "arm64" ]; then \
56+ TOOLCHAIN_URL="https://files.nordicsemi.com/artifactory/swtools/external/nrfutil/executables/aarch64-unknown-linux-gnu/nrfutil" ; \
57+ elif [ "$ARCH" = "amd64" ]; then \
58+ TOOLCHAIN_URL="https://files.nordicsemi.com/artifactory/swtools/external/nrfutil/executables/x86_64-unknown-linux-gnu/nrfutil" ; \
59+ else \
60+ echo "Unsupported architecture: $ARCH" ; \
61+ exit 1; \
62+ fi && curl -fsSL "$TOOLCHAIN_URL" -o nrfutil;\
63+ chmod +x nrfutil; \
64+ ./nrfutil install nrf5sdk-tools; \
65+ mv nrfutil /usr/local/bin; \
66+ nrfutil -V; \
67+ make -C ports/nrf submodules; \
68+ cd /workspace/ports/nrf && ./drivers/bluetooth/download_ble_stack.sh; \
69+ cd /workspace; \
70+ fi
71+
72+ # Espressif IDF
73+ ENV IDF_PATH=/opt/esp-idf
74+ ENV IDF_TOOLS_PATH=/opt/esp-idf-tools
75+ ENV ESP_ROM_ELF_DIR=/opt/esp-idf-tools
76+ RUN if [ "${BUILD_PLATFORM}" = "esp32" ]; then \
77+ git clone -b v5.4.2 --recursive https://github.com/espressif/esp-idf.git ${IDF_PATH}; \
78+ $IDF_PATH/install.sh; \
79+ bash -c "source ${IDF_PATH}/export.sh && pip3 install --upgrade minify-html jsmin sh requests-cache && make -C ports/esp32 submodules" ; \
80+ rm -rf $IDF_TOOLS_PATH/dist; \
81+ fi
82+
83+ COPY --chmod=0755 entrypoint.sh /entrypoint.sh
84+ ENTRYPOINT [ "/entrypoint.sh" ]
0 commit comments