Allow arbitrary source archive name to be imported into Dockerfile
Currently we cannot import source archives with names different than expected by hardcoded line in Dockerfiles. This worked well for Openstack services' tarballs where we expected SERVICE-* root folder after extraction or kanaka-noVNC for nova-novncproxy docker. The latter fails if one tries to clone or get tarball under other names. This fix allows any archive (tar,tgz,zip) or repo name to be imported into dockerfile. Change-Id: I869a6a19afaf0e93925572746c22b7589b6600c9 Closes-Bug: #1491415
This commit is contained in:
parent
233864ff32
commit
c22cf33268
@ -10,8 +10,8 @@ RUN echo '{{ install_type }} not yet available for {{ base_distro }}' \
|
||||
{% endif %}
|
||||
{% elif install_type == 'source' %}
|
||||
|
||||
ADD ceilometer-base.tar /
|
||||
RUN ln -s /ceilometer-* ceilometer \
|
||||
ADD ceilometer-base-archive /ceilometer-base-source
|
||||
RUN ln -s ceilometer-base-source/* ceilometer \
|
||||
&& useradd --user-group ceilometer \
|
||||
&& pip --no-cache-dir install /ceilometer \
|
||||
&& mkdir -p /etc/ceilometer /var/log/ceilometer /home/ceilometer \
|
||||
|
@ -33,8 +33,8 @@ RUN apt-get install -y --no-install-recommends lvm2 \
|
||||
|
||||
{% endif %}
|
||||
|
||||
ADD cinder-base.tar /
|
||||
RUN ln -s /cinder-* cinder \
|
||||
ADD cinder-base-archive /cinder-base-source
|
||||
RUN ln -s cinder-base-source/* cinder \
|
||||
&& useradd --user-group cinder \
|
||||
&& pip --no-cache-dir install /cinder \
|
||||
&& mkdir -p /etc/cinder /var/log/cinder /home/cinder \
|
||||
|
@ -25,8 +25,8 @@ RUN echo '{{ install_type}} not yet available for {{ base_distro }}' \
|
||||
{% endif %}
|
||||
{% elif install_type == 'source' %}
|
||||
|
||||
ADD designate-base.tar /
|
||||
RUN ln -s /designate-* designate \
|
||||
ADD designate-base-archive /designate-base-source
|
||||
RUN ln -s designate-base-source/* designate \
|
||||
&& useradd --user-group designate \
|
||||
&& pip --no-cache-dir install /designate \
|
||||
&& mkdir -p /etc/designate /var/log/designate /home/designate \
|
||||
|
@ -17,8 +17,8 @@ RUN echo '{{ install_type }} not yet available for {{ base_distro }}' \
|
||||
{% endif %}
|
||||
{% elif install_type == 'source' %}
|
||||
|
||||
ADD glance-base.tar /
|
||||
RUN ln -s /glance-* glance \
|
||||
ADD glance-base-archive /glance-base-source
|
||||
RUN ln -s glance-base-source/* glance \
|
||||
&& useradd --user-group glance \
|
||||
&& pip --no-cache-dir install /glance \
|
||||
&& mkdir -p /etc/glance /var/log/glance /home/glance \
|
||||
|
@ -14,8 +14,8 @@ RUN apt-get install -y --no-install-recommends libpq-dev \
|
||||
|
||||
{% endif %}
|
||||
|
||||
ADD gnocchi-base.tar /
|
||||
RUN ln -s /gnocchi-* gnocchi \
|
||||
ADD gnocchi-base-archive /gnocchi-base-source
|
||||
RUN ln -s gnocchi-base-source/* gnocchi \
|
||||
&& useradd --user-group gnocchi \
|
||||
&& pip --no-cache-dir install /gnocchi \
|
||||
&& mkdir -p /etc/gnocchi /var/log/gnocchi /home/gnocchi \
|
||||
|
@ -16,8 +16,8 @@ RUN echo '{{ install_type }} not yet available for {{ base_distro }}' \
|
||||
{% endif %}
|
||||
{% elif install_type == 'source' %}
|
||||
|
||||
ADD heat-base.tar /
|
||||
RUN ln -s /heat-* heat \
|
||||
ADD heat-base-archive /heat-base-source
|
||||
RUN ln -s heat-base-source/* heat \
|
||||
&& useradd --user-group heat \
|
||||
&& pip --no-cache-dir install /heat \
|
||||
&& mkdir -p /etc/heat /var/log/heat /home/heat \
|
||||
|
@ -50,8 +50,8 @@ RUN apt-get install -y --no-install-recommends \
|
||||
|
||||
{% endif %}
|
||||
|
||||
ADD horizon.tar /
|
||||
RUN ln -s /horizon-* horizon \
|
||||
ADD horizon-archive /horizon-source
|
||||
RUN ln -s horizon-source/* horizon \
|
||||
&& pip --no-cache-dir install /horizon \
|
||||
&& useradd --user-group horizon \
|
||||
&& mkdir -p /etc/openstack-dashboard /home/horizon \
|
||||
|
@ -20,8 +20,8 @@ RUN echo '{{ install_type }} not yet available for {{ base_distro }}' \
|
||||
{% endif %}
|
||||
{% elif install_type == 'source' %}
|
||||
|
||||
ADD ironic-base.tar /
|
||||
RUN ln -s /ironic-* ironic \
|
||||
ADD ironic-base-archive /ironic-base-source
|
||||
RUN ln -s ironic-base-source/* ironic \
|
||||
&& useradd --user-group ironic \
|
||||
&& pip --no-cache-dir install /ironic \
|
||||
&& mkdir -p /etc/ironic /var/log/ironic /home/ironic \
|
||||
|
@ -49,8 +49,8 @@ RUN apt-get install -y --no-install-recommends \
|
||||
|
||||
{% endif %}
|
||||
|
||||
ADD keystone.tar /
|
||||
RUN ln -s /keystone-* keystone \
|
||||
ADD keystone-archive /keystone-source
|
||||
RUN ln -s keystone-source/* keystone \
|
||||
&& useradd --user-group keystone \
|
||||
&& pip --no-cache-dir install /keystone \
|
||||
&& mkdir -p /etc/keystone /var/www/cgi-bin/keystone /var/log/apache2 /home/keystone \
|
||||
|
@ -18,8 +18,8 @@ RUN echo '{{ install_type }} not yet available for {{ base_distro }}' \
|
||||
{% endif %}
|
||||
{% elif install_type == 'source' %}
|
||||
|
||||
ADD magnum-base.tar /
|
||||
RUN ln -s /magnum-* magnum \
|
||||
ADD magnum-base-archive /magnum-base-source
|
||||
RUN ln -s magnum-base-source/* magnum \
|
||||
&& useradd --user-group magnum \
|
||||
&& pip --no-cache-dir install /magnum \
|
||||
&& mkdir -p /etc/magnum /var/log/magnum /home/magnum \
|
||||
|
@ -8,8 +8,8 @@ RUN echo '{{ install_type }} not yet available for {{ base_distro }}' \
|
||||
|
||||
{% elif install_type == 'source' %}
|
||||
|
||||
ADD murano-base.tar /
|
||||
RUN ln -s /murano-* murano \
|
||||
ADD murano-base-archive /murano-base-source
|
||||
RUN ln -s murano-base-source/* murano \
|
||||
&& useradd --user-group murano \
|
||||
&& pip --no-cache-dir install /murano \
|
||||
&& mkdir -p /etc/murano /var/log/murano /home/murano \
|
||||
|
@ -31,8 +31,8 @@ RUN apt-get install -y --no-install-recommends \
|
||||
|
||||
{% endif %}
|
||||
|
||||
ADD neutron-base.tar /
|
||||
RUN ln -s /neutron-* neutron \
|
||||
ADD neutron-base-archive /neutron-base-source
|
||||
RUN ln -s neutron-base-source/* neutron \
|
||||
&& useradd --user-group neutron \
|
||||
&& pip --no-cache-dir install /neutron \
|
||||
&& mkdir -p /etc/neutron /usr/share/neutron /var/log/neutron /home/neutron \
|
||||
|
@ -39,8 +39,8 @@ RUN apt-get install -y --no-install-recommends \
|
||||
|
||||
{% endif %}
|
||||
|
||||
ADD nova-base.tar /
|
||||
RUN ln -s /nova-* nova \
|
||||
ADD nova-base-archive /nova-base-source
|
||||
RUN ln -s nova-base-source/* nova \
|
||||
&& useradd --user-group nova \
|
||||
&& pip --no-cache-dir install /nova \
|
||||
&& mkdir -p /etc/nova /var/log/nova /home/nova \
|
||||
|
@ -12,8 +12,8 @@ RUN yum -y install \
|
||||
{% endif %}
|
||||
{% elif install_type == 'source' %}
|
||||
|
||||
ADD nova-novncproxy.tar /
|
||||
RUN ln -s /kanaka-noVNC-* /usr/share/novnc
|
||||
ADD nova-novncproxy-archive /nova-novncproxy-source
|
||||
RUN ln -s nova-novncproxy-source/* /usr/share/novnc
|
||||
|
||||
{% endif %}
|
||||
|
||||
|
@ -15,8 +15,8 @@ RUN echo '{{ install_type}} not yet available for {{ base_distro }}' \
|
||||
|
||||
{% elif install_type == 'source' %}
|
||||
|
||||
ADD swift-base.tar /
|
||||
RUN ln -s /swift-* swift \
|
||||
ADD swift-base-archive /swift-base-source
|
||||
RUN ln -s swift-base-source/* swift \
|
||||
&& useradd --user-group swift \
|
||||
&& pip --no-cache-dir install /swift \
|
||||
&& mkdir -p /etc/swift /var/log/swift /home/swift \
|
||||
|
@ -14,8 +14,8 @@ RUN echo '{{ install_type }} not yet available for {{ base_distro }}' \
|
||||
{% endif %}
|
||||
{% elif install_type == 'source' %}
|
||||
|
||||
ADD zaqar.tar /
|
||||
RUN ln -s /zaqar-* zaqar \
|
||||
ADD zaqar-archive /zaqar-source
|
||||
RUN ln -s zaqar-source/* zaqar \
|
||||
&& useradd --user-group zaqar \
|
||||
&& pip --no-cache-dir install /zaqar \
|
||||
&& mkdir -p /etc/zaqar /var/log/zaqar /home/zaqar \
|
||||
|
@ -88,27 +88,25 @@ class WorkerThread(Thread):
|
||||
|
||||
def process_source(self, image):
|
||||
source = image['source']
|
||||
dest_dir = image['path']
|
||||
dest_tar = os.path.join(dest_dir, image['name'] + '.tar')
|
||||
dest_archive = os.path.join(image['path'], image['name'] + '-archive')
|
||||
|
||||
if source.get('type') == 'url':
|
||||
LOG.debug("{}:Getting tarball from {}".format(image['name'],
|
||||
LOG.debug("{}:Getting archive from {}".format(image['name'],
|
||||
source['source']))
|
||||
r = requests.get(source['source'])
|
||||
|
||||
if r.status_code == 200:
|
||||
with open(dest_tar, 'wb') as f:
|
||||
with open(dest_archive, 'wb') as f:
|
||||
f.write(r.content)
|
||||
else:
|
||||
LOG.error(
|
||||
'{}:Failed to download tarball: status_code {}'.format(
|
||||
'{}:Failed to download archive: status_code {}'.format(
|
||||
image['name'], r.status_code))
|
||||
image['status'] = "error"
|
||||
return
|
||||
|
||||
elif source.get('type') == 'git':
|
||||
clone_dir = os.path.splitext(dest_tar)[0] + \
|
||||
'-' + source['reference']
|
||||
clone_dir = dest_archive + '-' + source['reference']
|
||||
try:
|
||||
LOG.debug("{}:Cloning from {}".format(image['name'],
|
||||
source['source']))
|
||||
@ -125,7 +123,7 @@ class WorkerThread(Thread):
|
||||
image['status'] = "error"
|
||||
return
|
||||
|
||||
with tarfile.open(dest_tar, 'w') as tar:
|
||||
with tarfile.open(dest_archive, 'w') as tar:
|
||||
tar.add(clone_dir, arcname=os.path.basename(clone_dir))
|
||||
|
||||
else:
|
||||
@ -134,8 +132,8 @@ class WorkerThread(Thread):
|
||||
image['status'] = "error"
|
||||
return
|
||||
|
||||
# Set time on destination tarball to epoch 0
|
||||
os.utime(dest_tar, (0, 0))
|
||||
# Set time on destination archive to epoch 0
|
||||
os.utime(dest_archive, (0, 0))
|
||||
|
||||
def builder(self, image):
|
||||
LOG.debug('{}:Processing'.format(image['name']))
|
||||
|
Loading…
Reference in New Issue
Block a user