11FROM python:3.13-bookworm AS base
22
33ENV PIP_ROOT_USER_ACTION=ignore
4- ENV ARM_TOOLCHAIN_EABI_VERSION=14.2.rel1
5- ENV ARM_TOOLCHAIN_ELF_VERSION=13.3.rel1
64
75# Apt dependencies
86RUN apt-get update && apt-get install -y \
97 jq jdupes build-essential \
108 libgpiod-dev libyaml-cpp-dev libbluetooth-dev libusb-1.0-0-dev libi2c-dev libuv1-dev \
119 libx11-dev libinput-dev libxkbcommon-x11-dev \
1210 openssl libssl-dev libulfius-dev liborcania-dev \
13- git git-lfs gettext cmake mtools floppyd dosfstools \
11+ git git-lfs gettext cmake mtools floppyd dosfstools ninja-build \
1412 && rm -rf /var/lib/apt/lists/*
1513
16- # Install ARM toolchain (EABI) based on architecture
17- RUN ARCH=$(dpkg --print-architecture) && \
14+ FROM base AS repo
15+ ARG BUILD_REPO="https://github.com/adafruit/circuitpython.git"
16+ ARG BUILD_REF="main"
17+ ARG BUILD_FORK_REPO="https://github.com/fobe-projects/circuitpython.git"
18+ ARG BUILD_FORK_REF="main"
19+
20+ WORKDIR /workspace
21+
22+ RUN git config --global --add safe.directory /workspace \
23+ && git clone --depth 1 --filter=tree:0 "${BUILD_REPO}" /workspace \
24+ && cd /workspace && git checkout "${BUILD_REF}" \
25+ && git submodule update --init --filter=blob:none data extmod lib tools frozen \
26+ && git fetch --no-recurse-submodules --shallow-since="2021-07-01" --tags "${BUILD_REPO}" HEAD \
27+ && git fetch --no-recurse-submodules --shallow-since="2021-07-01" origin \
28+ && git repack -d \
29+ && git remote add fork "${BUILD_FORK_REPO}" \
30+ && git fetch fork --filter=tree:0 \
31+ && git fetch --no-recurse-submodules --filter=tree:0 fork "${BUILD_FORK_REF}" \
32+ && git checkout -b fork-branch "fork/${BUILD_FORK_REF}" \
33+ && git repack -d
34+
35+ RUN pip3 install --upgrade -r requirements-doc.txt \
36+ && pip3 install --upgrade -r requirements-dev.txt \
37+ && pip3 install --upgrade huffman
38+
39+ FROM repo AS port
40+
41+ ARG ARM_TOOLCHAIN_EABI_VERSION="14.2.rel1"
42+ ARG ARM_TOOLCHAIN_ELF_VERSION="13.3.rel1"
43+ ARG BUILD_PLATFORM
44+
45+ RUN make -C ports/"${BUILD_PLATFORM}" fetch-port-submodules
46+
47+ RUN if [ "${BUILD_PLATFORM}" != "espressif" ] && [ "${BUILD_PLATFORM}" != "zephyr-cp" ] && [ "${BUILD_PLATFORM}" != "litex" ] && [ "${BUILD_PLATFORM}" != "none" ]; then \
48+ ARCH=$(dpkg --print-architecture) && \
1849 if [ "$ARCH" = "arm64" ]; then \
1950 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" ; \
2051 elif [ "$ARCH" = "amd64" ]; then \
@@ -27,10 +58,12 @@ RUN ARCH=$(dpkg --print-architecture) && \
2758 curl -fsSL "$TOOLCHAIN_URL" | tar -xJ -C /usr/local/arm-none-eabi --strip-components=1 && \
2859 for f in /usr/local/arm-none-eabi/bin/arm-none-eabi-*; do \
2960 ln -sf "$f" /usr/local/bin/$(basename "$f" ); \
30- done
61+ done \
62+ fi
3163
32- # Install ARM toolchain (ELF) based on architecture
33- RUN ARCH=$(dpkg --print-architecture) && \
64+ # Broadcom
65+ RUN if [ "${BUILD_PLATFORM}" = "broadcom" ]; then \
66+ ARCH=$(dpkg --print-architecture) && \
3467 if [ "$ARCH" = "arm64" ]; then \
3568 TOOLCHAIN_URL="https://developer.arm.com/-/media/Files/downloads/gnu/$ARM_TOOLCHAIN_ELF_VERSION/binrel/arm-gnu-toolchain-$ARM_TOOLCHAIN_ELF_VERSION-aarch64-aarch64-none-elf.tar.xz" ; \
3669 elif [ "$ARCH" = "amd64" ]; then \
@@ -43,35 +76,49 @@ RUN ARCH=$(dpkg --print-architecture) && \
4376 curl -fsSL "$TOOLCHAIN_URL" | tar -xJ -C /usr/local/arm-none-elf --strip-components=1 && \
4477 for f in /usr/local/arm-none-elf/bin/arm-none-elf-*; do \
4578 ln -sf "$f" /usr/local/bin/$(basename "$f" ); \
46- done
47-
48- FROM base AS repo
49- ARG BUILD_REPO="https://github.com/adafruit/circuitpython.git"
50- ARG BUILD_REF="main"
51- ARG BUILD_FORK_REPO="https://github.com/fobe-projects/circuitpython.git"
52- ARG BUILD_FORK_REF="main"
53- ARG BUILD_PLATFORM
79+ done \
80+ fi
5481
55- WORKDIR /workspace
56-
57- RUN git config --global --add safe.directory /workspace
58- RUN git clone --depth 1 --filter=tree:0 "${BUILD_REPO}" /workspace
59- RUN git checkout "${BUILD_REF}"
60- RUN git fetch --no-recurse-submodules --shallow-since="2021-07-01" --tags "${BUILD_REPO}" HEAD
61- RUN git fetch --no-recurse-submodules --shallow-since="2021-07-01" origin
62- RUN git repack -d
63- RUN git remote add fork "${BUILD_FORK_REPO}" && git fetch fork --filter=tree:0
64- RUN git checkout -b fork-branch "fork/${BUILD_FORK_REF}"
65-
66- RUN pip3 install --upgrade -r requirements-dev.txt && pip3 install --upgrade -r requirements-doc.txt
67- RUN pip3 install --upgrade huffman
68-
69- RUN python tools/ci_fetch_deps.py ${BUILD_PLATFORM}
82+ # Nordic
83+ RUN if [ "${BUILD_PLATFORM}" = "nordic" ]; then \
84+ ARCH=$(dpkg --print-architecture) && \
85+ if [ "$ARCH" = "arm64" ]; then \
86+ TOOLCHAIN_URL="https://files.nordicsemi.com/artifactory/swtools/external/nrfutil/executables/aarch64-unknown-linux-gnu/nrfutil" ; \
87+ elif [ "$ARCH" = "amd64" ]; then \
88+ TOOLCHAIN_URL="https://files.nordicsemi.com/artifactory/swtools/external/nrfutil/executables/x86_64-unknown-linux-gnu/nrfutil" ; \
89+ else \
90+ echo "Unsupported architecture: $ARCH" ; \
91+ exit 1; \
92+ fi && curl -fsSL "$TOOLCHAIN_URL" -o nrfutil;\
93+ chmod +x nrfutil; \
94+ ./nrfutil install nrf5sdk-tools; \
95+ mv nrfutil /usr/local/bin; \
96+ nrfutil -V; \
97+ fi
7098
99+ # Espressif IDF
71100ENV IDF_PATH=/workspace/ports/espressif/esp-idf
72101ENV IDF_TOOLS_PATH=/workspace/.idf_tools
73102ENV ESP_ROM_ELF_DIR=/workspace/.idf_tools
74- RUN git submodule update --init --depth=1 --recursive $IDF_PATH
103+ RUN if [ "${BUILD_PLATFORM}" = "espressif" ]; then \
104+ git submodule update --init --depth=1 --recursive ${IDF_PATH}; \
105+ $IDF_PATH/install.sh; \
106+ bash -c "source ${IDF_PATH}/export.sh && pip3 install --upgrade minify-html jsmin sh requests-cache" ; \
107+ rm -rf $IDF_TOOLS_PATH/dist; \
108+ fi
109+
110+ # Litex
111+ RUN if [ "${BUILD_PLATFORM}" = "litex" ]; then \
112+ ARCH=$(dpkg --print-architecture) && \
113+ if [ "$ARCH" = "amd64" ]; then \
114+ TOOLCHAIN_URL="https://static.dev.sifive.com/dev-tools/riscv64-unknown-elf-gcc-8.3.0-2019.08.0-x86_64-linux-centos6.tar.gz" ; \
115+ else \
116+ echo "Unsupported architecture: $ARCH" ; \
117+ exit 1; \
118+ fi && curl -fsSL "$TOOLCHAIN_URL" -o riscv64-unknown-elf-gcc-8.3.0-2019.08.0-x86_64-linux-centos6.tar.gz;\
119+ tar -C /usr --strip-components=1 -xaf riscv64-unknown-elf-gcc-8.3.0-2019.08.0-x86_64-linux-centos6.tar.gz; \
120+ rm -rf riscv64-unknown-elf-gcc-8.3.0-2019.08.0-x86_64-linux-centos6.tar.gz; \
121+ fi
75122
76- COPY entrypoint.sh /entrypoint.sh
123+ COPY --chmod=0755 entrypoint.sh /entrypoint.sh
77124ENTRYPOINT [ "/entrypoint.sh" ]
0 commit comments