ARG VERSION=latest
FROM connectedhomeip/chip-build-esp32:${VERSION} as build

WORKDIR /opt/espressif
ENV ESP_MATTER_PATH=/opt/espressif/esp-matter

RUN set -x \
    && git clone --depth 1 https://github.com/espressif/esp-matter.git \
    && cd esp-matter \
    && git submodule update --init --depth 1 \
    && ./connectedhomeip/connectedhomeip/scripts/checkout_submodules.py --platform esp32 --shallow \
    && . $IDF_PATH/export.sh \
    && ./install.sh \
    && : # last line

WORKDIR /opt/espressif/esp-matter
