From ef6219608da406b48b5d3da9b174db92481d8cd6 Mon Sep 17 00:00:00 2001 From: Pratik Raj Date: Sat, 3 Oct 2020 11:50:27 +0530 Subject: [PATCH] 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 Change-Id: I35b33ea50afce70b687762dba8b18f3f2be60e03 Signed-off-by: Pratik Raj --- cni.Dockerfile | 4 ++-- controller.Dockerfile | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cni.Dockerfile b/cni.Dockerfile index b4e547288..2351da0a1 100644 --- a/cni.Dockerfile +++ b/cni.Dockerfile @@ -18,8 +18,8 @@ RUN yum upgrade -y \ COPY . /opt/kuryr-kubernetes -RUN pip3 install -U pip \ - && python3 -m pip install -c $UPPER_CONSTRAINTS_FILE /opt/kuryr-kubernetes \ +RUN pip3 --no-cache-dir install -U pip \ + && python3 -m pip --no-cache-dir install -c $UPPER_CONSTRAINTS_FILE /opt/kuryr-kubernetes \ && cp /opt/kuryr-kubernetes/cni_ds_init /usr/bin/cni_ds_init \ && mkdir -p /etc/kuryr-cni \ && cp /opt/kuryr-kubernetes/etc/cni/net.d/* /etc/kuryr-cni \ diff --git a/controller.Dockerfile b/controller.Dockerfile index 662eac3c4..feeea36f9 100644 --- a/controller.Dockerfile +++ b/controller.Dockerfile @@ -10,7 +10,7 @@ RUN yum upgrade -y \ COPY . /opt/kuryr-kubernetes -RUN pip3 install -U pip \ +RUN pip3 --no-cache-dir install -U pip \ && python3 -m pip install -c $UPPER_CONSTRAINTS_FILE --no-cache-dir /opt/kuryr-kubernetes \ && yum -y history undo last \ && yum clean all \