launchpad: unroll the chip-build image to reduce image size

esp-matter docker image size is increased a lot, chip-build image
contains a lot more bloaty things that we do not need. So, falling back
to ubuntu base image.
This commit is contained in:
Shubham Patil
2025-12-19 15:36:13 +05:30
parent ee1a5e0241
commit 2c20c8380a
2 changed files with 84 additions and 44 deletions
+80 -39
View File
@@ -1,40 +1,84 @@
# 67 is the latest tag which updates the docker image for ESP32 platform
# hence pinning version to 67 for building with v1.4-branch.
ARG VERSION=67
FROM ghcr.io/project-chip/chip-build:${VERSION} as build
# Use IDF_CHECKOUT_REF to specify a tag, a branch or a specific commit ID.
# Minimal Ubuntu-based image for ESP32 Matter builds
FROM ubuntu:24.04
# Build arguments
ARG IDF_CLONE_URL=https://github.com/espressif/esp-idf.git
ARG IDF_CHECKOUT_REF=v5.1
# Environment variables
ENV DEBIAN_FRONTEND=noninteractive
ENV IDF_PATH=/opt/espressif/esp-idf
ENV IDF_TOOLS_PATH=/opt/espressif/tools
ENV PATH="${IDF_PATH}/tools:${PATH}"
# Install minimal dependencies for ESP-IDF and Matter
RUN set -x \
&& mkdir -p /tmp/esp-idf \
&& cd /tmp/esp-idf \
&& git init \
&& git remote add origin $IDF_CLONE_URL \
&& git fetch origin --depth=1 --recurse-submodules ${IDF_CHECKOUT_REF} \
&& git checkout FETCH_HEAD \
&& git submodule update --init --recursive --depth 1 \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
# Build essentials (gcc, g++, make, etc.)
build-essential \
cmake \
ninja-build \
ccache \
# Autotools (required by Matter bootstrap)
autoconf \
automake \
libtool \
# Python (ESP-IDF + Matter requirements)
python3 \
python3-pip \
python3-venv \
python3-dev \
python-is-python3 \
# Version control and tools
git \
git-lfs \
wget \
curl \
unzip \
rsync \
# ESP-IDF requirements
flex \
bison \
gperf \
libncurses5-dev \
libffi-dev \
libssl-dev \
libusb-1.0-0 \
dfu-util \
# Matter/CHIP core requirements
nodejs \
pkg-config \
libglib2.0-dev \
libdbus-1-dev \
libavahi-client-dev \
libavahi-common-dev \
libgirepository1.0-dev \
libcairo2-dev \
libreadline-dev \
libmbedtls-dev \
# Additional utilities
tree \
# Cleanup
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& git lfs install \
&& : # last line
FROM ghcr.io/project-chip/chip-build:${VERSION}
ENV IDF_PATH=/opt/espressif/esp-idf/
ENV IDF_TOOLS_PATH=/opt/espressif/tools
COPY --from=build /tmp/esp-idf /opt/espressif/esp-idf
# Setup the ESP-IDF
WORKDIR /opt/espressif/esp-idf
WORKDIR /opt/espressif
RUN set -x \
&& git clone --depth=1 --branch=${IDF_CHECKOUT_REF} --recurse-submodules --shallow-submodules ${IDF_CLONE_URL} ${IDF_PATH} \
&& cd ${IDF_PATH} \
&& ./install.sh \
&& git rev-parse --short HEAD > /opt/espressif/esp-idf-commit.txt \
&& rm -rf .git \
&& find . -name "__pycache__" -type d -exec rm -rf {} + 2>/dev/null || true \
&& find . -name "*.pyc" -delete 2>/dev/null || true \
&& rm -rf /root/.cache \
&& : # last line
ARG ESP_MATTER_CLONE_URL=https://github.com/espressif/esp-matter.git
ARG ESP_MATTER_CHECKOUT_REF=main
WORKDIR /opt/espressif
ENV ESP_MATTER_PATH=/opt/espressif/esp-matter
RUN set -x \
@@ -44,26 +88,23 @@ RUN set -x \
&& git remote add origin $ESP_MATTER_CLONE_URL \
&& git fetch origin --depth=1 ${ESP_MATTER_CHECKOUT_REF} \
&& git checkout FETCH_HEAD \
&& git submodule update --init --depth 1 \
&& git submodule update --init --depth=1 \
&& cd ./connectedhomeip/connectedhomeip \
&& ./scripts/checkout_submodules.py --platform esp32 linux --shallow \
&& cd ../.. \
&& cd $IDF_PATH \
&& . ./export.sh \
&& cd $ESP_MATTER_PATH \
&& ./scripts/checkout_submodules.py --platform esp32 --shallow \
&& git rev-parse --short HEAD > /opt/espressif/connectedhomeip-commit.txt \
&& cd ${ESP_MATTER_PATH} && git rev-parse --short HEAD > /opt/espressif/esp-matter-commit.txt \
&& . ${IDF_PATH}/export.sh \
&& ./install.sh \
&& : # last line
RUN set -x \
&& apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -fy --no-install-recommends \
tree \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/ \
&& rm -rf ${ESP_MATTER_PATH}/.git \
&& rm -rf ${ESP_MATTER_PATH}/.gitmodules \
&& find ${ESP_MATTER_PATH} -name ".git" -exec rm -rf {} + 2>/dev/null || true \
&& find ${ESP_MATTER_PATH} -name "__pycache__" -type d -exec rm -rf {} + 2>/dev/null || true \
&& find ${ESP_MATTER_PATH} -name "*.pyc" -delete 2>/dev/null || true \
&& rm -rf /root/.cache /tmp/* \
&& : # last line
COPY entrypoint.sh /opt/esp/entrypoint.sh
ENTRYPOINT [ "/opt/esp/entrypoint.sh" ]
CMD [ "/bin/bash" ]
WORKDIR /opt/espressif/esp-matter
WORKDIR /opt/espressif/esp-matter