From c0820961e09797eff1707a928579698d524e71d6 Mon Sep 17 00:00:00 2001 From: Mateusz Redzynia Date: Mon, 30 Jun 2025 13:40:26 +0000 Subject: [PATCH 1/2] zephyr: docker: change docker image to zephyr-lite Change docker image used in zephyr workflows to zephyr-lite built for the sof project. zephyr-lite contains less toolchains compared to zephyr-build to fit into 14GB max storage. Final size of zephyr-lite is appx 10.5GB vs 16.2GB of zephyr-build. Signed-off-by: Mateusz Redzynia --- zephyr/docker-run.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/zephyr/docker-run.sh b/zephyr/docker-run.sh index fccee059be81..8cc27df65a21 100755 --- a/zephyr/docker-run.sh +++ b/zephyr/docker-run.sh @@ -54,8 +54,10 @@ main() run_command() { - # zephyr-build:v0.27.4 has /opt/toolchains/zephyr-sdk-0.17.0 + # zephyr-lite:v0.27.4 has /opt/toolchains/zephyr-sdk-0.17.0 + # zephyr-lite:v0.27.4 is based on zephyr-build:v0.27.4 # https://hub.docker.com/r/zephyrprojectrtos/zephyr-build/tags + # https://hub.docker.com/r/thesofproject/zephyr-lite/tags # # Keep this SDK version identical to the one in # .github/workflows/zephyr.yml#Windows @@ -63,7 +65,7 @@ run_command() --workdir /zep_workspace \ $SOF_DOCKER_RUN \ --env REAL_CC --env http_proxy --env https_proxy \ - ghcr.io/zephyrproject-rtos/zephyr-build:v0.27.4 \ + thesofproject/zephyr-lite:v0.27.4 \ ./sof/scripts/sudo-cwd.sh "$@" } From d282ff1cf4d9669d2d3b728894832517f9381044 Mon Sep 17 00:00:00 2001 From: Mateusz Redzynia Date: Thu, 3 Jul 2025 12:57:29 +0000 Subject: [PATCH 2/2] zephyr-lite: add dockerfile for lightweight zephyr docker zephyr-lite is a new docker image based on zephyr-build to fit within storage limit of current free tier runners. Signed-off-by: Mateusz Redzynia --- scripts/docker_build/zephyr_lite/Dockerfile | 58 +++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 scripts/docker_build/zephyr_lite/Dockerfile diff --git a/scripts/docker_build/zephyr_lite/Dockerfile b/scripts/docker_build/zephyr_lite/Dockerfile new file mode 100644 index 000000000000..0c52b1f668f4 --- /dev/null +++ b/scripts/docker_build/zephyr_lite/Dockerfile @@ -0,0 +1,58 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2025 Intel Corporation. All rights reserved. + +# Use zephyr-build as base image +FROM ghcr.io/zephyrproject-rtos/zephyr-build:v0.27.4 as base + +# Remove additional toolchains. +# As this is not ideal solution there is a plan to build docker image without zephyr-build as the base +# and install only needeed toolchains in the future. +RUN cd /opt/toolchains/zephyr-sdk-0.17.0 && \ + sudo rm -rvf arc* \ + micro* \ + mips* \ + nios* \ + risc* \ + sparc* \ + x86* \ + xtensa-espressif* \ + xtensa-sample* \ + xtensa-dc233c* + +# Some of tests require python 3.12 - instll it from source +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 && \ + tar -xf Python-3.12.9.tgz && \ + cd Python-3.12.9 && \ + ./configure && \ + sudo make -j$(nproc) && \ + sudo make install && \ + sudo rm -rf /tmp/Python-3* + +# Reinstall python3.10 packages with python3.12 +RUN python3.10 -m pip freeze > /tmp/python3.10.pip.txt && \ + cat /tmp/python3.10.pip.txt | xargs -n 1 python3.12 -m pip install || true + +# Use ubuntu24.04 as base for zephyr-lite +FROM ubuntu:24.04 as zephyr-lite + +# Copy needed files from base to zephyr-lite +# /opt for toolchains and sdk +# /usr for binaries and libs +# /home for libs installed in .local +COPY --from=base /opt /opt +COPY --from=base /usr /usr +COPY --from=base /home /home + +USER root + +# Create a user if it doesn't already exist and grant them permission to /home/user. +# Add user to dialout and sudo group +RUN useradd -ms /bin/bash user && \ + chown -R user:user /home/user && \ + usermod -a -G dialout,sudo user + +USER user + +# Set zephyr env variables +ENV ZEPHYR_SDK_INSTALL_DIR=/opt/toolchains/zephyr-sdk-0.17.0 +ENV ZEPHYR_TOOLCHAIN_VARIANT=zephyr