From 4d819a10d5825f9589fa5debd739af2c3a1550fc Mon Sep 17 00:00:00 2001 From: Pratik raj Date: Fri, 11 Dec 2020 10:16:35 +0530 Subject: [PATCH] use `--no-cache-dir` flag to `pip` in dockerfiles to save space using "--no-cache-dir" flag in pip install ,make sure downloaded packages by pip don't cached on system . This is a best practice which make sure to fetch from repo instead of using local cached one . Further , in case of Docker Containers , by restricting caching , we can reduce image size. In term of stats , it depends upon the number of python packages multiplied by their respective size . e.g for heavy packages with a lot of dependencies it reduce a lot by don't caching pip packages. Further , more detail information can be found at https://medium.com/sciforce/strategies-of-docker-images-optimization-2ca9cc5719b6 Signed-off-by: Pratik raj --- applications/openvino/benchmark/Dockerfile | 4 ++-- .../examples/setup_baidu_openedge/composefile/Dockerfile | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/applications/openvino/benchmark/Dockerfile b/applications/openvino/benchmark/Dockerfile index d5fa29ef..eaf15a44 100644 --- a/applications/openvino/benchmark/Dockerfile +++ b/applications/openvino/benchmark/Dockerfile @@ -51,7 +51,7 @@ RUN wget $OPENVINO_LINK && \ rm -rf /tmp/l_openvino_toolkit* && \ ln --symbolic /opt/intel/openvino_"$YEAR"/ /opt/intel/openvino -RUN pip3 install networkx==2.3 +RUN pip3 install --no-cache-dir networkx==2.3 WORKDIR /opt/intel/openvino_$YEAR/deployment_tools/demo RUN /bin/bash -c "source $INSTALL_DIR/bin/setupvars.sh && ./demo_squeezenet_download_convert_run.sh" WORKDIR /root/inference_engine_samples_build @@ -70,7 +70,7 @@ USER openvino #Download OpenVINO pre-trained models WORKDIR /opt/intel/openvino_$YEAR/deployment_tools/open_model_zoo/tools/downloader -RUN pip3 install pyyaml requests +RUN pip3 install --no-cache-dir pyyaml requests RUN ./downloader.py --name face-detection-retail-0004 RUN ./downloader.py --name squeezenet1.1 RUN ./downloader.py --name semantic-segmentation-adas-0001 diff --git a/iot-gateway/baidu-openedge/scripts/ansible/examples/setup_baidu_openedge/composefile/Dockerfile b/iot-gateway/baidu-openedge/scripts/ansible/examples/setup_baidu_openedge/composefile/Dockerfile index 87020a4d..0d29a11b 100644 --- a/iot-gateway/baidu-openedge/scripts/ansible/examples/setup_baidu_openedge/composefile/Dockerfile +++ b/iot-gateway/baidu-openedge/scripts/ansible/examples/setup_baidu_openedge/composefile/Dockerfile @@ -31,7 +31,7 @@ RUN python3.6 get-pip.py # needed by openedge when build RUN apk add --no-cache zip unzip tcpdump -RUN pip3 install protobuf +RUN pip3 install --no-cache-dir protobuf RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime RUN echo 'Asia/Shanghai' >/etc/timezone @@ -45,7 +45,7 @@ RUN apk add --no-cache musl-dev #WORKDIR /root/ # install python pip and grpcio -#RUN pip install protobuf grpcio +#RUN pip install --no-cache-dir protobuf grpcio # install golang RUN apk add --no-cache go bash