From cd8cf177ad37352938409b8f9f01f8ac9d37bc73 Mon Sep 17 00:00:00 2001 From: Pratik Raj Date: Fri, 14 Jan 2022 16:59:27 +0530 Subject: [PATCH] chore : 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 --- deploy/Dockerfile | 2 +- ftlib/commlib/gloo/Dockerfile | 2 +- ftlib/commlib/nccl/Dockerfile | 2 +- ftlib/commlib/nccl/Dockerfile.cn | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/deploy/Dockerfile b/deploy/Dockerfile index 859bc4f..93dfb88 100644 --- a/deploy/Dockerfile +++ b/deploy/Dockerfile @@ -4,7 +4,7 @@ COPY requirements.txt requirements.txt COPY requirements-dev.txt requirements-dev.txt COPY setup.py setup.py COPY deploy/FindNCCL.cmake /usr/share/cmake-3.10/Modules -RUN pip3 install -r requirements.txt -r requirements-dev.txt +RUN pip3 install --no-cache-dir -r requirements.txt -r requirements-dev.txt COPY ftlib ftlib RUN cd ftlib/consensus/shared_storage/proto/ && bash gen_grpc.sh diff --git a/ftlib/commlib/gloo/Dockerfile b/ftlib/commlib/gloo/Dockerfile index 696c80b..cc20df6 100644 --- a/ftlib/commlib/gloo/Dockerfile +++ b/ftlib/commlib/gloo/Dockerfile @@ -9,7 +9,7 @@ ENV PATH=/root/miniconda3/bin:${PATH} RUN conda init bash && echo "auto_activate_base: true" > ~/.condarc -RUN pip install pytest pybind11==2.4.3 numpy +RUN pip install --no-cache-dir pytest pybind11==2.4.3 numpy RUN wget -O /usr/share/cmake-3.10/Modules/FindNCCL.cmake https://raw.githubusercontent.com/BVLC/caffe/master/cmake/Modules/FindNCCL.cmake diff --git a/ftlib/commlib/nccl/Dockerfile b/ftlib/commlib/nccl/Dockerfile index fc9d2dd..7c12c3a 100644 --- a/ftlib/commlib/nccl/Dockerfile +++ b/ftlib/commlib/nccl/Dockerfile @@ -9,7 +9,7 @@ ENV PATH=/root/miniconda3/bin:${PATH} RUN conda init bash && echo "auto_activate_base: true" > ~/.condarc -RUN pip install pytest pybind11==2.4.3 numpy +RUN pip install --no-cache-dir pytest pybind11==2.4.3 numpy RUN wget -O /usr/share/cmake-3.10/Modules/FindNCCL.cmake https://raw.githubusercontent.com/BVLC/caffe/master/cmake/Modules/FindNCCL.cmake diff --git a/ftlib/commlib/nccl/Dockerfile.cn b/ftlib/commlib/nccl/Dockerfile.cn index d4437e6..1e11047 100644 --- a/ftlib/commlib/nccl/Dockerfile.cn +++ b/ftlib/commlib/nccl/Dockerfile.cn @@ -11,7 +11,7 @@ ENV PATH=/root/miniconda3/bin:${PATH} RUN conda init bash && echo "auto_activate_base: true" > ~/.condarc -RUN pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pytest pybind11==2.4.3 numpy +RUN pip install --no-cache-dir -i https://pypi.tuna.tsinghua.edu.cn/simple pytest pybind11==2.4.3 numpy RUN wget -O /usr/share/cmake-3.10/Modules/FindNCCL.cmake https://raw.githubusercontent.com/BVLC/caffe/master/cmake/Modules/FindNCCL.cmake