|
| 1 | +# ZSWatch slim base image |
| 2 | +# Minimal tooling for nRF5340 and native_sim builds; omits extras from the upstream base. |
| 3 | + |
| 4 | +FROM ubuntu:24.04 |
| 5 | + |
| 6 | +ARG USERNAME=user |
| 7 | +ARG UID=1000 |
| 8 | +ARG GID=1000 |
| 9 | +ARG PYTHON_VENV_PATH=/opt/python/venv |
| 10 | +ARG UBUNTU_MIRROR_ARCHIVE=archive.ubuntu.com/ubuntu |
| 11 | +ARG UBUNTU_MIRROR_SECURITY=security.ubuntu.com/ubuntu |
| 12 | +ARG UBUNTU_MIRROR_PORTS=ports.ubuntu.com/ubuntu-ports |
| 13 | + |
| 14 | +# Set default shell during Docker image build to bash |
| 15 | +SHELL ["/bin/bash", "-eo", "pipefail", "-c"] |
| 16 | + |
| 17 | +# Set non-interactive frontend for apt-get to skip any user confirmations |
| 18 | +ENV DEBIAN_FRONTEND=noninteractive |
| 19 | + |
| 20 | +# Install a trimmed set of APT packages |
| 21 | +RUN <<EOF |
| 22 | + # Set up custom Ubuntu APT mirrors |
| 23 | + pushd /etc/apt/sources.list.d |
| 24 | + cp ubuntu.sources ubuntu.sources.bak |
| 25 | + sed -i "s#archive.ubuntu.com/ubuntu#${UBUNTU_MIRROR_ARCHIVE}#" ubuntu.sources |
| 26 | + sed -i "s#security.ubuntu.com/ubuntu#${UBUNTU_MIRROR_SECURITY}#" ubuntu.sources |
| 27 | + sed -i "s#ports.ubuntu.com/ubuntu-ports#${UBUNTU_MIRROR_PORTS}#" ubuntu.sources |
| 28 | + popd |
| 29 | + |
| 30 | + apt-get -y update |
| 31 | + |
| 32 | + # Core build and tooling stack |
| 33 | + apt-get install --no-install-recommends -y \ |
| 34 | + build-essential \ |
| 35 | + ca-certificates \ |
| 36 | + ccache \ |
| 37 | + cmake \ |
| 38 | + dfu-util \ |
| 39 | + device-tree-compiler \ |
| 40 | + file \ |
| 41 | + gdb \ |
| 42 | + git \ |
| 43 | + gperf \ |
| 44 | + libffi-dev \ |
| 45 | + libncursesw6 \ |
| 46 | + libreadline8 \ |
| 47 | + libssl-dev \ |
| 48 | + libusb-1.0-0 \ |
| 49 | + libyaml-0-2 \ |
| 50 | + libsdl2-dev \ |
| 51 | + locales \ |
| 52 | + ninja-build \ |
| 53 | + openssh-client \ |
| 54 | + pkg-config \ |
| 55 | + python3 \ |
| 56 | + python3-dev \ |
| 57 | + python3-pip \ |
| 58 | + python3-setuptools \ |
| 59 | + python3-wheel \ |
| 60 | + python3-venv \ |
| 61 | + python-is-python3 \ |
| 62 | + sudo \ |
| 63 | + unzip \ |
| 64 | + wget \ |
| 65 | + xz-utils |
| 66 | + |
| 67 | + apt-get autoremove --purge -y |
| 68 | + apt-get clean -y |
| 69 | + rm -rf /var/lib/apt/lists/* |
| 70 | + |
| 71 | + # Restore original Ubuntu mirrors |
| 72 | + pushd /etc/apt/sources.list.d |
| 73 | + mv -f ubuntu.sources.bak ubuntu.sources |
| 74 | + popd |
| 75 | +EOF |
| 76 | + |
| 77 | +# Initialise system locale |
| 78 | +RUN locale-gen en_US.UTF-8 |
| 79 | +ENV LANG=en_US.UTF-8 |
| 80 | +ENV LANGUAGE=en_US:en |
| 81 | +ENV LC_ALL=en_US.UTF-8 |
| 82 | + |
| 83 | +# Set up Python virtual environment for Zephyr |
| 84 | +RUN <<EOF |
| 85 | + mkdir -p ${PYTHON_VENV_PATH} |
| 86 | + python3 -m venv ${PYTHON_VENV_PATH} |
| 87 | + source ${PYTHON_VENV_PATH}/bin/activate |
| 88 | + |
| 89 | + pip install --no-cache-dir --upgrade pip setuptools wheel |
| 90 | + pip install --no-cache-dir \ |
| 91 | + -r https://raw.githubusercontent.com/zephyrproject-rtos/zephyr/main/scripts/requirements.txt \ |
| 92 | + -r https://raw.githubusercontent.com/zephyrproject-rtos/mcuboot/main/scripts/requirements.txt \ |
| 93 | + 'esptool>=5.0.2' \ |
| 94 | + GitPython \ |
| 95 | + imgtool \ |
| 96 | + junitparser \ |
| 97 | + junit2html \ |
| 98 | + nrf-regtool~=9.0.1 \ |
| 99 | + numpy \ |
| 100 | + protobuf \ |
| 101 | + grpcio-tools \ |
| 102 | + PyGithub \ |
| 103 | + pylint \ |
| 104 | + sh \ |
| 105 | + statistics \ |
| 106 | + west |
| 107 | +EOF |
| 108 | + |
| 109 | +# Make Zephyr Python virtual environment available globally |
| 110 | +ENV PATH=${PYTHON_VENV_PATH}/bin:$PATH |
| 111 | + |
| 112 | +# Create user account |
| 113 | +RUN <<EOF |
| 114 | + userdel -r ubuntu || true |
| 115 | + groupadd -g $GID -o $USERNAME |
| 116 | + useradd -u $UID -m -g $USERNAME -G plugdev $USERNAME |
| 117 | + echo $USERNAME ' ALL = NOPASSWD: ALL' > /etc/sudoers.d/$USERNAME |
| 118 | + chmod 0440 /etc/sudoers.d/$USERNAME |
| 119 | +EOF |
| 120 | + |
| 121 | +# Ensure that container runs in the 'root' user context |
| 122 | +USER root |
0 commit comments