tools: optimize docker image and fix launchpad builds

- Earlier fixes removed .git which potentially failed building the
  examples as esp-idf does git describe during builds. Added them back
  anad build works now.
- Removed the dormant bits from the docker-image
- Added ninja-jobs option for better resource utilization during host
  tool builds
- Added back the linux installation as we do need ability to run
  chip-tool from the container.
This commit is contained in:
Shubham Patil
2025-12-30 18:00:33 +05:30
parent a13535b57a
commit 27dd31913a
3 changed files with 35 additions and 22 deletions
+18 -15
View File
@@ -10,6 +10,8 @@ ENV DEBIAN_FRONTEND=noninteractive
ENV IDF_PATH=/opt/espressif/esp-idf
ENV IDF_TOOLS_PATH=/opt/espressif/tools
ENV PATH="${IDF_PATH}/tools:${PATH}"
# Defaulting to 4 as this would be mostly run on resource constrained machines.
ENV NINJA_JOBS=4
# Install minimal dependencies for ESP-IDF and Matter
RUN set -x \
@@ -36,7 +38,6 @@ RUN set -x \
wget \
curl \
unzip \
rsync \
# ESP-IDF requirements
flex \
bison \
@@ -59,9 +60,12 @@ RUN set -x \
libmbedtls-dev \
# Additional utilities
tree \
# Cleanup
# Cleanup apt and unnecessary files
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /usr/share/doc/* /usr/share/man/* /usr/share/info/* \
&& rm -rf /usr/share/locale/* \
&& rm -rf /var/log/* /var/cache/* \
&& git lfs install \
&& : # last line
@@ -69,11 +73,10 @@ 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 \
&& ./install.sh --disable-gdbgui --disable-pytest --disable-ci --disable-docs \
&& 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 \
# remove the archives from the tools path
&& rm -rf ${IDF_TOOLS_PATH}/dist \
&& rm -rf /root/.cache \
&& : # last line
@@ -90,16 +93,16 @@ RUN set -x \
&& git checkout FETCH_HEAD \
&& git submodule update --init --depth=1 \
&& cd ./connectedhomeip/connectedhomeip \
&& ./scripts/checkout_submodules.py --platform esp32 --shallow \
&& ./scripts/checkout_submodules.py --platform esp32 linux --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 \
&& 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 \
&& export IDF_PATH_FORCE=1 && . ${IDF_PATH}/export.sh \
&& cd ${ESP_MATTER_PATH} && ./install.sh --ninja-jobs ${NINJA_JOBS} \
# Move host tools to /usr/local/bin, strip debug symbols, and remove build directory
&& cp ${ESP_MATTER_PATH}/connectedhomeip/connectedhomeip/out/host/chip-cert /usr/local/bin/ \
&& cp ${ESP_MATTER_PATH}/connectedhomeip/connectedhomeip/out/host/chip-tool /usr/local/bin/ \
&& strip /usr/local/bin/chip-cert /usr/local/bin/chip-tool \
&& rm -rf ${ESP_MATTER_PATH}/connectedhomeip/connectedhomeip/out \
&& rm -rf /root/.cache /tmp/* \
&& : # last line
@@ -107,4 +110,4 @@ 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