From ea3d7cbf2a87aa51781616fa2363e26db2ccb18c Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Fri, 13 Jul 2018 08:55:37 -0500 Subject: [PATCH] Plumb in pypi mirror config from build host If the build host has pypi mirror configured, we should use it inside of the container builds. Bind-mount build-host pip config. Change-Id: Ib1540dfe3c4172eeb8a70b29becd73a2828b3efb --- pbrx/container_images.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pbrx/container_images.py b/pbrx/container_images.py index d31bc2b..3168294 100755 --- a/pbrx/container_images.py +++ b/pbrx/container_images.py @@ -52,6 +52,14 @@ class ContainerContext(object): def __init__(self, base, volumes): self._base = base self._volumes = volumes or [] + # bind-mount the pip.conf from the host so that any configured + # pypi mirrors will be used inside of the image builds. + if os.path.exists('/etc/pip.conf'): + self._volumes.append('/etc/pip.conf:/etc/pip.conf') + if os.path.exists(os.path.expanduser('~/.config/pip/pip.conf')): + self._volumes.append('{host}:{guest}'.format( + host=os.path.expanduser('~/.config/pip/pip.conf'), + guest='/root/.config/pip/pip.conf')) self.run_id = self.create() self._cont = sh.docker.bake("exec", self.run_id, "sh", "-c")