diff options
Diffstat (limited to 'kolla')
| -rw-r--r-- | kolla/common/config.py | 8 | ||||
| -rw-r--r-- | kolla/docker/base/Dockerfile.j2 | 6 | ||||
| -rw-r--r-- | kolla/image/kolla_worker.py | 15 | ||||
| -rw-r--r-- | kolla/image/tasks.py | 9 |
4 files changed, 35 insertions, 3 deletions
diff --git a/kolla/common/config.py b/kolla/common/config.py index 245afce50..1915f5c48 100644 --- a/kolla/common/config.py +++ b/kolla/common/config.py @@ -298,6 +298,14 @@ _BASE_OPTS = [ help='Clean all package cache.'), cfg.ListOpt('allowed-to-fail', default=[], help='Images which are allowed to fail'), + cfg.StrOpt('pip_index_url', + help='URL of the primary pip index (sets ARG PIP_INDEX_URL)'), + cfg.StrOpt('pip_trusted_host', + help='Hostname to mark as trusted for pip ' + '(sets ARG PIP_TRUSTED_HOST)'), + cfg.StrOpt('pip_extra_index_url', + help='URL of an extra pip index ' + '(sets ARG PIP_EXTRA_INDEX_URL)'), ] diff --git a/kolla/docker/base/Dockerfile.j2 b/kolla/docker/base/Dockerfile.j2 index 6c1022ece..746f0e731 100644 --- a/kolla/docker/base/Dockerfile.j2 +++ b/kolla/docker/base/Dockerfile.j2 @@ -341,9 +341,9 @@ RUN touch /usr/local/bin/kolla_extend_start \ && rm -f /tmp/kolla_bashrc {% block base_pip_conf %} -# the variables like PIP_INDEX_URL, PIP_EXTRA_INDEX_URL, PIP_TRUSTED_HOST etc. should be defined here. -# ENV PIP_INDEX_URL=https://pypi.python.org/simple -# ENV PIP_TRUSTED_HOST=pypi.python.org +# pip build-time settings (PIP_INDEX_URL, PIP_TRUSTED_HOST, PIP_EXTRA_INDEX_URL) are +# injected as ARG instructions by kolla-build and passed via --build-arg, so they do +# not persist in the final image. Override this block to add further pip configuration. {% endblock %} {{ macros.kolla_patch_sources() }} diff --git a/kolla/image/kolla_worker.py b/kolla/image/kolla_worker.py index 1dc37e2a6..b54e81bea 100644 --- a/kolla/image/kolla_worker.py +++ b/kolla/image/kolla_worker.py @@ -411,6 +411,21 @@ class KollaWorker(object): env.globals.update(self._get_methods()) template = env.get_template(template_name) content = template.render(values, env=os.environ) + pip_args = [ + 'ARG {}'.format(k) + for k, v in ( + ('PIP_INDEX_URL', self.conf.pip_index_url), + ('PIP_TRUSTED_HOST', self.conf.pip_trusted_host), + ('PIP_EXTRA_INDEX_URL', self.conf.pip_extra_index_url), + ) if v + ] + if pip_args: + lines = content.split('\n') + for i, line in enumerate(lines): + if line.startswith('FROM '): + lines[i + 1:i + 1] = pip_args + break + content = '\n'.join(lines) content_path = os.path.join(path, 'Dockerfile') with open(content_path, 'w') as f: LOG.debug("Rendered %s into:", tpl_path) diff --git a/kolla/image/tasks.py b/kolla/image/tasks.py index 9eec24a8f..ba2ade743 100644 --- a/kolla/image/tasks.py +++ b/kolla/image/tasks.py @@ -304,6 +304,15 @@ class BuildTask(EngineTask): if proxy_var in os.environ and proxy_var not in buildargs: buildargs[proxy_var] = os.environ.get(proxy_var) + pip_vars = ( + ('PIP_INDEX_URL', self.conf.pip_index_url), + ('PIP_TRUSTED_HOST', self.conf.pip_trusted_host), + ('PIP_EXTRA_INDEX_URL', self.conf.pip_extra_index_url), + ) + for pip_var, value in pip_vars: + if value and pip_var not in buildargs: + buildargs[pip_var] = value + if not buildargs: return None return buildargs |
