From fabb22d50533b8c8ef09bbf22e9fe34637082aa0 Mon Sep 17 00:00:00 2001 From: zhubingbing <1392607554@qq.com> Date: Mon, 17 Oct 2016 15:54:00 +0800 Subject: [PATCH] add panko dockerfile Change-Id: Ibf74db39348dfb6f56f4fca0aff142a75ef53d38 Partially-Implements: blueprint add-panko --- docker/panko/panko-api/Dockerfile.j2 | 25 +++++++ docker/panko/panko-api/extend_start.sh | 18 +++++ docker/panko/panko-base/Dockerfile.j2 | 69 +++++++++++++++++++ docker/panko/panko-base/extend_start.sh | 10 +++ kolla/common/config.py | 10 ++- ...add-panko-dockerfile-ff69a745aca3ec15.yaml | 3 + tests/test_build.py | 3 +- 7 files changed, 134 insertions(+), 4 deletions(-) create mode 100644 docker/panko/panko-api/Dockerfile.j2 create mode 100644 docker/panko/panko-api/extend_start.sh create mode 100644 docker/panko/panko-base/Dockerfile.j2 create mode 100644 docker/panko/panko-base/extend_start.sh create mode 100644 releasenotes/notes/add-panko-dockerfile-ff69a745aca3ec15.yaml diff --git a/docker/panko/panko-api/Dockerfile.j2 b/docker/panko/panko-api/Dockerfile.j2 new file mode 100644 index 0000000000..0ef0de233c --- /dev/null +++ b/docker/panko/panko-api/Dockerfile.j2 @@ -0,0 +1,25 @@ +FROM {{ namespace }}/{{ image_prefix }}panko-base:{{ tag }} +MAINTAINER {{ maintainer }} + +{% block panko_api_header %}{% endblock %} + +{% import "macros.j2" as macros with context %} + +{% if install_type == 'binary' %} + {% if base_distro in ['centos', 'oraclelinux', 'rhel'] %} + {% set panko_api_packages = ['openstack-panko-api'] %} + {% elif base_distro in ['ubuntu'] %} + +RUN echo '{{ install_type }} not yet available for {{ base_distro }}' \ + && /bin/false + + {% endif %} +{{ macros.install_packages(panko_api_packages | customizable("packages")) }} +{% endif %} + +COPY extend_start.sh /usr/local/bin/kolla_panko_extend_start +RUN chmod 755 /usr/local/bin/kolla_panko_extend_start + +{% block panko_api_footer %}{% endblock %} +{% block footer %}{% endblock %} +{{ include_footer }} diff --git a/docker/panko/panko-api/extend_start.sh b/docker/panko/panko-api/extend_start.sh new file mode 100644 index 0000000000..cf3cc3bd46 --- /dev/null +++ b/docker/panko/panko-api/extend_start.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +# NOTE(pbourke): httpd will not clean up after itself in some cases which +# results in the container not being able to restart. (bug #1489676, 1557036) +if [[ "${KOLLA_BASE_DISTRO}" =~ debian|ubuntu ]]; then + # Loading Apache2 ENV variables + source /etc/apache2/envvars + rm -rf /var/run/apache2/* +else + rm -rf /var/run/httpd/* /run/httpd/* /tmp/httpd* +fi + +# Bootstrap and exit if KOLLA_BOOTSTRAP variable is set. This catches all cases +# of the KOLLA_BOOTSTRAP variable being set, including empty. +if [[ "${!KOLLA_BOOTSTRAP[@]}" ]]; then + panko-dbsync + exit 0 +fi diff --git a/docker/panko/panko-base/Dockerfile.j2 b/docker/panko/panko-base/Dockerfile.j2 new file mode 100644 index 0000000000..98c95fc740 --- /dev/null +++ b/docker/panko/panko-base/Dockerfile.j2 @@ -0,0 +1,69 @@ +FROM {{ namespace }}/{{ image_prefix }}openstack-base:{{ tag }} +MAINTAINER {{ maintainer }} + +{% block panko_base_header %}{% endblock %} + +{% import "macros.j2" as macros with context %} + +{% if install_type == 'binary' %} + {% if base_distro in ['centos', 'oraclelinux', 'rhel'] %} + + {% set panko_base_packages = [ + 'openstack-panko-common', + 'httpd', + 'mod_wsgi', + 'python-ldappool' + ] %} + +{{ macros.install_packages(panko_base_packages | customizable("packages")) }} +RUN sed -i -r 's,^(Listen 80),#\1,' /etc/httpd/conf/httpd.conf + {% elif base_distro in ['ubuntu', 'debian'] %} + +RUN echo '{{ install_type }} not yet available for {{ base_distro }}' \ + && /bin/false + + {% endif %} +{% elif install_type == 'source' %} + {% if base_distro in ['centos', 'oraclelinux', 'rhel'] %} + + {% set panko_base_packages = [ + 'httpd', + 'mod_wsgi', + 'python-ldappool' + ] %} +{{ macros.install_packages(panko_base_packages | customizable("packages")) }} +RUN sed -i -r 's,^(Listen 80),#\1,' /etc/httpd/conf/httpd.conf + + {% elif base_distro in ['ubuntu', 'debian'] %} + + {% set panko_base_packages = [ + 'apache2', + 'libapache2-mod-wsgi', + 'python-ldappool' + ] %} + +{{ macros.install_packages(panko_base_packages | customizable("packages")) }} +RUN truncate -s 0 /etc/apache2/ports.conf + + {% endif %} + +ADD panko-base-archive /panko-base-source + +RUN ln -s panko-base-source/* panko \ + && useradd --user-group panko \ + && /var/lib/kolla/venv/bin/pip --no-cache-dir install --upgrade -c requirements/upper-constraints.txt \ + && mkdir -p /etc/panko /home/panko \ + && cp -r /panko/etc/panko/* /etc/panko/ \ + && chown -R panko: /etc/panko /home/panko + +{% endif %} + +COPY extend_start.sh /usr/local/bin/kolla_extend_start + +RUN usermod -a -G kolla panko \ + && mkdir -p /var/lib/panko \ + && chown -R panko: /var/lib/panko \ + && touch /usr/local/bin/kolla_panko_extend_start \ + && chmod 755 /usr/local/bin/kolla_extend_start /usr/local/bin/kolla_panko_extend_start + +{% block panko_base_footer %}{% endblock %} diff --git a/docker/panko/panko-base/extend_start.sh b/docker/panko/panko-base/extend_start.sh new file mode 100644 index 0000000000..6d8061ddcf --- /dev/null +++ b/docker/panko/panko-base/extend_start.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +if [[ ! -d "/var/log/kolla/panko" ]]; then + mkdir -p /var/log/kolla/panko +fi +if [[ $(stat -c %a /var/log/kolla/panko) != "755" ]]; then + chmod 755 /var/log/kolla/panko +fi + +. /usr/local/bin/kolla_panko_extend_start diff --git a/kolla/common/config.py b/kolla/common/config.py index 5cb64c7885..00e70a5d00 100644 --- a/kolla/common/config.py +++ b/kolla/common/config.py @@ -47,9 +47,9 @@ _PROFILE_OPTS = [ cfg.ListOpt('aux', default=['aodh', 'cloudkitty', 'congress', 'designate', 'gnocchi', 'influxdb', 'ironic', 'kuryr', 'magnum', - 'manila', 'mistral', 'murano', 'rally', 'sahara', - 'searchlight', 'senlin', 'solum', 'telegraf', 'trove', - 'zaqar'], + 'manila', 'mistral', 'murano', 'panko', 'rally', + 'sahara', 'searchlight', 'senlin', 'solum', + 'telegraf', 'trove', 'zaqar'], help='Aux Images'), cfg.ListOpt('default', default=['chrony', 'cron', 'kolla-toolbox', 'glance', @@ -282,6 +282,10 @@ SOURCES = { 'type': 'url', 'location': ('http://github.com/kanaka/noVNC/tarball/' 'v0.5.1')}, + 'panko-base': { + 'type': 'url', + 'location': ('http://tarballs.openstack.org/panko/' + 'panko-master.tar.gz')}, 'rally': { 'type': 'url', 'location': ('http://tarballs.openstack.org/rally/' diff --git a/releasenotes/notes/add-panko-dockerfile-ff69a745aca3ec15.yaml b/releasenotes/notes/add-panko-dockerfile-ff69a745aca3ec15.yaml new file mode 100644 index 0000000000..f02b45e199 --- /dev/null +++ b/releasenotes/notes/add-panko-dockerfile-ff69a745aca3ec15.yaml @@ -0,0 +1,3 @@ +--- +features: + - Add Panko dockerfile, Panko is a component of the Telemetry project diff --git a/tests/test_build.py b/tests/test_build.py index 431137c7df..8b240c017b 100644 --- a/tests/test_build.py +++ b/tests/test_build.py @@ -105,7 +105,8 @@ class BuildTestUbuntuBinary(BuildTest, base.BaseTestCase): "congress-base", "bifrost-base", "cloudkitty-base", - "freezer-base"] + "freezer-base", + "panko-base"] def setUp(self): super(BuildTestUbuntuBinary, self).setUp()