From b93c40a3635fbce72e48dc29120e50484cba36ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20THEROND=20=28Fl1nt=29?= Date: Thu, 17 Sep 2020 14:38:21 +0200 Subject: [PATCH] Improve pip install process for offline deployment. * "Use distribution-provided pip" * "Use python's pip module invocation method" * "Install pip earlier in order to avoid multiple installation" * "Remove pip_version variable requirement and call" Change-Id: Id0e738044a1931f9d611a7281a48ea4a593f1cf1 Closes-bug: #1893204 --- docker/base/Dockerfile.j2 | 2 ++ .../elasticsearch-curator/Dockerfile.j2 | 2 +- docker/gnocchi/gnocchi-base/Dockerfile.j2 | 2 +- docker/kolla-toolbox/Dockerfile.j2 | 4 ---- docker/macros.j2 | 13 ++----------- docker/openstack-base/Dockerfile.j2 | 4 ---- .../openvswitch-netcontrold/Dockerfile.j2 | 2 +- 7 files changed, 7 insertions(+), 22 deletions(-) diff --git a/docker/base/Dockerfile.j2 b/docker/base/Dockerfile.j2 index cef4ba6288..55a2e18290 100644 --- a/docker/base/Dockerfile.j2 +++ b/docker/base/Dockerfile.j2 @@ -258,6 +258,7 @@ RUN {{ macros.install_packages(base_centos_yum_repo_packages | customizable("cen 'ncurses', 'procps-ng', 'python3', + 'python3-pip', 'socat', 'sudo', 'tar', @@ -329,6 +330,7 @@ COPY apt_preferences /etc/apt/preferences.d/kolla-custom 'open-iscsi', 'procps', 'python3', + 'python3-pip', 'socat', 'sudo', 'tgt'] diff --git a/docker/elasticsearch/elasticsearch-curator/Dockerfile.j2 b/docker/elasticsearch/elasticsearch-curator/Dockerfile.j2 index e316b5e054..34fef466a5 100644 --- a/docker/elasticsearch/elasticsearch-curator/Dockerfile.j2 +++ b/docker/elasticsearch/elasticsearch-curator/Dockerfile.j2 @@ -29,7 +29,7 @@ LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build 'elasticsearch-curator' ] %} -RUN {{ macros.install_pip(elasticsearch_curator_pip_packages | customizable("pip_packages"), constraints=false, pip_version="pip3") }} \ +RUN {{ macros.install_pip(elasticsearch_curator_pip_packages | customizable("pip_packages"), constraints=false) }} \ && mkdir -p /etc/elasticsearch-curator \ && chown -R elasticsearch: /etc/elasticsearch-curator diff --git a/docker/gnocchi/gnocchi-base/Dockerfile.j2 b/docker/gnocchi/gnocchi-base/Dockerfile.j2 index 200f3ff3d8..91b203dabd 100644 --- a/docker/gnocchi/gnocchi-base/Dockerfile.j2 +++ b/docker/gnocchi/gnocchi-base/Dockerfile.j2 @@ -42,7 +42,7 @@ LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build ] %} {{ macros.install_packages(gnocchi_base_packages | customizable("packages")) }} -RUN {{ macros.install_pip(gnocchi_base_pip_packages | customizable("pip_packages"), constraints=false, pip_version="pip3") }} +RUN {{ macros.install_pip(gnocchi_base_pip_packages | customizable("pip_packages"), constraints=false) }} {% endif %} {% elif install_type == 'source' %} diff --git a/docker/kolla-toolbox/Dockerfile.j2 b/docker/kolla-toolbox/Dockerfile.j2 index 227036c2fe..67052dbb5e 100644 --- a/docker/kolla-toolbox/Dockerfile.j2 +++ b/docker/kolla-toolbox/Dockerfile.j2 @@ -53,10 +53,6 @@ LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build {% endif %} {{ macros.install_packages(kolla_toolbox_packages | customizable("packages")) }} -{% block kolla_toolbox_source_install_python_pip %} -{{ macros.get_pip() }} -{% endblock %} - {% set kolla_toolbox_pip_virtualenv_packages = [ 'virtualenv' ] %} diff --git a/docker/macros.j2 b/docker/macros.j2 index efeac9b818..56dd1414a3 100644 --- a/docker/macros.j2 +++ b/docker/macros.j2 @@ -32,18 +32,9 @@ {% endif %} {%- endmacro %} -{% macro get_pip() %} -RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py \ - && python3 get-pip.py \ - && rm get-pip.py -{% endmacro %} - -{% macro install_pip(packages, constraints = true, pip_version = pip) %} +{% macro install_pip(packages, constraints = true) %} {%- if packages is sequence and packages|length > 0 -%} -{%- if not pip_version -%} - {%- set pip_version = 'pip' -%} -{%- endif -%} - {{ pip_version }} --no-cache-dir install --upgrade{{ ' ' }} + python{{ distro_python_version }} -m pip --no-cache-dir install --upgrade{{ ' ' }} {%- if constraints %}-c /requirements/upper-constraints.txt {% endif -%} {{ packages | join(' ') }} {%- else -%} diff --git a/docker/openstack-base/Dockerfile.j2 b/docker/openstack-base/Dockerfile.j2 index 03d85a3a78..48d4629ba7 100644 --- a/docker/openstack-base/Dockerfile.j2 +++ b/docker/openstack-base/Dockerfile.j2 @@ -196,10 +196,6 @@ ENV DEBIAN_FRONTEND noninteractive {{ macros.install_packages(openstack_base_packages | customizable("packages")) }} -{% block source_install_python_pip %} -{{ macros.get_pip() }} -{% endblock %} - {% set openstack_base_pip_packages = [ 'Babel', 'Mako', diff --git a/docker/openvswitch/openvswitch-netcontrold/Dockerfile.j2 b/docker/openvswitch/openvswitch-netcontrold/Dockerfile.j2 index 510f1ce071..c4be974059 100644 --- a/docker/openvswitch/openvswitch-netcontrold/Dockerfile.j2 +++ b/docker/openvswitch/openvswitch-netcontrold/Dockerfile.j2 @@ -20,7 +20,7 @@ LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build ] %} -RUN {{ macros.install_pip(openvswitch_netcontrold_pip_packages | customizable("pip_packages"), constraints = false, pip_version = "pip3") }} +RUN {{ macros.install_pip(openvswitch_netcontrold_pip_packages | customizable("pip_packages"), constraints = false) }} {% endblock %}