FROM ubuntu:25.10
LABEL maintainer="Krzysztof Lewandowski <krzysiek@supla.org>"

# Install required packages
RUN apt update && \
    DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt install -y tzdata && \
    apt install -y git wget flex bison gperf python3 python3-pip \
        python3-setuptools cmake ninja-build ccache libffi-dev libssl-dev \
        dfu-util libusb-1.0-0 python-is-python3 gcc make libncurses-dev \
        python3-venv

# Setup workdir
RUN mkdir supla
WORKDIR /supla

# Download and install espressif toolset and esp-idf
RUN mkdir esp && \
    cd esp && \
    git clone -b v6.0.2 --recursive https://github.com/espressif/esp-idf.git esp-idf && \
    cd esp-idf && \
    ./install.sh all

# Download supla-device
RUN git clone --recursive https://github.com/SUPLA/supla-device.git && \
      mkdir projects
WORKDIR /supla/projects

ENV SUPLA_DEVICE_PATH="/supla/supla-device"
ENV ESP_TOOLSET="esp32"
RUN echo "source /supla/esp/esp-idf/export.sh" >> ~/.bashrc

