From c5db7dd2c7bc5cad3c0da6aff0b234ec5e2234f3 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Thu, 26 May 2022 01:03:01 +0200 Subject: [PATCH] tools/docker: add IDF_CLONE_SHALLOW and IDF_INSTALL_TARGETS arguments These two arguments can be used to reduce the size of the Docker image: - Setting IDF_CLONE_SHALLOW enables shallow cloning. - Setting IDF_INSTALL_TARGETS to the comma separated list of targets results in toolchains being installed only for these targets. --- tools/docker/Dockerfile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/docker/Dockerfile b/tools/docker/Dockerfile index 4b2872e1d7..376202c0bc 100644 --- a/tools/docker/Dockerfile +++ b/tools/docker/Dockerfile @@ -36,20 +36,26 @@ RUN python -m pip install --upgrade pip virtualenv # It is possibe to combine both, e.g.: # IDF_CLONE_BRANCH_OR_TAG=release/vX.Y # IDF_CHECKOUT_REF=. +# Use IDF_CLONE_SHALLOW=1 to peform shallow clone (i.e. --depth=1 --shallow-submodules) ARG IDF_CLONE_URL=https://github.com/espressif/esp-idf.git ARG IDF_CLONE_BRANCH_OR_TAG=master ARG IDF_CHECKOUT_REF= +ARG IDF_CLONE_SHALLOW= ENV IDF_PATH=/opt/esp/idf ENV IDF_TOOLS_PATH=/opt/esp RUN echo IDF_CHECKOUT_REF=$IDF_CHECKOUT_REF IDF_CLONE_BRANCH_OR_TAG=$IDF_CLONE_BRANCH_OR_TAG && \ git clone --recursive \ + ${IDF_CLONE_SHALLOW:+--depth=1 --shallow-submodules} \ ${IDF_CLONE_BRANCH_OR_TAG:+-b $IDF_CLONE_BRANCH_OR_TAG} \ $IDF_CLONE_URL $IDF_PATH && \ if [ -n "$IDF_CHECKOUT_REF" ]; then \ cd $IDF_PATH && \ + if [ -n "$IDF_CLONE_SHALLOW" ]; then \ + git fetch origin --depth=1 --recurse-submodules ${IDF_CHECKOUT_REF}; \ + fi && \ git checkout $IDF_CHECKOUT_REF && \ git submodule update --init --recursive; \ fi