|
| 1 | +FROM ubuntu:22.04 |
| 2 | + |
| 3 | +# switch to root, let the entrypoint drop back to host user |
| 4 | +USER root |
| 5 | + |
| 6 | +ARG DEBIAN_FRONTEND=noninteractive |
| 7 | + |
| 8 | +RUN : \ |
| 9 | + && apt-get update \ |
| 10 | + && apt-get install -y --no-install-recommends \ |
| 11 | + bison \ |
| 12 | + ccache \ |
| 13 | + cmake \ |
| 14 | + curl \ |
| 15 | + flex \ |
| 16 | + git \ |
| 17 | + gperf \ |
| 18 | + jq \ |
| 19 | + libncurses-dev \ |
| 20 | + libssl-dev \ |
| 21 | + libusb-1.0 \ |
| 22 | + ninja-build \ |
| 23 | + patch \ |
| 24 | + python3 \ |
| 25 | + python3-click \ |
| 26 | + python3-cryptography \ |
| 27 | + python3-future \ |
| 28 | + python3-pip \ |
| 29 | + python3-pyelftools \ |
| 30 | + python3-pyparsing \ |
| 31 | + python3-serial \ |
| 32 | + python3-setuptools \ |
| 33 | + python3-textual \ |
| 34 | + python3-venv \ |
| 35 | + wget \ |
| 36 | + && pip install --upgrade pip \ |
| 37 | + && apt-get autoremove -y \ |
| 38 | + && rm -rf /var/lib/apt/lists/* \ |
| 39 | + && : |
| 40 | + |
| 41 | +# install gosu for a better su+exec command |
| 42 | +ARG GOSU_VERSION=1.17 |
| 43 | +RUN dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')" \ |
| 44 | + && wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch" \ |
| 45 | + && chmod +x /usr/local/bin/gosu \ |
| 46 | + && gosu nobody true |
| 47 | + |
| 48 | +# To build the image for a branch or a tag of the lib-builder, pass --build-arg LIBBUILDER_CLONE_BRANCH_OR_TAG=name. |
| 49 | +# To build the image with a specific commit ID of lib-builder, pass --build-arg LIBBUILDER_CHECKOUT_REF=commit-id. |
| 50 | +# It is possibe to combine both, e.g.: |
| 51 | +# LIBBUILDER_CLONE_BRANCH_OR_TAG=release/vX.Y |
| 52 | +# LIBBUILDER_CHECKOUT_REF=<some commit on release/vX.Y branch>. |
| 53 | +# Use LIBBUILDER_CLONE_SHALLOW=1 to peform shallow clone (i.e. --depth=1 --shallow-submodules) |
| 54 | +# Use LIBBUILDER_CLONE_SHALLOW_DEPTH=X to define the depth if LIBBUILDER_CLONE_SHALLOW is used (i.e. --depth=X) |
| 55 | + |
| 56 | +ARG LIBBUILDER_CLONE_URL=https://github.com/espressif/esp32-arduino-lib-builder |
| 57 | +ARG LIBBUILDER_CLONE_BRANCH_OR_TAG=master |
| 58 | +ARG LIBBUILDER_CHECKOUT_REF= |
| 59 | +ARG LIBBUILDER_CLONE_SHALLOW= |
| 60 | +ARG LIBBUILDER_CLONE_SHALLOW_DEPTH=1 |
| 61 | +ARG LIBBUILDER_TARGETS=all |
| 62 | + |
| 63 | +ENV LIBBUILDER_PATH=/opt/esp/lib-builder |
| 64 | +ENV ARDUINO_PATH=/opt/esp/lib-builder/arduino-esp32 |
| 65 | +# Ccache is installed, enable it by default |
| 66 | +ENV IDF_CCACHE_ENABLE=1 |
| 67 | + |
| 68 | +RUN echo LIBBUILDER_CHECKOUT_REF=$LIBBUILDER_CHECKOUT_REF LIBBUILDER_CLONE_BRANCH_OR_TAG=$LIBBUILDER_CLONE_BRANCH_OR_TAG && \ |
| 69 | + git clone --recursive \ |
| 70 | + ${LIBBUILDER_CLONE_SHALLOW:+--depth=${LIBBUILDER_CLONE_SHALLOW_DEPTH} --shallow-submodules} \ |
| 71 | + ${LIBBUILDER_CLONE_BRANCH_OR_TAG:+-b $LIBBUILDER_CLONE_BRANCH_OR_TAG} \ |
| 72 | + $LIBBUILDER_CLONE_URL $LIBBUILDER_PATH && \ |
| 73 | + git config --system --add safe.directory $LIBBUILDER_PATH && \ |
| 74 | + if [ -n "$LIBBUILDER_CHECKOUT_REF" ]; then \ |
| 75 | + cd $LIBBUILDER_PATH && \ |
| 76 | + if [ -n "$LIBBUILDER_CLONE_SHALLOW" ]; then \ |
| 77 | + git fetch origin --depth=${LIBBUILDER_CLONE_SHALLOW_DEPTH} --recurse-submodules ${LIBBUILDER_CHECKOUT_REF}; \ |
| 78 | + fi && \ |
| 79 | + git checkout $LIBBUILDER_CHECKOUT_REF && \ |
| 80 | + git submodule update --init --recursive; \ |
| 81 | + fi |
| 82 | + |
| 83 | +COPY entrypoint.sh $LIBBUILDER_PATH/entrypoint.sh |
| 84 | + |
| 85 | +WORKDIR /opt/esp/lib-builder |
| 86 | +ENTRYPOINT [ "/opt/esp/lib-builder/entrypoint.sh" ] |
| 87 | +CMD [ "bash" ] |
0 commit comments