Skip to content

Commit 4437214

Browse files
committed
Make image smaller by removing stuff we don't need.
1 parent cba8e36 commit 4437214

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
- main
77
- zswatch_*
88
paths:
9+
- Dockerfile.zswatch-ci
910
- Dockerfile.base
1011
- Dockerfile.ci
1112
- .github/workflows/zswatch-ci-image.yml

Dockerfile.zswatch-ci

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ ARG UBUNTU_MIRROR_PORTS=ports.ubuntu.com/ubuntu-ports
1212

1313
ARG ZSDK_VERSION=0.17.4
1414
ENV ZSDK_VERSION=$ZSDK_VERSION
15+
# Limit installed SDK content to the toolchains used by ZSWatch to keep the image lean.
16+
ARG ZSDK_TOOLCHAINS="arm-zephyr-eabi,x86_64-zephyr-elf"
17+
ENV ZSDK_TOOLCHAINS=$ZSDK_TOOLCHAINS
1518

1619
# Install minimal extra APT packages required for ZSWatch CI
1720
RUN <<EOF
@@ -24,14 +27,43 @@ RUN <<EOF
2427
rm -rf /var/lib/apt/lists/*
2528
EOF
2629

30+
# Remove large tooling from ci-base that ZSWatch does not need (keeps image small)
31+
RUN <<'EOF'
32+
if [ "${HOSTTYPE}" = "x86_64" ]; then
33+
# Drop 32-bit support and multilib toolchains not needed for nRF/native_sim_64
34+
apt-get purge --auto-remove -y \
35+
gcc-multilib g++-multilib \
36+
libc6-dbg:i386 libfuse-dev:i386 libsdl2-dev:i386 || true
37+
dpkg --remove-architecture i386 || true
38+
fi
39+
40+
# Remove heavy debug/coverage/doc tools unused in ZSWatch CI builds
41+
apt-get purge --auto-remove -y \
42+
valgrind \
43+
lcov \
44+
gcovr \
45+
doxygen \
46+
thrift-compiler || true
47+
48+
apt-get clean -y
49+
rm -rf /var/lib/apt/lists/*
50+
EOF
51+
2752
# Install Zephyr SDK
2853
RUN <<EOF
2954
mkdir -p /opt/toolchains
3055
cd /opt/toolchains
3156
wget ${WGET_ARGS} https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v${ZSDK_VERSION}/zephyr-sdk-${ZSDK_VERSION}_linux-${HOSTTYPE}.tar.xz
3257
tar xf zephyr-sdk-${ZSDK_VERSION}_linux-${HOSTTYPE}.tar.xz
33-
zephyr-sdk-${ZSDK_VERSION}/setup.sh -t all -h -c
58+
# Convert comma/space separated toolchain list into repeated -t flags (required by setup.sh)
59+
set --
60+
for toolchain in $(printf '%s' "$ZSDK_TOOLCHAINS" | tr ',' ' '); do
61+
set -- "$@" -t "$toolchain"
62+
done
63+
set -- "$@" -h -c
64+
zephyr-sdk-${ZSDK_VERSION}/setup.sh "$@"
3465
rm zephyr-sdk-${ZSDK_VERSION}_linux-${HOSTTYPE}.tar.xz
66+
find zephyr-sdk-${ZSDK_VERSION}/sysroots -maxdepth 4 -type d \( -name doc -o -name man -o -name info \) -exec rm -rf '{}' +
3567
EOF
3668

3769
# Run the Zephyr SDK setup script as 'user' in order to ensure that the

0 commit comments

Comments
 (0)