Skip to content

Commit 219bac2

Browse files
committed
Split into a slim base dockerfile.
1 parent af33da7 commit 219bac2

3 files changed

Lines changed: 130 additions & 4 deletions

File tree

.github/workflows/zswatch-ci-image.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
- main
77
- zswatch_*
88
paths:
9+
- Dockerfile.zswatch-base
910
- Dockerfile.zswatch-ci
1011
- Dockerfile.base
1112
- Dockerfile.ci
@@ -46,11 +47,11 @@ jobs:
4647
uses: docker/build-push-action@v5
4748
with:
4849
context: .
49-
file: ./Dockerfile.base
50+
file: ./Dockerfile.zswatch-base
5051
push: true
5152
tags: |
52-
ghcr.io/zswatch/ci-base:${{ github.ref_name }}
53-
ghcr.io/zswatch/ci-base:latest
53+
ghcr.io/zswatch/ci-base-slim:${{ github.ref_name }}
54+
ghcr.io/zswatch/ci-base-slim:latest
5455
5556
- name: Prune buildx cache
5657
run: docker buildx prune -af --keep-storage 5GB
@@ -65,4 +66,4 @@ jobs:
6566
ghcr.io/zswatch/zswatch-ci:latest
6667
ghcr.io/zswatch/zswatch-ci:${{ github.ref_name }}
6768
build-args: |
68-
BASE_IMAGE=ghcr.io/zswatch/ci-base:${{ github.ref_name }}
69+
BASE_IMAGE=ghcr.io/zswatch/ci-base-slim:${{ github.ref_name }}

Dockerfile.zswatch-base

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
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

Dockerfile.zswatch-ci

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,23 @@ EOF
3131
RUN <<'EOF'
3232
if [ "${HOSTTYPE}" = "x86_64" ]; then
3333
# Drop 32-bit support and multilib toolchains not needed for nRF/native_sim_64
34+
apt-get update -y
3435
apt-get purge --auto-remove -y \
3536
gcc-multilib g++-multilib \
3637
libc6-dbg:i386 libfuse-dev:i386 libsdl2-dev:i386 || true
3738
dpkg --remove-architecture i386 || true
3839
fi
3940

4041
# Remove heavy debug/coverage/doc tools unused in ZSWatch CI builds
42+
apt-get update -y
4143
apt-get purge --auto-remove -y \
4244
valgrind \
4345
lcov \
4446
gcovr \
4547
doxygen \
4648
thrift-compiler || true
4749

50+
apt-get update -y
4851
apt-get purge --auto-remove -y \
4952
libgtk2.0-0 \
5053
libcairo2-dev \

0 commit comments

Comments
 (0)