From 19136fd4c4b9689b8da70f788f9426c3a242b8a6 Mon Sep 17 00:00:00 2001
From: Swapnil Kulkarni <me@coolsvap.net>
Date: Thu, 16 Jul 2015 08:48:15 +0000
Subject: [PATCH] Add build from source and templating for Zaqar

Co-Authored-By: Steven Dake <stdake@cisco.com>

Change-Id: Ibe8b6ea7941ab3f2fd7dcfcd2ed18fd6111bb270
Partially-implements: blueprint install-from-source
Partially-implements: blueprint dockerfile-template
---
 docker/centos/source/zaqar/.buildinfo         | 10 ++++++
 docker/centos/source/zaqar/Dockerfile         | 20 +++++++++++
 docker/centos/source/zaqar/build              |  1 +
 docker/centos/source/zaqar/config-external.sh |  1 +
 docker/centos/source/zaqar/start.sh           |  1 +
 docker_templates/zaqar/Dockerfile.j2          | 33 +++++++++++++++++++
 docker_templates/zaqar/config-external.sh     |  1 +
 docker_templates/zaqar/start.sh               |  1 +
 8 files changed, 68 insertions(+)
 create mode 100644 docker/centos/source/zaqar/.buildinfo
 create mode 100644 docker/centos/source/zaqar/Dockerfile
 create mode 120000 docker/centos/source/zaqar/build
 create mode 120000 docker/centos/source/zaqar/config-external.sh
 create mode 120000 docker/centos/source/zaqar/start.sh
 create mode 100644 docker_templates/zaqar/Dockerfile.j2
 create mode 120000 docker_templates/zaqar/config-external.sh
 create mode 120000 docker_templates/zaqar/start.sh

diff --git a/docker/centos/source/zaqar/.buildinfo b/docker/centos/source/zaqar/.buildinfo
new file mode 100644
index 0000000000..5f46f8dd70
--- /dev/null
+++ b/docker/centos/source/zaqar/.buildinfo
@@ -0,0 +1,10 @@
+# Build info specific to this image. All values can be overridden in .buildconf
+
+COMPONENT=zaqar
+SOURCE_INSTALL_AVAILABLE=1
+
+# Used for git install method
+: ${CLONE_FROM:=https://github.com/openstack/zaqar}
+
+# Used for curl install method
+: ${TARBALL_URI:=http://tarballs.openstack.org/zaqar/zaqar-master.tar.gz}
diff --git a/docker/centos/source/zaqar/Dockerfile b/docker/centos/source/zaqar/Dockerfile
new file mode 100644
index 0000000000..3fee08aee7
--- /dev/null
+++ b/docker/centos/source/zaqar/Dockerfile
@@ -0,0 +1,20 @@
+FROM %%KOLLA_NAMESPACE%%/%%KOLLA_PREFIX%%base:%%KOLLA_TAG%%
+MAINTAINER Kolla Project (https://launchpad.net/kolla)
+
+ADD ./zaqar.tar /
+RUN ln -s /zaqar-* /zaqar
+
+RUN cd /zaqar \
+    && useradd --user-group zaqar \
+    && pip install -r requirements.txt \
+    && pip install /zaqar \
+    && mkdir /etc/zaqar /var/log/zaqar \
+    && cp -r /zaqar/etc/* /etc/zaqar/ \
+    && rm -rf /root/.cache
+
+
+COPY ./start.sh /start.sh
+
+COPY config-external.sh /opt/kolla/
+
+CMD ["/start.sh"]
diff --git a/docker/centos/source/zaqar/build b/docker/centos/source/zaqar/build
new file mode 120000
index 0000000000..8d652f7ee2
--- /dev/null
+++ b/docker/centos/source/zaqar/build
@@ -0,0 +1 @@
+../../../../tools/build-docker-image
\ No newline at end of file
diff --git a/docker/centos/source/zaqar/config-external.sh b/docker/centos/source/zaqar/config-external.sh
new file mode 120000
index 0000000000..38fff40d1e
--- /dev/null
+++ b/docker/centos/source/zaqar/config-external.sh
@@ -0,0 +1 @@
+../../../common/zaqar/config-external.sh
\ No newline at end of file
diff --git a/docker/centos/source/zaqar/start.sh b/docker/centos/source/zaqar/start.sh
new file mode 120000
index 0000000000..48134a0442
--- /dev/null
+++ b/docker/centos/source/zaqar/start.sh
@@ -0,0 +1 @@
+../../../common/zaqar/start.sh
\ No newline at end of file
diff --git a/docker_templates/zaqar/Dockerfile.j2 b/docker_templates/zaqar/Dockerfile.j2
new file mode 100644
index 0000000000..e312f27ad7
--- /dev/null
+++ b/docker_templates/zaqar/Dockerfile.j2
@@ -0,0 +1,33 @@
+FROM {{ namespace }}/{{ base_distro }}-{{ install_type }}-base:{{ tag }}
+MAINTAINER Kolla Project (https://launchpad.net/kolla)
+
+{% if install_type == 'binary' %}
+    {% if base_distro in ['fedora', 'centos', 'oraclelinux'] %}
+
+RUN yum -y install openstack-zaqar && yum clean all
+
+    {% elif base_distro in ['ubuntu', 'debian'] %}
+
+RUN echo '{{ install_type }} not yet available for {{ base_distro }}' \
+    && /bin/false
+
+{% elif install_type == 'source' %}
+
+ADD ./zaqar.tar /
+RUN ln -s /zaqar-* /zaqar
+
+RUN cd /zaqar \
+    && useradd --user-group zaqar \
+    && pip install -r requirements.txt \
+    && pip install /zaqar \
+    && mkdir /etc/zaqar /var/log/zaqar \
+    && cp -r /zaqar/etc/* /etc/zaqar/ \
+    && rm -rf /root/.cache
+
+{% endif %}
+
+COPY ./start.sh /start.sh
+
+COPY config-external.sh /opt/kolla/
+
+CMD ["/start.sh"]
diff --git a/docker_templates/zaqar/config-external.sh b/docker_templates/zaqar/config-external.sh
new file mode 120000
index 0000000000..412266e051
--- /dev/null
+++ b/docker_templates/zaqar/config-external.sh
@@ -0,0 +1 @@
+../../docker/common/zaqar/config-external.sh
\ No newline at end of file
diff --git a/docker_templates/zaqar/start.sh b/docker_templates/zaqar/start.sh
new file mode 120000
index 0000000000..51966e2712
--- /dev/null
+++ b/docker_templates/zaqar/start.sh
@@ -0,0 +1 @@
+../../docker/common/zaqar/start.sh
\ No newline at end of file
-- 
GitLab