From 8a63fd9b22525f684386bc63ecc2d727e1a84000 Mon Sep 17 00:00:00 2001 From: Pratik raj Date: Tue, 29 Dec 2020 18:52:28 +0530 Subject: [PATCH] [docker] 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 --- apps/InfluxdbApp/docker/influxdb-amd64 | 2 +- apps/InfluxdbApp/docker/influxdb-arm | 2 +- apps/InfluxdbApp/docker/influxdbapp-amd64 | 2 +- apps/InfluxdbApp/docker/influxdbapp-arm | 2 +- apps/OrionContextBroker/docker/orioncontextbroker-amd64 | 2 +- apps/OrionContextBroker/docker/orioncontextbroker-arm | 2 +- apps/csvInjector/docker/csvinjector-amd64 | 2 +- apps/csvInjector/docker/csvinjector-arm | 2 +- apps/mqttConnector/docker/mqttconnector-amd64 | 2 +- apps/mqttConnector/docker/mqttconnector-arm | 2 +- create-app-structure | 2 +- docker/backend-amd64 | 2 +- docker/backend-arm | 2 +- docker/gateway-amd64 | 2 +- docker/gateway-arm | 2 +- docker/sdk-amd64 | 4 ++-- docker/sdk-arm | 4 ++-- ipes/CUL868IPE/docker/cul868ipe-amd64 | 2 +- ipes/CUL868IPE/docker/cul868ipe-arm | 2 +- 19 files changed, 21 insertions(+), 21 deletions(-) diff --git a/apps/InfluxdbApp/docker/influxdb-amd64 b/apps/InfluxdbApp/docker/influxdb-amd64 index 1809c0e..8791e5c 100644 --- a/apps/InfluxdbApp/docker/influxdb-amd64 +++ b/apps/InfluxdbApp/docker/influxdb-amd64 @@ -12,7 +12,7 @@ MAINTAINER rst # install openmtc dependencies COPY tmp/$MOD_NAME-dependencies.txt /tmp/requirements.txt -RUN pip install --upgrade --requirement /tmp/requirements.txt +RUN pip install --no-cache-dir --upgrade --requirement /tmp/requirements.txt # install openmtc-influxdb COPY tmp/openmtc-$MOD_NAME.tar.gz /tmp/openmtc-$MOD_NAME.tar.gz diff --git a/apps/InfluxdbApp/docker/influxdb-arm b/apps/InfluxdbApp/docker/influxdb-arm index a2b184b..8ec8fd8 100644 --- a/apps/InfluxdbApp/docker/influxdb-arm +++ b/apps/InfluxdbApp/docker/influxdb-arm @@ -12,7 +12,7 @@ MAINTAINER rst # install openmtc dependencies COPY tmp/$MOD_NAME-dependencies.txt /tmp/requirements.txt -RUN pip install --upgrade --requirement /tmp/requirements.txt +RUN pip install --no-cache-dir --upgrade --requirement /tmp/requirements.txt # install openmtc-influxdb COPY tmp/openmtc-$MOD_NAME.tar.gz /tmp/openmtc-$MOD_NAME.tar.gz diff --git a/apps/InfluxdbApp/docker/influxdbapp-amd64 b/apps/InfluxdbApp/docker/influxdbapp-amd64 index b509058..c95552c 100644 --- a/apps/InfluxdbApp/docker/influxdbapp-amd64 +++ b/apps/InfluxdbApp/docker/influxdbapp-amd64 @@ -12,7 +12,7 @@ MAINTAINER rst # install openmtc dependencies COPY tmp/$MOD_NAME-dependencies.txt /tmp/requirements.txt -RUN pip install --upgrade --requirement /tmp/requirements.txt +RUN pip install --no-cache-dir --upgrade --requirement /tmp/requirements.txt # install openmtc-influxdbapp COPY tmp/openmtc-$MOD_NAME.tar.gz /tmp/openmtc-$MOD_NAME.tar.gz diff --git a/apps/InfluxdbApp/docker/influxdbapp-arm b/apps/InfluxdbApp/docker/influxdbapp-arm index d955b36..e8b1841 100644 --- a/apps/InfluxdbApp/docker/influxdbapp-arm +++ b/apps/InfluxdbApp/docker/influxdbapp-arm @@ -12,7 +12,7 @@ MAINTAINER rst # install openmtc dependencies COPY tmp/$MOD_NAME-dependencies.txt /tmp/requirements.txt -RUN pip install --upgrade --requirement /tmp/requirements.txt +RUN pip install --no-cache-dir --upgrade --requirement /tmp/requirements.txt # install openmtc-influxdbapp COPY tmp/openmtc-$MOD_NAME.tar.gz /tmp/openmtc-$MOD_NAME.tar.gz diff --git a/apps/OrionContextBroker/docker/orioncontextbroker-amd64 b/apps/OrionContextBroker/docker/orioncontextbroker-amd64 index f12c354..990113c 100644 --- a/apps/OrionContextBroker/docker/orioncontextbroker-amd64 +++ b/apps/OrionContextBroker/docker/orioncontextbroker-amd64 @@ -12,7 +12,7 @@ MAINTAINER rst # install openmtc dependencies COPY tmp/$MOD_NAME-dependencies.txt /tmp/requirements.txt -RUN pip install --upgrade --requirement /tmp/requirements.txt +RUN pip install --no-cache-dir --upgrade --requirement /tmp/requirements.txt # install openmtc-orioncontextbroker COPY tmp/openmtc-$MOD_NAME.tar.gz /tmp/openmtc-$MOD_NAME.tar.gz diff --git a/apps/OrionContextBroker/docker/orioncontextbroker-arm b/apps/OrionContextBroker/docker/orioncontextbroker-arm index 115706a..47d3860 100644 --- a/apps/OrionContextBroker/docker/orioncontextbroker-arm +++ b/apps/OrionContextBroker/docker/orioncontextbroker-arm @@ -12,7 +12,7 @@ MAINTAINER rst # install openmtc dependencies COPY tmp/$MOD_NAME-dependencies.txt /tmp/requirements.txt -RUN pip install --upgrade --requirement /tmp/requirements.txt +RUN pip install --no-cache-dir --upgrade --requirement /tmp/requirements.txt # install openmtc-orioncontextbroker COPY tmp/openmtc-$MOD_NAME.tar.gz /tmp/openmtc-$MOD_NAME.tar.gz diff --git a/apps/csvInjector/docker/csvinjector-amd64 b/apps/csvInjector/docker/csvinjector-amd64 index 9a3aba7..cfa1752 100644 --- a/apps/csvInjector/docker/csvinjector-amd64 +++ b/apps/csvInjector/docker/csvinjector-amd64 @@ -12,7 +12,7 @@ MAINTAINER rst # install openmtc dependencies COPY tmp/$MOD_NAME-dependencies.txt /tmp/requirements.txt -RUN pip install --upgrade --requirement /tmp/requirements.txt +RUN pip install --no-cache-dir --upgrade --requirement /tmp/requirements.txt # install openmtc-csvinjector COPY tmp/openmtc-$MOD_NAME.tar.gz /tmp/openmtc-$MOD_NAME.tar.gz diff --git a/apps/csvInjector/docker/csvinjector-arm b/apps/csvInjector/docker/csvinjector-arm index 50a8ef4..8436067 100644 --- a/apps/csvInjector/docker/csvinjector-arm +++ b/apps/csvInjector/docker/csvinjector-arm @@ -12,7 +12,7 @@ MAINTAINER rst # install openmtc dependencies COPY tmp/$MOD_NAME-dependencies.txt /tmp/requirements.txt -RUN pip install --upgrade --requirement /tmp/requirements.txt +RUN pip install --no-cache-dir --upgrade --requirement /tmp/requirements.txt # install openmtc-csvinjector COPY tmp/openmtc-$MOD_NAME.tar.gz /tmp/openmtc-$MOD_NAME.tar.gz diff --git a/apps/mqttConnector/docker/mqttconnector-amd64 b/apps/mqttConnector/docker/mqttconnector-amd64 index 84ea2e4..e95764a 100644 --- a/apps/mqttConnector/docker/mqttconnector-amd64 +++ b/apps/mqttConnector/docker/mqttconnector-amd64 @@ -12,7 +12,7 @@ MAINTAINER rst # install openmtc dependencies COPY tmp/$MOD_NAME-dependencies.txt /tmp/requirements.txt -RUN pip install --upgrade --requirement /tmp/requirements.txt +RUN pip install --no-cache-dir --upgrade --requirement /tmp/requirements.txt # install openmtc-mqttconnector COPY tmp/openmtc-$MOD_NAME.tar.gz /tmp/openmtc-$MOD_NAME.tar.gz diff --git a/apps/mqttConnector/docker/mqttconnector-arm b/apps/mqttConnector/docker/mqttconnector-arm index 0f862ad..e3e3463 100644 --- a/apps/mqttConnector/docker/mqttconnector-arm +++ b/apps/mqttConnector/docker/mqttconnector-arm @@ -12,7 +12,7 @@ MAINTAINER rst # install openmtc dependencies COPY tmp/$MOD_NAME-dependencies.txt /tmp/requirements.txt -RUN pip install --upgrade --requirement /tmp/requirements.txt +RUN pip install --no-cache-dir --upgrade --requirement /tmp/requirements.txt # install openmtc-mqttconnector COPY tmp/openmtc-$MOD_NAME.tar.gz /tmp/openmtc-$MOD_NAME.tar.gz diff --git a/create-app-structure b/create-app-structure index c358681..562116d 100755 --- a/create-app-structure +++ b/create-app-structure @@ -522,7 +522,7 @@ MAINTAINER rst # install openmtc dependencies COPY tmp/\$MOD_NAME-dependencies.txt /tmp/requirements.txt -RUN pip install --upgrade --requirement /tmp/requirements.txt +RUN pip install --no-cache-dir --upgrade --requirement /tmp/requirements.txt # install openmtc-${PKG_NAME} COPY tmp/openmtc-\$MOD_NAME.tar.gz /tmp/openmtc-\$MOD_NAME.tar.gz diff --git a/docker/backend-amd64 b/docker/backend-amd64 index d4085d2..379885a 100644 --- a/docker/backend-amd64 +++ b/docker/backend-amd64 @@ -12,7 +12,7 @@ MAINTAINER rst/tgu # install openmtc dependencies COPY tmp/$MOD_NAME-dependencies.txt /tmp/requirements.txt -RUN pip3 install --upgrade --requirement /tmp/requirements.txt +RUN pip3 install --no-cache-dir --upgrade --requirement /tmp/requirements.txt # install openmtc-all COPY tmp/openmtc-$MOD_NAME.tar.gz /tmp/openmtc-$MOD_NAME.tar.gz diff --git a/docker/backend-arm b/docker/backend-arm index 620ad2b..9415f2b 100644 --- a/docker/backend-arm +++ b/docker/backend-arm @@ -12,7 +12,7 @@ MAINTAINER rst/tgu # install openmtc dependencies COPY tmp/$MOD_NAME-dependencies.txt /tmp/requirements.txt -RUN pip3 install --upgrade --requirement /tmp/requirements.txt +RUN pip3 install --no-cache-dir --upgrade --requirement /tmp/requirements.txt # install openmtc-all COPY tmp/openmtc-$MOD_NAME.tar.gz /tmp/openmtc-$MOD_NAME.tar.gz diff --git a/docker/gateway-amd64 b/docker/gateway-amd64 index e53810a..8253115 100644 --- a/docker/gateway-amd64 +++ b/docker/gateway-amd64 @@ -12,7 +12,7 @@ MAINTAINER rst/tgu # install openmtc dependencies COPY tmp/$MOD_NAME-dependencies.txt /tmp/requirements.txt -RUN pip3 install --upgrade --requirement /tmp/requirements.txt +RUN pip3 install --no-cache-dir --upgrade --requirement /tmp/requirements.txt # install openmtc-all COPY tmp/openmtc-$MOD_NAME.tar.gz /tmp/openmtc-$MOD_NAME.tar.gz diff --git a/docker/gateway-arm b/docker/gateway-arm index 5041d73..465d879 100644 --- a/docker/gateway-arm +++ b/docker/gateway-arm @@ -12,7 +12,7 @@ MAINTAINER rst/tgu # install openmtc dependencies COPY tmp/$MOD_NAME-dependencies.txt /tmp/requirements.txt -RUN pip3 install --upgrade --requirement /tmp/requirements.txt +RUN pip3 install --no-cache-dir --upgrade --requirement /tmp/requirements.txt # install openmtc-all COPY tmp/openmtc-$MOD_NAME.tar.gz /tmp/openmtc-$MOD_NAME.tar.gz diff --git a/docker/sdk-amd64 b/docker/sdk-amd64 index a5a8f0a..4468020 100644 --- a/docker/sdk-amd64 +++ b/docker/sdk-amd64 @@ -11,11 +11,11 @@ ENV MOD_NAME=sdk MAINTAINER rst/tgu # update pip to latest version -RUN pip3 install --upgrade pip +RUN pip3 install --no-cache-dir --upgrade pip # install openmtc dependencies COPY tmp/$MOD_NAME-dependencies.txt /tmp/requirements.txt -RUN pip3 install --upgrade --requirement /tmp/requirements.txt +RUN pip3 install --no-cache-dir --upgrade --requirement /tmp/requirements.txt # install openmtc-sdk COPY tmp/openmtc-$MOD_NAME.tar.gz /tmp/openmtc-$MOD_NAME.tar.gz diff --git a/docker/sdk-arm b/docker/sdk-arm index 19ad23d..176d65f 100644 --- a/docker/sdk-arm +++ b/docker/sdk-arm @@ -11,11 +11,11 @@ ENV MOD_NAME=sdk MAINTAINER rst/tgu # update pip to latest version -RUN pip3 install --upgrade pip setuptools +RUN pip3 install --no-cache-dir --upgrade pip setuptools # install openmtc dependencies COPY tmp/$MOD_NAME-dependencies.txt /tmp/requirements.txt -RUN pip3 install --upgrade --requirement /tmp/requirements.txt +RUN pip3 install --no-cache-dir --upgrade --requirement /tmp/requirements.txt # install openmtc-sdk COPY tmp/openmtc-$MOD_NAME.tar.gz /tmp/openmtc-$MOD_NAME.tar.gz diff --git a/ipes/CUL868IPE/docker/cul868ipe-amd64 b/ipes/CUL868IPE/docker/cul868ipe-amd64 index 0ba70ff..6158cb7 100644 --- a/ipes/CUL868IPE/docker/cul868ipe-amd64 +++ b/ipes/CUL868IPE/docker/cul868ipe-amd64 @@ -12,7 +12,7 @@ MAINTAINER rst # install openmtc dependencies COPY tmp/$MOD_NAME-dependencies.txt /tmp/requirements.txt -RUN pip install --upgrade --requirement /tmp/requirements.txt +RUN pip install --no-cache-dir --upgrade --requirement /tmp/requirements.txt # install openmtc-cul868ipe COPY tmp/openmtc-$MOD_NAME.tar.gz /tmp/openmtc-$MOD_NAME.tar.gz diff --git a/ipes/CUL868IPE/docker/cul868ipe-arm b/ipes/CUL868IPE/docker/cul868ipe-arm index 088b1fa..a890b21 100644 --- a/ipes/CUL868IPE/docker/cul868ipe-arm +++ b/ipes/CUL868IPE/docker/cul868ipe-arm @@ -12,7 +12,7 @@ MAINTAINER rst # install openmtc dependencies COPY tmp/$MOD_NAME-dependencies.txt /tmp/requirements.txt -RUN pip install --upgrade --requirement /tmp/requirements.txt +RUN pip install --no-cache-dir --upgrade --requirement /tmp/requirements.txt # install openmtc-cul868ipe COPY tmp/openmtc-$MOD_NAME.tar.gz /tmp/openmtc-$MOD_NAME.tar.gz