1- # # Use an official lightweight Python image.
2- FROM tensorflow/tensorflow:2.9.1-gpu
1+ # ===========================================================================
2+ # EdgeVolution Multi-Target Dockerfile
3+ #
4+ # Targets:
5+ # ml - TensorFlow 2.9.1 GPU + Python deps + project code (DEFAULT)
6+ # embedded - Extends ml with nRF tools, J-Link, Zephyr SDK, west workspace
7+ #
8+ # Usage:
9+ # docker build -t edgevolution . # builds ml
10+ # docker build --target embedded -t edgevolution-embedded . # builds embedded
11+ # ===========================================================================
12+
13+ # ===========================================================================
14+ # Stage 1: ML / NAS runtime (default target)
15+ # Base: tensorflow/tensorflow:2.9.1-gpu (Ubuntu 20.04, Python 3.8, CUDA 11.2)
16+ # ===========================================================================
17+ FROM tensorflow/tensorflow:2.9.1-gpu AS ml
318
4- # # Prevent interactive dialogs during apt-get installs
519ENV DEBIAN_FRONTEND=noninteractive
620
7- # ---------------------------------------------------------------------------
8- # System dependencies & basic setup
9- # ---------------------------------------------------------------------------
21+ # The TF base image already provides python3, pip, wget, curl, etc.
22+ # Only install packages that are actually missing.
23+ # git - required by GitPython (used in utils/saver.py)
24+ # ffmpeg - required by librosa/pydub for audio processing
25+ # libsndfile1 - required by SoundFile for audio I/O
26+ # vim - convenience for interactive debugging
1027RUN apt-get update && apt-get install -y --no-install-recommends \
11- wget \
12- dpkg \
1328 git \
29+ ffmpeg \
30+ libsndfile1 \
1431 vim \
15- vim-common \
16- ca-certificates \
17- udev \
18- libusb-1.0-0 \
19- libxcb-render-util0 \
20- libxcb-randr0 \
21- libxcb-icccm4 \
22- libxcb-keysyms1 \
23- libxcb-image0 \
24- libxkbcommon-x11-0 \
25- sudo \
32+ && rm -rf /var/lib/apt/lists/*
33+
34+ WORKDIR /EdgeVolution
35+
36+ # Copy requirements.txt FIRST for Docker layer caching.
37+ # pip install is only re-run when requirements.txt changes,
38+ # not on every source code change.
39+ COPY requirements.txt /EdgeVolution/requirements.txt
40+ RUN pip install --upgrade pip \
41+ && pip install --no-cache-dir --timeout 600 -r requirements.txt
42+
43+ # Copy the rest of the project source code.
44+ # .dockerignore prevents copying .git, docs, notebooks, build artifacts, etc.
45+ COPY . /EdgeVolution
46+ RUN pip install --no-cache-dir -e .
47+
48+ CMD ["/bin/bash" ]
49+
50+
51+ # ===========================================================================
52+ # Stage 2: Embedded toolchain (extends ml)
53+ # Adds: nRF CLI tools, Segger J-Link, CMake >= 3.20, Zephyr SDK, west workspace
54+ # ===========================================================================
55+ FROM ml AS embedded
56+
57+ ENV DEBIAN_FRONTEND=noninteractive
58+
59+ # System packages required by Zephyr, west, nRF tools, and the C/C++ build.
60+ RUN apt-get update && apt-get install -y --no-install-recommends \
2661 gnupg \
2762 lsb-release \
63+ udev \
64+ libusb-1.0-0 \
2865 build-essential \
29- ffmpeg \
30- python3 \
31- python3-pip \
32- python3-venv \
33- python3-dev \
34- git \
3566 ninja-build \
3667 gperf \
3768 ccache \
@@ -45,104 +76,66 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
4576 g++-multilib \
4677 libsdl2-dev \
4778 libmagic1 \
79+ wget \
4880 && rm -rf /var/lib/apt/lists/*
4981
5082
5183# ---------------------------------------------------------------------------
52- # Install nRF Command Line Tools (including nrfjprog )
84+ # CMake 3.28 (compatible with Python 3.8; CMake 4.x requires Python 3.9+ )
5385# ---------------------------------------------------------------------------
54- WORKDIR /tmp/nrf
55- RUN wget "https://nsscprodmedia.blob.core.windows.net/prod/software-and-other-downloads/desktop-software/nrf-command-line-tools/sw/versions-10-x-x/10-21-0/nrf-command-line-tools-10.21.0_linux-amd64.tar.gz" \
56- && tar xvf nrf-command-line-tools-10.21.0_linux-amd64.tar.gz \
57- && sudo cp -a nrf-command-line-tools /opt/ \
58- && rm -rf nrf-command-line-tools-10.21.0_linux-amd64.tar.gz nrf-command-line-tools
59-
60- ENV PATH="${PATH}:/opt/nrf-command-line-tools/bin"
86+ RUN wget -q https://github.com/Kitware/CMake/releases/download/v3.28.6/cmake-3.28.6-linux-x86_64.tar.gz \
87+ && tar xf cmake-3.28.6-linux-x86_64.tar.gz --strip-components=1 -C /usr/local \
88+ && rm cmake-3.28.6-linux-x86_64.tar.gz
6189
6290# ---------------------------------------------------------------------------
63- # Install Segger J-Link software
64- # (You might want to update the version to the latest.)
91+ # nRF Command Line Tools (including nrfjprog)
6592# ---------------------------------------------------------------------------
66- RUN /lib/systemd/systemd-udevd --daemon
67- RUN udevadm monitor &
68-
69- RUN wget --post-data="accept_license_agreement=accepted&submit=Download+software" https://www.segger.com/downloads/jlink/JLink_Linux_V788n_x86_64.deb
70-
71- # Took this small workaround from: https://forums.docker.com/t/udevadm-monitor-in-docker-file/125723
72- RUN dpkg --unpack JLink_Linux_V788n_x86_64.deb
73- RUN rm /var/lib/dpkg/info/jlink.postinst -f
74- RUN dpkg --configure jlink
75- RUN apt install -yf
93+ WORKDIR /tmp/nrf
94+ RUN wget -q "https://nsscprodmedia.blob.core.windows.net/prod/software-and-other-downloads/desktop-software/nrf-command-line-tools/sw/versions-10-x-x/10-21-0/nrf-command-line-tools-10.21.0_linux-amd64.tar.gz" \
95+ && tar xf nrf-command-line-tools-10.21.0_linux-amd64.tar.gz \
96+ && cp -a nrf-command-line-tools /opt/ \
97+ && rm -rf /tmp/nrf
7698
77- # ---------------------------------------------------------------------------
78- # Install CMake (some distributions already have an older version).
79- # ---------------------------------------------------------------------------
80- RUN wget https://apt.kitware.com/kitware-archive.sh \
81- && sudo bash kitware-archive.sh \
82- && rm kitware-archive.sh \
83- && apt-get update && apt-get install -y cmake
99+ ENV PATH="${PATH}:/opt/nrf-command-line-tools/bin"
84100
85101# ---------------------------------------------------------------------------
86- # Install west (Zephyr's meta-tool) and dependencies
102+ # Segger J-Link
103+ # The J-Link .deb postinst script tries to start udev/systemd services
104+ # which don't exist in Docker. Workaround:
105+ # 1. dpkg --unpack (extract files without running postinst)
106+ # 2. Remove the postinst script
107+ # 3. dpkg --configure (mark package as configured)
108+ # 4. apt-get install -yf (resolve any missing dependencies)
87109# ---------------------------------------------------------------------------
88- RUN pip install west
110+ WORKDIR /tmp/jlink
111+ RUN wget -q --post-data="accept_license_agreement=accepted&submit=Download+software" \
112+ https://www.segger.com/downloads/jlink/JLink_Linux_V788n_x86_64.deb \
113+ && dpkg --unpack JLink_Linux_V788n_x86_64.deb \
114+ && rm -f /var/lib/dpkg/info/jlink.postinst \
115+ && apt-get update && apt-get install -yf \
116+ && rm -rf /var/lib/apt/lists/* /tmp/jlink
89117
90118# ---------------------------------------------------------------------------
91- # Install Zephyr SDK to /opt/zephyr-sdk- 0.16.5-1
119+ # Zephyr SDK 0.16.5-1
92120# ---------------------------------------------------------------------------
93121WORKDIR /opt
94- RUN wget https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.5-1/zephyr-sdk-0.16.5-1_linux-x86_64.tar.xz \
95- && wget -O - https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.5-1/sha256.sum | shasum --check --ignore-missing \
96- && tar xvf zephyr-sdk-0.16.5-1_linux-x86_64.tar.xz \
122+ RUN wget -q https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.5-1/zephyr-sdk-0.16.5-1_linux-x86_64.tar.xz \
123+ && wget -q - O - https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.5-1/sha256.sum | shasum --check --ignore-missing \
124+ && tar xf zephyr-sdk-0.16.5-1_linux-x86_64.tar.xz \
97125 && rm zephyr-sdk-0.16.5-1_linux-x86_64.tar.xz
98126
99127ENV ZEPHYR_SDK_INSTALL_DIR="/opt/zephyr-sdk-0.16.5-1"
100128
101129# ---------------------------------------------------------------------------
102- # Create a non-root user
130+ # Upgrade west to 1.0.0 (Zephyr 4.0.0 build.py requires west.commands.Verbosity,
131+ # which was removed in west 0.14.0 and re-added in west 1.0.0)
103132# ---------------------------------------------------------------------------
104- ARG USERNAME=edgedev
105- ARG USER_UID=1000
106- ARG USER_GID=$USER_UID
107-
108- RUN groupadd --gid $USER_GID $USERNAME \
109- && useradd --uid $USER_UID --gid $USER_GID -m $USERNAME -s /bin/bash \
110- && echo "$USERNAME ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/$USERNAME \
111- && chmod 0440 /etc/sudoers.d/$USERNAME
112-
113- # Add user to dialout group for serial port access
114- RUN usermod -a -G dialout,plugdev $USERNAME
133+ RUN pip install --no-cache-dir west==1.0.0
115134
116135# ---------------------------------------------------------------------------
117- # Create a project directory and copy your files
118- # (Assuming you have requirements.txt and a tflite/ folder , etc.)
136+ # Zephyr workspace is provided via volume mount from the host.
137+ # The host must have .west/, zephyr/, modules/ , etc. in tflite/.
119138# ---------------------------------------------------------------------------
120139WORKDIR /EdgeVolution
121- COPY . /EdgeVolution
122140
123- # ---------------------------------------------------------------------------
124- # Install Python dependencies (as root, but accessible to user)
125- # ---------------------------------------------------------------------------
126- RUN pip install --upgrade pip \
127- && pip install --no-cache-dir -r requirements.txt
128-
129- RUN pip install --upgrade numba librosa
130-
131- # ---------------------------------------------------------------------------
132- # Zephyr project initialization (as root first)
133- # ---------------------------------------------------------------------------
134- WORKDIR /EdgeVolution/tflite
135- RUN if [ ! -f .west/config ]; then west init .; else echo "West workspace already initialized" ; fi && \
136- west config manifest.group-filter -- +optional && \
137- west zephyr-export
138-
139- # ---------------------------------------------------------------------------
140- # Change ownership of the project directory to the non-root user
141- # ---------------------------------------------------------------------------
142- RUN chown -R $USERNAME:$USERNAME /EdgeVolution
143-
144- # Switch to non-root user
145- USER $USERNAME
146-
147- WORKDIR /EdgeVolution
148- CMD ["/bin/bash" ]
141+ CMD ["/bin/bash" ]
0 commit comments