optimize size and time using "--no-cache-dir" 64/108864/2
authorPratik Raj <rajpratik71@gmail.com>
Sat, 6 Jun 2020 16:26:53 +0000 (21:56 +0530)
committerkrishna moorthy <krishna.moorthy6@wipro.com>
Sat, 1 Aug 2020 15:40:06 +0000 (15:40 +0000)
Using "--no-cache-dir" flag in pip install ,make sure dowloaded packages
by pip don't cached on system . This is a best practise which make sure
to fetch ftom repo instead of using local cached one . Further , in case
of Docker Containers , by restricing 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: OPTFRA-774

Signed-off-by: Pratik Raj <rajpratik71@gmail.com>
Change-Id: I40d9eb94ecea623a9ed54b50b1786b154788a17b

conductor/conductor/tests/functional/simulators/aafsim/Dockerfile
conductor/conductor/tests/functional/simulators/aaisim/Dockerfile
conductor/conductor/tests/functional/simulators/multicloudsim/Dockerfile
conductor/docker/Dockerfile
conductor/tox.ini
docs/sections/installation.rst
sonar.sh

index eb43a86..0a3ea52 100755 (executable)
@@ -26,8 +26,8 @@ WORKDIR /opt/aafsim
 ADD ./  /opt/aafsim
 
 # Install any needed packages specified in requirements.txt
-RUN pip install web.py
-RUN pip install oslo.log
+RUN pip install --no-cache-dir web.py
+RUN pip install --no-cache-dir oslo.log
 
 # Make port 80 available to the world outside this container
 EXPOSE 8100
index 9ab4213..d88a78a 100755 (executable)
@@ -26,7 +26,7 @@ WORKDIR /opt/aaisim
 ADD ./  /opt/aaisim
 
 # Install any needed packages specified in requirements.txt
-RUN pip install web.py
+RUN pip install --no-cache-dir web.py
 
 # Make port 80 available to the world outside this container
 EXPOSE 8081
index aeaf2b9..19b5d04 100755 (executable)
@@ -26,7 +26,7 @@ WORKDIR /opt/multicloudsim
 ADD ./  /opt/multicloudsim
 
 # Install any needed packages specified in requirements.txt
-RUN pip install web.py
+RUN pip install --no-cache-dir web.py
 
 # Make port 80 available to the world outside this container
 EXPOSE 8082
index 38afc0e..e20efda 100644 (file)
@@ -49,9 +49,9 @@ RUN apk --update add py-setuptools && \
     apk add bash vim && \
     apk add nginx && \
     apk add py2-pip libpq python-dev && \
-    pip install --upgrade pip && \
+    pip install --no-cache-dir --upgrade pip && \
     apk add --virtual build-dependencies build-base linux-headers pcre-dev libffi-dev libxslt-dev libressl-dev && \
-    pip install uwsgi
+    pip install --no-cache-dir uwsgi
 
 # Get, Install, cleanup and setup
 COPY onap-has-tm/optf-has-conductor-${MVN_ARTIFACT_VERSION}.zip /tmp/optf-has.zip
@@ -59,7 +59,7 @@ RUN unzip -q -o -B /tmp/optf-has.zip -d /opt/has && rm -f /tmp/optf-has.zip
 
 #PKG-INFO file must also exists in the conductor folder (i.e. besides and inside the of_has.egg-info folder). The zip file for distro above is missing it
 RUN cp /opt/has/conductor/of_has.egg-info/PKG-INFO /opt/has/conductor
-RUN pip install -e /opt/has/conductor
+RUN pip install --no-cache-dir -e /opt/has/conductor
 COPY app.wsgi /etc/nginx/conductor.wsgi
 COPY api_paste.ini /usr/local/etc/conductor/api_paste.ini
 
index a6aa070..e358564 100644 (file)
@@ -7,7 +7,7 @@ envlist = py3,pep8
 basepython=python3
 deps = -r{toxinidir}/requirements.txt
        -r{toxinidir}/test-requirements.txt
-install_command = pip install -U {opts} {packages}
+install_command = pip install --no-cache-dir -U {opts} {packages}
 usedevelop = True
 setenv = VIRTUAL_ENV={envdir}
          OS_TEST_PATH=conductor/tests/unit
index df7a4c2..c116b8b 100644 (file)
@@ -223,9 +223,9 @@ Once the configuration is in place, installation is simple:
 
 .. code:: bash
 
-    $ pip install of-has
+    $ pip install --no-cache-dir of-has
 
-To upgrade or downgrade, simply re-run ``pip install`` using the
+To upgrade or downgrade, simply re-run ``pip install --no-cache-dir`` using the
 appropriate ``pip`` command line options.
 
 **NOTE**: Be sure proxy settings are in place if they're required to
@@ -251,14 +251,14 @@ directory:
     Receiving objects: 100% (2291/2291), 477.59 KiB | 0 bytes/s, done.
     Resolving deltas: 100% (1422/1422), done.
     $ cd conductor
-    $ pip install .
+    $ pip install --no-cache-dir .
 
 The latest source can be pulled from ONAP at any time and reinstalled:
 
 .. code:: bash
 
     $ git pull
-    $ pip install .
+    $ pip install --no-cache-dir .
 
 Verifying Installation
 ~~~~~~~~~~~~~~~~~~~~~~
index 566ede7..4d17c7c 100755 (executable)
--- a/sonar.sh
+++ b/sonar.sh
@@ -29,8 +29,8 @@ run_tox_test()
     rm -rf ./venv-tox ./.tox
     virtualenv ./venv-tox
     source ./venv-tox/bin/activate
-    pip install --upgrade pip
-    pip install --upgrade tox argparse
+    pip install --no-cache-dir --upgrade pip
+    pip install --no-cache-dir --upgrade tox argparse
     pip freeze
     tox -e cover
     deactivate