From 9b01155e3ca2626e6ca7416fbf857bcd92a8ad39 Mon Sep 17 00:00:00 2001 From: Pratik Raj Date: Sat, 6 Jun 2020 21:56:53 +0530 Subject: optimize size and time using "--no-cache-dir" 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 Change-Id: I40d9eb94ecea623a9ed54b50b1786b154788a17b --- conductor/conductor/tests/functional/simulators/aafsim/Dockerfile | 4 ++-- conductor/conductor/tests/functional/simulators/aaisim/Dockerfile | 2 +- .../conductor/tests/functional/simulators/multicloudsim/Dockerfile | 2 +- conductor/docker/Dockerfile | 6 +++--- conductor/tox.ini | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) (limited to 'conductor') diff --git a/conductor/conductor/tests/functional/simulators/aafsim/Dockerfile b/conductor/conductor/tests/functional/simulators/aafsim/Dockerfile index eb43a86..0a3ea52 100755 --- a/conductor/conductor/tests/functional/simulators/aafsim/Dockerfile +++ b/conductor/conductor/tests/functional/simulators/aafsim/Dockerfile @@ -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 diff --git a/conductor/conductor/tests/functional/simulators/aaisim/Dockerfile b/conductor/conductor/tests/functional/simulators/aaisim/Dockerfile index 9ab4213..d88a78a 100755 --- a/conductor/conductor/tests/functional/simulators/aaisim/Dockerfile +++ b/conductor/conductor/tests/functional/simulators/aaisim/Dockerfile @@ -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 diff --git a/conductor/conductor/tests/functional/simulators/multicloudsim/Dockerfile b/conductor/conductor/tests/functional/simulators/multicloudsim/Dockerfile index aeaf2b9..19b5d04 100755 --- a/conductor/conductor/tests/functional/simulators/multicloudsim/Dockerfile +++ b/conductor/conductor/tests/functional/simulators/multicloudsim/Dockerfile @@ -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 diff --git a/conductor/docker/Dockerfile b/conductor/docker/Dockerfile index 38afc0e..e20efda 100644 --- a/conductor/docker/Dockerfile +++ b/conductor/docker/Dockerfile @@ -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 diff --git a/conductor/tox.ini b/conductor/tox.ini index a6aa070..e358564 100644 --- a/conductor/tox.ini +++ b/conductor/tox.ini @@ -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 -- cgit 1.2.3-korg