|
| 1 | +# SPDX-License-Identifier: BSD-3-Clause |
| 2 | +# Copyright(c) 2025 Intel Corporation. All rights reserved. |
| 3 | + |
| 4 | +# Use zephyr-build as base image |
| 5 | +FROM ghcr.io/zephyrproject-rtos/zephyr-build:v0.27.4 as base |
| 6 | + |
| 7 | +# Remove additional toolchains. |
| 8 | +# As this is not ideal solution there is a plan to build docker image without zephyr-build as the base |
| 9 | +# and install only needeed toolchains in the future. |
| 10 | +RUN cd /opt/toolchains/zephyr-sdk-0.17.0 && \ |
| 11 | + sudo rm -rvf arc* \ |
| 12 | + micro* \ |
| 13 | + mips* \ |
| 14 | + nios* \ |
| 15 | + risc* \ |
| 16 | + sparc* \ |
| 17 | + x86* \ |
| 18 | + xtensa-espressif* \ |
| 19 | + xtensa-sample* \ |
| 20 | + xtensa-dc233c* |
| 21 | + |
| 22 | +# Some of tests require python 3.12 - instll it from source |
| 23 | +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 && \ |
| 24 | + tar -xf Python-3.12.9.tgz && \ |
| 25 | + cd Python-3.12.9 && \ |
| 26 | + ./configure && \ |
| 27 | + sudo make -j$(nproc) && \ |
| 28 | + sudo make install && \ |
| 29 | + sudo rm -rf /tmp/Python-3* |
| 30 | + |
| 31 | +# Reinstall python3.10 packages with python3.12 |
| 32 | +RUN python3.10 -m pip freeze > /tmp/python3.10.pip.txt && \ |
| 33 | + cat /tmp/python3.10.pip.txt | xargs -n 1 python3.12 -m pip install || true |
| 34 | + |
| 35 | +# Use ubuntu24.04 as base for zephyr-lite |
| 36 | +FROM ubuntu:24.04 as zephyr-lite |
| 37 | + |
| 38 | +# Copy needed files from base to zephyr-lite |
| 39 | +# /opt for toolchains and sdk |
| 40 | +# /usr for binaries and libs |
| 41 | +# /home for libs installed in .local |
| 42 | +COPY --from=base /opt /opt |
| 43 | +COPY --from=base /usr /usr |
| 44 | +COPY --from=base /home /home |
| 45 | + |
| 46 | +USER root |
| 47 | + |
| 48 | +# Create a user if it doesn't already exist and grant them permission to /home/user. |
| 49 | +# Add user to dialout and sudo group |
| 50 | +RUN useradd -ms /bin/bash user && \ |
| 51 | + chown -R user:user /home/user && \ |
| 52 | + usermod -a -G dialout,sudo user |
| 53 | + |
| 54 | +USER user |
| 55 | + |
| 56 | +# Set zephyr env variables |
| 57 | +ENV ZEPHYR_SDK_INSTALL_DIR=/opt/toolchains/zephyr-sdk-0.17.0 |
| 58 | +ENV ZEPHYR_TOOLCHAIN_VARIANT=zephyr |
0 commit comments