|
1 | 1 | # 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 | + |
3 | 4 | ARG BASE_IMAGE_TAG=idf-v5.4.1 |
4 | 5 | ARG ESP_MATTER_VERSION=v1.4.2 |
5 | 6 |
|
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} |
9 | 7 | FROM ghcr.io/jethome-iot/jethome-dev-esp-idf:${BASE_IMAGE_TAG} |
10 | 8 |
|
11 | 9 | # Re-declare build arguments after FROM |
12 | 10 | ARG ESP_MATTER_VERSION |
13 | 11 |
|
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) |
18 | 22 | pkg-config \ |
19 | | - ninja-build \ |
20 | | - # Python development |
21 | | - python3-venv \ |
22 | | - python3-pip \ |
23 | | - # Matter SDK dependencies |
24 | 23 | libssl-dev \ |
25 | 24 | libdbus-1-dev \ |
26 | 25 | libglib2.0-dev \ |
27 | 26 | libavahi-client-dev \ |
28 | 27 | # Clean up |
| 28 | + && apt-get autoremove -y \ |
29 | 29 | && apt-get clean \ |
30 | 30 | && rm -rf /var/lib/apt/lists/* |
31 | 31 |
|
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 |
35 | 34 | WORKDIR /opt |
36 | 35 | RUN git clone --depth 1 --branch release/${ESP_MATTER_VERSION} \ |
37 | 36 | https://github.com/espressif/esp-matter.git && \ |
38 | 37 | 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 |
45 | 41 |
|
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 |
49 | 45 | 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 |
51 | 48 |
|
52 | 49 | # Set ESP-Matter environment variables |
53 | 50 | ENV ESP_MATTER_PATH=/opt/esp-matter |
54 | 51 |
|
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 |
73 | 55 |
|
74 | | -# Set working directory back to workspace |
| 56 | +# Set working directory |
75 | 57 | WORKDIR /workspace |
76 | 58 |
|
77 | 59 | # 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 && \ |
80 | 62 | python --version && \ |
81 | 63 | idf.py --version && \ |
82 | | - echo "ESP-Matter ${ESP_MATTER_VERSION} installation verified successfully"' |
| 64 | + echo "ESP-Matter ${ESP_MATTER_VERSION} installation verified successfully" |
83 | 65 |
|
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"] |
86 | 68 |
|
87 | 69 | CMD ["/bin/bash"] |
88 | 70 |
|
0 commit comments