diff --git a/docker/manila/manila-api/Dockerfile.j2 b/docker/manila/manila-api/Dockerfile.j2 index a7be7444d7..9ff1102830 100644 --- a/docker/manila/manila-api/Dockerfile.j2 +++ b/docker/manila/manila-api/Dockerfile.j2 @@ -6,19 +6,62 @@ LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build {% import "macros.j2" as macros with context %} {% if install_type == 'binary' %} - {% if base_distro in ['debian', 'ubuntu'] %} - + {% if base_distro in ['centos', 'oraclelinux', 'rhel'] %} {% set manila_api_packages = [ + 'httpd', + 'mod_ssl', + 'mod_wsgi' + ] %} +{{ macros.install_packages(manila_api_packages | customizable("packages")) }} +RUN mkdir -p /var/www/cgi-bin/manila \ + && cp -a /usr/bin/manila-wsgi /var/www/cgi-bin/manila/manila-wsgi \ + && 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 manila_api_packages = [ + 'apache2', + 'libapache2-mod-wsgi', 'manila-api' ] %} - {{ macros.install_packages(manila_api_packages | customizable("packages")) }} +RUN mkdir -p /var/www/cgi-bin/manila \ + && cp -a /usr/bin/manila-wsgi /var/www/cgi-bin/manila/manila-wsgi \ + && echo > /etc/apache2/ports.conf + {% endif %} - {% endif%} -{% endif%} + +{% elif install_type == 'source' %} + + {% if base_distro in ['centos', 'oraclelinux', 'rhel'] %} + {% set manila_api_packages = [ + 'httpd', + 'mod_ssl', + 'mod_wsgi' + ] %} +{{ macros.install_packages(manila_api_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 manila_api_packages = [ + 'apache2', + 'libapache2-mod-wsgi' + ] %} +{{ macros.install_packages(manila_api_packages | customizable("packages")) }} +RUN echo > /etc/apache2/ports.conf + + {% endif %} + +RUN mkdir -p /var/www/cgi-bin/manila \ + && cp -a /var/lib/kolla/venv/bin/manila-wsgi /var/www/cgi-bin/manila/manila-wsgi + +{% endif %} COPY extend_start.sh /usr/local/bin/kolla_manila_extend_start -RUN chmod 755 /usr/local/bin/kolla_manila_extend_start +RUN chmod 755 /usr/local/bin/kolla_manila_extend_start \ + && chown -R manila: /var/www/cgi-bin/manila \ + && chmod 755 /var/www/cgi-bin/manila/manila-wsgi {% block manila_api_footer %}{% endblock %} {% block footer %}{% endblock %} diff --git a/docker/manila/manila-api/extend_start.sh b/docker/manila/manila-api/extend_start.sh index bea77dbba4..3e5347ac5b 100644 --- a/docker/manila/manila-api/extend_start.sh +++ b/docker/manila/manila-api/extend_start.sh @@ -7,3 +7,16 @@ if [[ "${!KOLLA_BOOTSTRAP[@]}" ]]; then manila-manage db sync exit 0 fi + +# Assume the service runs on top of Apache when user is root +if [[ "$(whoami)" == '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 diff --git a/releasenotes/notes/add-manila-api-httpd-packages-and-conf-1bea1364037cd64e.yaml b/releasenotes/notes/add-manila-api-httpd-packages-and-conf-1bea1364037cd64e.yaml new file mode 100644 index 0000000000..fbaafc5ec4 --- /dev/null +++ b/releasenotes/notes/add-manila-api-httpd-packages-and-conf-1bea1364037cd64e.yaml @@ -0,0 +1,8 @@ +--- +features: + - | + The manila-api dockerfile now contains support for httpd and mod_wsgi + packages for all supported platforms. It also contains the mod_ssl + package for RHEL/centos and oraclelinux. Docker entrypoints can now use + the httpd configuration seeded to run the manila-api service with + httpd/mod_wsgi.