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: Ib152ccd75af3b5987ac9729033e4be88cfb88f89 Signed-off-by: Pratik Raj <rajpratik71@gmail.com>
This commit is contained in:
parent
4130a447d4
commit
857cb0fd17
|
@ -270,7 +270,7 @@ Dev install
|
|||
The following playbook will produce a modified image with Python source
|
||||
code installed via pip. To minimize dependencies within the container
|
||||
we generate the sdist locally and then copy it into the resulting
|
||||
container image as an sdist tarball to run pip install locally.
|
||||
container image as an sdist tarball to run pip install --no-cache-dir locally.
|
||||
|
||||
It can be used to pull a review from OpenDev Gerrit:
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ RUN /bin/bash -c 'PKG="$(command -v dnf || command -v yum)"; \
|
|||
if [ $PKG_MGR == "dnf" ]; then $PKG install -y python3-pip; PIP=pip3; else $PKG install -y python-pip; \
|
||||
PIP=pip; fi; \
|
||||
cd /; \
|
||||
for X in $(ls /root/refspec_projects/*.tar.gz); do $PIP install $X; done; \
|
||||
for X in $(ls /root/refspec_projects/*.tar.gz); do $pip install --no-cache-dir $X; done; \
|
||||
rm -Rf /root/refspec_projects'
|
||||
|
||||
USER "{{ original_user }}"
|
||||
|
|
2
tox.ini
2
tox.ini
|
@ -5,7 +5,7 @@ skipdist = True
|
|||
|
||||
[testenv]
|
||||
usedevelop = True
|
||||
install_command = pip install -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt} {opts} {packages}
|
||||
install_command = pip install --no-cache-dir -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt} {opts} {packages}
|
||||
setenv = VIRTUAL_ENV={envdir}
|
||||
passenv =
|
||||
CURL_CA_BUNDLE
|
||||
|
|
Loading…
Reference in New Issue