Skip to content

Commit 86f6d90

Browse files
committed
Add ESP-Matter Docker image and enable workflow
- Refactor ESP-Matter Dockerfile for cleaner build - Add python3-dev for psutil C extension compilation - Source ESP-IDF environment before running install.sh - Remove darwin platform (Docker runs on Linux only) - Install ESP-Matter with --no-host-tool to reduce image size - Add SHELL directive for QEMU emulation compatibility - Clean and consistent with ESP-IDF Dockerfile style - Add custom entrypoint script - Create images/esp-matter/entrypoint.sh - Automatically activates both ESP-IDF and ESP-Matter environments - Add helpful activation messages for users - Located at /opt/esp/esp_matter_entrypoint.sh - Enable ESP-Matter workflow - Remove 'if: false' condition from esp-matter-build job - Multi-platform build: linux/amd64 and linux/arm64 - Tags: latest, sha, idf-vX.X.X-matter-vX.X.X (version last for GHCR display) - Timeout: 60 minutes - Depends on esp-idf-build job completion
1 parent eb9fce7 commit 86f6d90

File tree

3 files changed

+54
-51
lines changed

3 files changed

+54
-51
lines changed

.github/workflows/esp-idf.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ jobs:
8181
runs-on: ubuntu-latest
8282
timeout-minutes: 60
8383
needs: esp-idf-build
84-
if: false && (github.repository_owner == 'jethome-iot' || github.event_name == 'workflow_dispatch') # Temporarily disabled
84+
if: github.repository_owner == 'jethome-iot' || github.event_name == 'workflow_dispatch'
8585
permissions:
8686
contents: read
8787
packages: write

images/esp-matter/Dockerfile

Lines changed: 32 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,70 @@
11
# ESP-Matter Development Image
2-
# Build arguments for version pinning
2+
# Based on https://docs.espressif.com/projects/esp-matter/en/latest/esp32/developing.html
3+
34
ARG BASE_IMAGE_TAG=idf-v5.4.1
45
ARG ESP_MATTER_VERSION=v1.4.2
56

6-
# Use our esp-idf image as base
7-
# For local builds: Uses default idf-v5.4.1 tag
8-
# For CI/CD: Override with --build-arg BASE_IMAGE_TAG=idf-v5.4.1-linux-${ARCH}
97
FROM ghcr.io/jethome-iot/jethome-dev-esp-idf:${BASE_IMAGE_TAG}
108

119
# Re-declare build arguments after FROM
1210
ARG ESP_MATTER_VERSION
1311

