1FROM ubuntu:18.04
2
3ARG DEBIAN_FRONTEND=noninteractive
4
5# We need libpython2.7 due to GDB tools
6RUN apt-get update && apt-get install -y \
7    apt-utils \
8    bison \
9    ca-certificates \
10    ccache \
11    check \
12    curl \
13    flex \
14    git \
15    gperf \
16    lcov \
17    libncurses-dev \
18    libusb-1.0-0-dev \
19    make \
20    ninja-build \
21    libpython2.7 \
22    python3 \
23    python3-pip \
24    unzip \
25    wget \
26    xz-utils \
27    zip \
28   && apt-get autoremove -y \
29   && rm -rf /var/lib/apt/lists/* \
30   && update-alternatives --install /usr/bin/python python /usr/bin/python3 10
31
32RUN python -m pip install --upgrade pip virtualenv
33
34# To build the image for a branch or a tag of IDF, pass --build-arg IDF_CLONE_BRANCH_OR_TAG=name.
35# To build the image with a specific commit ID of IDF, pass --build-arg IDF_CHECKOUT_REF=commit-id.
36# It is possibe to combine both, e.g.:
37#   IDF_CLONE_BRANCH_OR_TAG=release/vX.Y
38#   IDF_CHECKOUT_REF=<some commit on release/vX.Y branch>.
39
40ARG IDF_CLONE_URL=https://github.com/espressif/esp-idf.git
41ARG IDF_CLONE_BRANCH_OR_TAG=master
42ARG IDF_CHECKOUT_REF=
43
44ENV IDF_PATH=/opt/esp/idf
45ENV IDF_TOOLS_PATH=/opt/esp
46
47RUN echo IDF_CHECKOUT_REF=$IDF_CHECKOUT_REF IDF_CLONE_BRANCH_OR_TAG=$IDF_CLONE_BRANCH_OR_TAG && \
48    git clone --recursive \
49      ${IDF_CLONE_BRANCH_OR_TAG:+-b $IDF_CLONE_BRANCH_OR_TAG} \
50      $IDF_CLONE_URL $IDF_PATH && \
51    if [ -n "$IDF_CHECKOUT_REF" ]; then \
52      cd $IDF_PATH && \
53      git checkout $IDF_CHECKOUT_REF && \
54      git submodule update --init --recursive; \
55    fi
56
57# Install all the required tools, plus CMake
58RUN $IDF_PATH/tools/idf_tools.py --non-interactive install required \
59  && $IDF_PATH/tools/idf_tools.py --non-interactive install cmake \
60  && $IDF_PATH/tools/idf_tools.py --non-interactive install-python-env \
61  && rm -rf $IDF_TOOLS_PATH/dist
62
63# Ccache is installed, enable it by default
64ENV IDF_CCACHE_ENABLE=1
65
66COPY entrypoint.sh /opt/esp/entrypoint.sh
67
68ENTRYPOINT [ "/opt/esp/entrypoint.sh" ]
69CMD [ "/bin/bash" ]
70