diff --git a/.github/workflows/zswatch-ci-image.yml b/.github/workflows/zswatch-ci-image.yml index 185d457..21a7ce9 100644 --- a/.github/workflows/zswatch-ci-image.yml +++ b/.github/workflows/zswatch-ci-image.yml @@ -6,6 +6,8 @@ on: - main - zswatch_* paths: + - Dockerfile.zswatch-base + - Dockerfile.zswatch-ci - Dockerfile.base - Dockerfile.ci - .github/workflows/zswatch-ci-image.yml @@ -23,6 +25,14 @@ jobs: - name: Checkout uses: actions/checkout@v4 + - name: Free disk space + run: | + df -h + sudo rm -rf /usr/share/dotnet /opt/ghc /usr/local/lib/android /opt/hostedtoolcache/CodeQL + docker system prune -af || true + docker volume prune -f || true + df -h + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -37,11 +47,14 @@ jobs: uses: docker/build-push-action@v5 with: context: . - file: ./Dockerfile.base + file: ./Dockerfile.zswatch-base push: true tags: | - ghcr.io/zswatch/ci-base:${{ github.ref_name }} - ghcr.io/zswatch/ci-base:latest + ghcr.io/zswatch/ci-base-slim:${{ github.ref_name }} + ghcr.io/zswatch/ci-base-slim:latest + + - name: Prune buildx cache + run: docker buildx prune -af --keep-storage 5GB - name: Build and push CI image uses: docker/build-push-action@v5 @@ -53,4 +66,4 @@ jobs: ghcr.io/zswatch/zswatch-ci:latest ghcr.io/zswatch/zswatch-ci:${{ github.ref_name }} build-args: | - BASE_IMAGE=ghcr.io/zswatch/ci-base:${{ github.ref_name }} + BASE_IMAGE=ghcr.io/zswatch/ci-base-slim:${{ github.ref_name }} diff --git a/Dockerfile.zswatch-base b/Dockerfile.zswatch-base new file mode 100644 index 0000000..7acfee5 --- /dev/null +++ b/Dockerfile.zswatch-base @@ -0,0 +1,122 @@ +# ZSWatch slim base image +# Minimal tooling for nRF5340 and native_sim builds; omits extras from the upstream base. + +FROM ubuntu:24.04 + +ARG USERNAME=user +ARG UID=1000 +ARG GID=1000 +ARG PYTHON_VENV_PATH=/opt/python/venv +ARG UBUNTU_MIRROR_ARCHIVE=archive.ubuntu.com/ubuntu +ARG UBUNTU_MIRROR_SECURITY=security.ubuntu.com/ubuntu +ARG UBUNTU_MIRROR_PORTS=ports.ubuntu.com/ubuntu-ports + +# Set default shell during Docker image build to bash +SHELL ["/bin/bash", "-eo", "pipefail", "-c"] + +# Set non-interactive frontend for apt-get to skip any user confirmations +ENV DEBIAN_FRONTEND=noninteractive + +# Install a trimmed set of APT packages +RUN <=5.0.2' \ + GitPython \ + imgtool \ + junitparser \ + junit2html \ + nrf-regtool~=9.0.1 \ + numpy \ + protobuf \ + grpcio-tools \ + PyGithub \ + pylint \ + sh \ + statistics \ + west +EOF + +# Make Zephyr Python virtual environment available globally +ENV PATH=${PYTHON_VENV_PATH}/bin:$PATH + +# Create user account +RUN < /etc/sudoers.d/$USERNAME + chmod 0440 /etc/sudoers.d/$USERNAME +EOF + +# Ensure that container runs in the 'root' user context +USER root diff --git a/Dockerfile.zswatch-ci b/Dockerfile.zswatch-ci index 31255ef..6668c6e 100644 --- a/Dockerfile.zswatch-ci +++ b/Dockerfile.zswatch-ci @@ -12,6 +12,9 @@ ARG UBUNTU_MIRROR_PORTS=ports.ubuntu.com/ubuntu-ports ARG ZSDK_VERSION=0.17.4 ENV ZSDK_VERSION=$ZSDK_VERSION +# Limit installed SDK content to the toolchains used by ZSWatch to keep the image lean. +ARG ZSDK_TOOLCHAINS="arm-zephyr-eabi,x86_64-zephyr-elf" +ENV ZSDK_TOOLCHAINS=$ZSDK_TOOLCHAINS # Install minimal extra APT packages required for ZSWatch CI RUN <