FROM debian:stretch

RUN apt-get update && apt-get install -yy \
git \
wget \
make \
libncurses-dev \
flex \
bison \
gperf \
python \
python-pip \
python-setuptools \
python-serial \
python-future \
python-cryptography \
python-pyparsing \
python-pyelftools \
cmake \
ninja-build \
g++ \
python-protobuf

RUN mkdir /esp
WORKDIR /esp

RUN wget https://dl.espressif.com/dl/xtensa-esp32-elf-linux64-1.22.0-80-g6c4433a-5.2.0.tar.gz \
-O xtensa-esp32-elf.tar.gz
RUN tar --extract --verbose --file xtensa-esp32-elf.tar.gz && rm xtensa-esp32-elf.tar.gz

RUN git clone --branch v3.2 --depth 1 --recursive https://github.com/espressif/esp-idf.git

ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/esp/xtensa-esp32-elf/bin \
IDF_PATH=/esp/esp-idf

RUN python2.7 -m pip install --user -r $IDF_PATH/requirements.txt