optimize size and time using "--no-cache-dir" 60/108860/1
authorPratik Raj <rajpratik71@gmail.com>
Sat, 6 Jun 2020 16:19:55 +0000 (21:49 +0530)
committerPratik Raj <rajpratik71@gmail.com>
Sat, 6 Jun 2020 16:23:36 +0000 (21:53 +0530)
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: CLAMP-861

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

README.md
extra/docker/clamp/docker-compose.yml
src/test/resources/http-cache/start_http_cache.sh

index abf41d5..031c0e8 100644 (file)
--- a/README.md
+++ b/README.md
@@ -206,7 +206,7 @@ In that case, the credentials should be specified in `src/main/resources/clds/cl
 
 Passwords should be hashed using Bcrypt :
 ```
-# pip3 install bcrypt  # if you don't have the bcrypt python lib installed, should be done once.
+# pip3 install --no-cache-dir bcrypt  # if you don't have the bcrypt python lib installed, should be done once.
 # python3 -c 'import bcrypt; print(bcrypt.hashpw("password".encode(), bcrypt.gensalt(rounds=10, prefix=b"2a")))'
 ```
 
index 8d57be0..81cac25 100644 (file)
@@ -35,4 +35,4 @@ services:
       - "../../../src/test/resources/http-cache/:/script/:ro"
     ports:
       - "8085:8085"
-    command: /bin/sh -c "pip install requests &&  pip install simplejson && python -u /script/third_party_proxy.py -v true --port 8085 --root /thirdparty --proxyaddress third-party-proxy:8085"
+    command: /bin/sh -c "pip install --no-cache-dir requests &&  pip install --no-cache-dir simplejson && python -u /script/third_party_proxy.py -v true --port 8085 --root /thirdparty --proxyaddress third-party-proxy:8085"
index 178ac80..1f84b56 100755 (executable)
@@ -47,6 +47,6 @@ esac
 done
 
 echo 'Installing requests packages for Python'
-pip install requests
+pip install --no-cache-dir requests
 echo 'Executing the Http proxy in Cache mode only'
 python -u third_party_proxy.py --port 8080 --root /usr/src/http-cache-app/data-cache $python_proxyaddress