|
| 1 | +# MIT License |
| 2 | + |
| 3 | +# Copyright (c) 2025 Intel Corporation |
| 4 | + |
| 5 | +# Permission is hereby granted, free of charge, to any person obtaining a copy |
| 6 | +# of this software and associated documentation files (the "Software"), to deal |
| 7 | +# in the Software without restriction, including without limitation the rights |
| 8 | +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 9 | +# copies of the Software, and to permit persons to whom the Software is |
| 10 | +# furnished to do so, subject to the following conditions: |
| 11 | + |
| 12 | +# The above copyright notice and this permission notice shall be included in all |
| 13 | +# copies or substantial portions of the Software. |
| 14 | + |
| 15 | +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 | +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 | +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 18 | +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 19 | +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 20 | +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 21 | +# SOFTWARE. |
| 22 | + |
| 23 | +# Use zephyr-build as base image |
| 24 | +FROM ghcr.io/zephyrproject-rtos/zephyr-build:v0.27.4 as base |
| 25 | + |
| 26 | +# Remove additional toolchains. |
| 27 | +# As this is not ideal solution there is a plan to build docker image without zephyr-build as the base |
| 28 | +# and install only needeed toolchains in the future. |
| 29 | +RUN cd /opt/toolchains/zephyr-sdk-0.17.0 && \ |
| 30 | + sudo rm -rvf arc* \ |
| 31 | + micro* \ |
| 32 | + mips* \ |
| 33 | + nios* \ |
| 34 | + risc* \ |
| 35 | + sparc* \ |
| 36 | + x86* \ |
| 37 | + xtensa-espressif* \ |
| 38 | + xtensa-sample* \ |
| 39 | + xtensa-dc233c* |
| 40 | + |
| 41 | +# Some of tests require python 3.12 - instll it from source |
| 42 | +RUN cd /tmp && wget -q --show-progress --progress=bar:force:noscroll --no-check-certificate https://www.python.org/ftp/python/3.12.9/Python-3.12.9.tgz && \ |
| 43 | + tar -xf Python-3.12.9.tgz && \ |
| 44 | + cd Python-3.12.9 && \ |
| 45 | + ./configure && \ |
| 46 | + sudo make -j$(nproc) && \ |
| 47 | + sudo make install && \ |
| 48 | + sudo rm -rf /tmp/Python-3* |
| 49 | + |
| 50 | +# Reinstall python3.10 packages with python3.12 |
| 51 | +RUN python3.10 -m pip freeze > /tmp/python3.10.pip.txt && \ |
| 52 | + cat /tmp/python3.10.pip.txt | xargs -n 1 python3.12 -m pip install || true |
| 53 | + |
| 54 | +# Use ubuntu24.04 as base for zephyr-lite |
| 55 | +FROM ubuntu:24.04 as zephyr-lite |
| 56 | + |
| 57 | +# Copy needed files from base to zephyr-lite |
| 58 | +# /opt for toolchains and sdk |
| 59 | +# /usr for binaries and libs |
| 60 | +# /home for libs installed in .local |
| 61 | +COPY --from=base /opt /opt |
| 62 | +COPY --from=base /usr /usr |
| 63 | +COPY --from=base /home /home |
| 64 | + |
| 65 | +USER root |
| 66 | + |
| 67 | +# Create a user if it doesn't already exist and grant them permission to /home/user. |
| 68 | +# Add user to dialout and sudo group |
| 69 | +RUN useradd -ms /bin/bash user && \ |
| 70 | + chown -R user:user /home/user && \ |
| 71 | + usermod -a -G dialout,sudo user |
| 72 | + |
| 73 | +USER user |
| 74 | + |
| 75 | +# Set zephyr env variables |
| 76 | +ENV ZEPHYR_SDK_INSTALL_DIR=/opt/toolchains/zephyr-sdk-0.17.0 |
| 77 | +ENV ZEPHYR_TOOLCHAIN_VARIANT=zephyr |
0 commit comments