From a2c0087b3842c00e27440e69abc3c57125a50cc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Andr=C3=A9?= Date: Tue, 2 May 2017 15:14:36 +0200 Subject: [PATCH] Add Apache packages to zaqar container Some projects that use Kolla docker containers (TripleO) run zaqar under httpd. This patch adds the httpd package so that it exists in the container and can optionally by used via Docker entrypoints. As many of these projects do not require the use of Apache (it is opt-in) at this point not all deployment frameworks support the use of it so the existing configuration defaults have been left as-is for now. Change-Id: I35cfd1c2320eb972890b44668c8f9f0a047a65dc Partially-Implements: blueprint apache-packages-for-apis --- docker/zaqar/Dockerfile.j2 | 49 ++++++++++++++++++++++++++++++------ docker/zaqar/extend_start.sh | 13 ++++++++++ 2 files changed, 54 insertions(+), 8 deletions(-) diff --git a/docker/zaqar/Dockerfile.j2 b/docker/zaqar/Dockerfile.j2 index b17ffdd083..eeac2eef1f 100755 --- a/docker/zaqar/Dockerfile.j2 +++ b/docker/zaqar/Dockerfile.j2 @@ -9,17 +9,50 @@ LABEL maintainer="{{ maintainer }}" {% if install_type == 'binary' %} - {% if base_distro in ['centos', 'oraclelinux', 'rhel'] %} - {% set zaqar_packages = ['openstack-zaqar'] %} - {% elif base_distro in ['debian', 'ubuntu'] %} - {% set zaqar_packages = [ - 'zaqar-common', - 'zaqar-server' - ] %} - {% endif %} +{% if base_distro in ['centos', 'oraclelinux', 'rhel'] %} + {% set zaqar_packages = [ + 'httpd', + 'mod_ssl', + 'mod_wsgi', + 'openstack-zaqar' + ] %} {{ macros.install_packages(zaqar_packages | customizable("packages")) }} +RUN sed -i -r 's,^(Listen 80),#\1,' /etc/httpd/conf/httpd.conf \ + && sed -i -r 's,^(Listen 443),#\1,' /etc/httpd/conf.d/ssl.conf +{% elif base_distro in ['debian', 'ubuntu'] %} + {% set zaqar_packages = [ + 'apache2', + 'libapache2-mod-wsgi' + 'zaqar-common', + 'zaqar-server' + ] %} +{{ macros.install_packages(zaqar_packages | customizable("packages")) }} +RUN echo > /etc/apache2/ports.conf +{% endif %} {% elif install_type == 'source' %} +{% if base_distro in ['centos', 'oraclelinux', 'rhel'] %} + + {% set zaqar_packages = [ + 'httpd', + 'mod_ssl', + 'mod_wsgi' + ] %} +{{ macros.install_packages(zaqar_packages | customizable("packages")) }} +RUN sed -i -r 's,^(Listen 80),#\1,' /etc/httpd/conf/httpd.conf \ + && sed -i -r 's,^(Listen 443),#\1,' /etc/httpd/conf.d/ssl.conf + +{% elif base_distro in ['debian', 'ubuntu'] %} + + {% set zaqar_packages = [ + 'apache2', + 'libapache2-mod-wsgi' + ] %} + +{{ macros.install_packages(zaqar_packages | customizable("packages")) }} +RUN echo > /etc/apache2/ports.conf +{% endif %} + ADD zaqar-archive /zaqar-source {% set zaqar_pip_packages = [ diff --git a/docker/zaqar/extend_start.sh b/docker/zaqar/extend_start.sh index b7ce7bb04d..e0fb2142ec 100755 --- a/docker/zaqar/extend_start.sh +++ b/docker/zaqar/extend_start.sh @@ -6,3 +6,16 @@ fi if [[ $(stat -c %a /var/log/kolla/zaqar) != "755" ]]; then chmod 755 /var/log/kolla/zaqar fi + +# Assume the service runs on top of Apache when user is root +if [[ $USER == 'root' ]]; then + # 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 + . /etc/apache2/envvars + rm -rf /var/run/apache2/* + else + rm -rf /var/run/httpd/* /run/httpd/* /tmp/httpd* + fi +fi