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: I3a407658f0c472c740911d53c46f834a718429ee
Signed-off-by: Pratik Raj <rajpratik71@gmail.com>
This commit is contained in:
Pratik Raj 2020-06-18 15:22:10 +05:30
parent cb7643daef
commit 5269f1c4ba
No known key found for this signature in database
GPG Key ID: 593B9C33F6A71FC3
2 changed files with 2 additions and 2 deletions

View File

@ -106,7 +106,7 @@ constraint = '-c https://opendev.org/openstack/requirements/raw/branch/stable/tr
execute 'install tempest' do
action :nothing
command "#{venv_path}/bin/pip install #{constraint} tempest==#{tempest_ver}"
command "#{venv_path}/bin/pip install --no-cache-dir #{constraint} tempest==#{tempest_ver}"
cwd tempest_path
end

View File

@ -93,7 +93,7 @@ describe 'openstack-integration-test::setup' do
it do
expect(chef_run).to nothing_execute('install tempest')
.with(
command: '/opt/tempest-venv/bin/pip install -c https://opendev.org/openstack/requirements/raw/branch/stable/train/upper-constraints.txt tempest==22.1.0',
command: '/opt/tempest-venv/bin/pip install --no-cache-dir -c https://opendev.org/openstack/requirements/raw/branch/stable/train/upper-constraints.txt tempest==22.1.0',
cwd: '/opt/tempest'
)
end