[docker] use `--no-cache-dir` flag to `pip` in dockerfiles to save space 49/116549/1
authorPratik raj <rajpratik71@gmail.com>
Wed, 30 Dec 2020 17:22:18 +0000 (22:52 +0530)
committerPratik raj <rajpratik71@gmail.com>
Wed, 30 Dec 2020 17:22:18 +0000 (22:52 +0530)
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

Issue-ID: CCSDK-3071
Signed-off-by: Pratik Raj <rajpratik71@gmail.com>
Change-Id: I9c957bda7fbcf631ce9be65bd5bcc41d2c9ada48

ms/command-executor/src/main/docker/Dockerfile
ms/py-executor/docker/Dockerfile

index 8f2f1a7..dcb8afb 100644 (file)
@@ -17,9 +17,8 @@ RUN tar -xzf /source.tar.gz -C /tmp \
 
 VOLUME /opt/app/onap/blueprints/deploy/
 
-RUN python -m pip install --upgrade pip setuptools
-RUN pip install grpcio==1.20.0 grpcio-tools==1.20.0
-RUN pip install virtualenv==16.7.9
+RUN python -m pip install --no-cache-dir --upgrade pip setuptools
+RUN pip install --no-cache-dir grpcio==1.20.0 grpcio-tools==1.20.0 virtualenv==16.7.9
 
 RUN groupadd -r -g 1000 onap && useradd -r -u 1000 -g onap onap
 RUN chown onap:onap /opt -R
index 2fa6996..26f84af 100644 (file)
@@ -17,7 +17,7 @@ RUN tar -xzf /source.tar.gz -C /tmp \
 
 VOLUME /opt/app/onap/blueprints/deploy/
 
-RUN python -m pip install --upgrade pip setuptools
+RUN python -m pip install --no-cache-dir --upgrade pip setuptools
 RUN pip install --no-cache-dir -r /opt/app/onap/python/requirements/docker.txt
 
 RUN groupadd -r -g 1000 onap && useradd -r -u 1000 -g onap onap