14-
# Install Matter prerequisites
15-
# Based on https://docs.espressif.com/projects/esp-matter/en/latest/esp32/developing.html
16-
RUN apt-get update && apt-get install -y \
17-
# Build essentials
12+
# Use bash for all RUN commands (needed for QEMU emulation compatibility)
13+
SHELL ["/bin/bash", "-c"]
14+
15+
# Install only Matter-specific development packages not in base image
16+
# Base image already has: ninja-build, python3-venv, python3-pip, runtime libs
17+
RUN apt-get update && \
18+
apt-get install -y --no-install-recommends \
19+
# Python development headers (needed for psutil and other C extensions)
20+
python3-dev \
21+
# Matter SDK build dependencies (development headers)
1822
pkg-config \
19-
ninja-build \
20-
# Python development
21-
python3-venv \
22-
python3-pip \
23-
# Matter SDK dependencies
2423
libssl-dev \
2524
libdbus-1-dev \
2625
libglib2.0-dev \
2726
libavahi-client-dev \
2827
# Clean up
28+
&& apt-get autoremove -y \
2929
&& apt-get clean \
3030
&& rm -rf /var/lib/apt/lists/*
3131

32-
# Clone esp-matter repository
33-
# Using shallow clone to reduce image size
34-
# ESP-Matter uses release branches (e.g., release/v1.4.2)
32+
# Clone ESP-Matter repository and submodules
33+
# Using shallow clones to reduce image size
3534
WORKDIR /opt
3635
RUN git clone --depth 1 --branch release/${ESP_MATTER_VERSION} \
3736
https://github.com/espressif/esp-matter.git && \
3837
cd esp-matter && \
39-
git submodule update --init --depth 1
40-
41-
# Checkout connectedhomeip submodules
42-
# Include both linux and darwin platforms for maximum compatibility
43-
WORKDIR /opt/esp-matter/connectedhomeip/connectedhomeip
44-
RUN ./scripts/checkout_submodules.py --platform esp32 linux darwin --shallow
38+
git submodule update --init --depth 1 && \
39+
cd connectedhomeip/connectedhomeip && \
40+
./scripts/checkout_submodules.py --platform esp32 linux --shallow
4541

46-
# Install esp-matter (without host tools)
47-
# Host tools (chip-tool, chip-cert, etc.) are excluded to reduce image size
48-
# Use --break-system-packages since this is a containerized environment
42+
# Install ESP-Matter (without host tools to reduce image size)
43+
# Source ESP-IDF environment first to activate Python venv with pip
44+
# TODO: Consider enabling host tools (chip-tool, chip-cert) in future if needed
4945
WORKDIR /opt/esp-matter
50-
RUN PIP_BREAK_SYSTEM_PACKAGES=1 ./install.sh --no-host-tool
46+
RUN source ${IDF_PATH}/export.sh && \
47+
./install.sh --no-host-tool
5148

5249
# Set ESP-Matter environment variables
5350
ENV ESP_MATTER_PATH=/opt/esp-matter
5451

55-
# Create entrypoint script that activates both ESP-IDF and ESP-Matter environments
56-
RUN printf '#!/bin/bash\n\
57-
set -e\n\
58-
\n\
59-
# Source ESP-IDF environment (from base image)\n\
60-
if [ -f "${IDF_PATH}/export.sh" ]; then\n\
61-
. "${IDF_PATH}/export.sh" > /dev/null 2>&1\n\
62-
fi\n\
63-
\n\
64-
# Source ESP-Matter environment\n\
65-
if [ -f "${ESP_MATTER_PATH}/export.sh" ]; then\n\
66-
. "${ESP_MATTER_PATH}/export.sh" > /dev/null 2>&1\n\
67-
fi\n\
68-
\n\
69-
# Execute the command\n\
70-
exec "$@"\n\
71-
' > /opt/esp-matter/entrypoint.sh && \
72-
chmod +x /opt/esp-matter/entrypoint.sh
52+
# Copy and set up custom entrypoint
53+
COPY entrypoint.sh /opt/esp/esp_matter_entrypoint.sh
54+
RUN chmod +x /opt/esp/esp_matter_entrypoint.sh
7355

74-
# Set working directory back to workspace
56+
# Set working directory
7557
WORKDIR /workspace
7658

7759
# Verify installation
78-
RUN bash -c '. ${IDF_PATH}/export.sh && \
79-
. ${ESP_MATTER_PATH}/export.sh && \
60+
RUN source ${IDF_PATH}/export.sh && \
61+
source ${ESP_MATTER_PATH}/export.sh && \
8062
python --version && \
8163
idf.py --version && \
82-
echo "ESP-Matter ${ESP_MATTER_VERSION} installation verified successfully"'
64+
echo "ESP-Matter ${ESP_MATTER_VERSION} installation verified successfully"
8365

84-
# Use custom entrypoint to activate environments
85-
ENTRYPOINT ["/opt/esp-matter/entrypoint.sh"]
66+
# Use custom entrypoint to activate environments (like entrypoint.sh in esp-idf image)
67+
ENTRYPOINT ["/opt/esp/esp_matter_entrypoint.sh"]
8668

8769
CMD ["/bin/bash"]
8870

images/esp-matter/entrypoint.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
set -e
3+
4+
echo "Activating ESP-IDF and ESP-Matter environments..."
5+
echo ""
6+
7+
# Source ESP-IDF environment
8+
. "${IDF_PATH}/export.sh"
9+
10+
echo ""
11+
echo "Activating ESP-Matter environment..."
12+
13+
# Source ESP-Matter environment
14+
. "${ESP_MATTER_PATH}/export.sh"
15+
16+
echo "ESP-Matter environment activated"
17+
echo ""
18+
19+
# Execute the command
20+
exec "$@"
21+

0 commit comments

Comments
 (0)