From 0ab7d57d95da99750c808cac5b500cb2fae2046c Mon Sep 17 00:00:00 2001 From: Pratik raj Date: Sat, 2 Jan 2021 17:12:15 +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 --- UC2_mobile_contribution/broadcaster/service/Dockerfile | 2 +- kubernetes/proxier-service/Dockerfile | 2 +- kubernetes/service/Dockerfile.prereq | 4 ++-- openwhisk/docker/Dockerfile.base | 2 +- openwhisk/docker/Dockerfile.base.18.04 | 2 +- openwhisk/docker/Dockerfile.base.gpu | 2 +- openwhisk/docker/Dockerfile.base.gpu.ds061-cc61 | 2 +- vim-plugin/configuration_service/Dockerfile | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/UC2_mobile_contribution/broadcaster/service/Dockerfile b/UC2_mobile_contribution/broadcaster/service/Dockerfile index 508034d..be10f59 100644 --- a/UC2_mobile_contribution/broadcaster/service/Dockerfile +++ b/UC2_mobile_contribution/broadcaster/service/Dockerfile @@ -8,7 +8,7 @@ RUN apt-get update && apt-get install -y bash \ libc-dev \ python-pip -RUN pip install --upgrade pip setuptools six +RUN pip install --no-cache-dir --upgrade pip setuptools six RUN pip install --no-cache-dir gevent==1.2.1 flask>=1.0.0 requests==2.13.0 kafka-python==1.4.2 pyopenssl RUN openssl req -x509 -nodes -days 365 -newkey rsa:2048 -subj "/C=EU/ST=5gmedia 5gmedia/L=5gmedia /O=5gmedia/OU=5gmedia/CN=5gmedia/emailAddress=5gmedia" -keyout /server.key -out /server.crt diff --git a/kubernetes/proxier-service/Dockerfile b/kubernetes/proxier-service/Dockerfile index e5f86a5..5bde1f4 100644 --- a/kubernetes/proxier-service/Dockerfile +++ b/kubernetes/proxier-service/Dockerfile @@ -1,6 +1,6 @@ FROM docker5gmedia/ow-offload-serverprereqs:0.1 -RUN pip install \ +RUN pip install --no-cache-dir \ kubernetes==10.0.1 RUN mkdir -p /proxyServer diff --git a/kubernetes/service/Dockerfile.prereq b/kubernetes/service/Dockerfile.prereq index 6b4cb22..e9a256a 100644 --- a/kubernetes/service/Dockerfile.prereq +++ b/kubernetes/service/Dockerfile.prereq @@ -7,7 +7,7 @@ RUN apk add --no-cache bash \ bzip2-dev \ gcc \ libc-dev \ - && pip install --upgrade pip setuptools \ + && pip install --no-cache-dir --upgrade pip setuptools \ && pip install --no-cache-dir gevent==1.2.1 flask==0.12 \ && apk del .build-deps @@ -22,7 +22,7 @@ RUN apk add --no-cache \ openssl-dev # Install common modules for python -RUN pip install \ +RUN pip install --no-cache-dir \ beautifulsoup4==4.5.3 \ httplib2==0.10.3 \ kafka_python==1.3.2 \ diff --git a/openwhisk/docker/Dockerfile.base b/openwhisk/docker/Dockerfile.base index db5860f..c995584 100644 --- a/openwhisk/docker/Dockerfile.base +++ b/openwhisk/docker/Dockerfile.base @@ -9,7 +9,7 @@ RUN apt-get update && apt-get install -y bash \ libc-dev \ python-pip -RUN pip install --upgrade pip setuptools six +RUN pip install --no-cache-dir --upgrade pip setuptools six RUN pip install --no-cache-dir gevent==1.2.1 flask==0.12 requests==2.13.0 # Do not modify - this is the internal openwhisk invoker service port diff --git a/openwhisk/docker/Dockerfile.base.18.04 b/openwhisk/docker/Dockerfile.base.18.04 index fb2e683..c5adc2a 100644 --- a/openwhisk/docker/Dockerfile.base.18.04 +++ b/openwhisk/docker/Dockerfile.base.18.04 @@ -9,7 +9,7 @@ RUN apt-get update && apt-get install -y bash \ libc-dev \ python-pip -RUN pip install --upgrade pip setuptools six +RUN pip install --no-cache-dir --upgrade pip setuptools six RUN pip install --no-cache-dir gevent==1.2.1 flask==0.12 requests==2.13.0 # Do not modify - this is the internal openwhisk invoker service port diff --git a/openwhisk/docker/Dockerfile.base.gpu b/openwhisk/docker/Dockerfile.base.gpu index c406b7d..3eb53ad 100644 --- a/openwhisk/docker/Dockerfile.base.gpu +++ b/openwhisk/docker/Dockerfile.base.gpu @@ -9,7 +9,7 @@ RUN apt-get update && apt-get install -y bash \ libc-dev \ python-pip -RUN pip install --upgrade pip setuptools six +RUN pip install --no-cache-dir --upgrade pip setuptools six RUN pip install --no-cache-dir gevent==1.2.1 flask==0.12 requests==2.13.0 # Do not modify - this is the internal openwhisk invoker service port diff --git a/openwhisk/docker/Dockerfile.base.gpu.ds061-cc61 b/openwhisk/docker/Dockerfile.base.gpu.ds061-cc61 index de3918a..75194de 100644 --- a/openwhisk/docker/Dockerfile.base.gpu.ds061-cc61 +++ b/openwhisk/docker/Dockerfile.base.gpu.ds061-cc61 @@ -9,7 +9,7 @@ RUN apt-get update && apt-get install -y bash \ libc-dev \ python-pip -RUN pip install --upgrade pip setuptools six +RUN pip install --no-cache-dir --upgrade pip setuptools six RUN pip install --no-cache-dir gevent==1.2.1 flask==0.12 requests==2.13.0 # Do not modify - this is the internal openwhisk invoker service port diff --git a/vim-plugin/configuration_service/Dockerfile b/vim-plugin/configuration_service/Dockerfile index 1fbcdd9..f2ec96b 100644 --- a/vim-plugin/configuration_service/Dockerfile +++ b/vim-plugin/configuration_service/Dockerfile @@ -8,7 +8,7 @@ RUN apt-get update && apt-get install -y bash \ libc-dev \ python-pip -RUN pip install --upgrade pip setuptools six +RUN pip install --no-cache-dir --upgrade pip setuptools six RUN pip install --no-cache-dir gevent==1.2.1 flask==0.12 requests==2.13.0 ADD faas_configuration_service.py /