diff --git a/docker/horizon/Dockerfile.j2 b/docker/horizon/Dockerfile.j2 index f55b269071..03a8dcb1b5 100644 --- a/docker/horizon/Dockerfile.j2 +++ b/docker/horizon/Dockerfile.j2 @@ -18,8 +18,7 @@ RUN yum -y install \ RUN sed -i "s|WEBROOT = '/dashboard/'|WEBROOT = '/'|" /etc/openstack-dashboard/local_settings \ && cp /usr/share/openstack-dashboard/manage.py /usr/bin/manage.py \ - && /usr/bin/python /usr/bin/manage.py collectstatic --noinput --clear \ - && /usr/bin/python /usr/bin/manage.py compress --force + && /usr/bin/python /usr/bin/manage.py collectstatic --noinput --clear {% elif base_distro in ['ubuntu'] %} @@ -34,7 +33,6 @@ RUN cp /usr/share/openstack-dashboard/openstack_dashboard/conf/*.json /etc/opens && sed -i "s|^POLICY_FILES_PATH|POLICY_FILES_PATH = '/etc/openstack-dashboard'|" /etc/openstack-dashboard/local_settings.py \ && cp /usr/share/openstack-dashboard/manage.py /usr/bin/manage.py \ && /usr/bin/python /usr/bin/manage.py collectstatic --noinput \ - && /usr/bin/manage.py compress --force \ && rm /etc/apache2/conf-enabled/openstack-dashboard.conf \ && echo "" > /etc/apache2/ports.conf \ && rm /etc/openstack-dashboard/local_settings.py \ @@ -73,7 +71,6 @@ RUN ln -s horizon-source/* horizon \ && cp /horizon/openstack_dashboard/local/local_settings.py.example /etc/openstack-dashboard/local_settings \ && cp /horizon/manage.py /var/lib/kolla/venv/bin/manage.py \ && /var/lib/kolla/venv/bin/python /var/lib/kolla/venv/bin/manage.py collectstatic --noinput --clear \ - && /var/lib/kolla/venv/bin/python /var/lib/kolla/venv/bin/manage.py compress --force \ && chown -R horizon: /etc/openstack-dashboard /home/horizon /var/lib/kolla/venv/lib/python2.7/site-packages/static {% endif %} diff --git a/docker/horizon/extend_start.sh b/docker/horizon/extend_start.sh index a82821f14f..c3ef0e8951 100644 --- a/docker/horizon/extend_start.sh +++ b/docker/horizon/extend_start.sh @@ -12,3 +12,16 @@ fi if [[ "${KOLLA_BASE_DISTRO}" =~ fedora|centos|oraclelinux|rhel ]]; then rm -rf /var/run/httpd/* /run/httpd/* /tmp/httpd* fi + +# NOTE(jeffrey4l): The local_settings file affect django-compress +# behavior, so re-generate the compressed javascript and css if it +# is changed +MD5SUM_TXT_PATH="/home/horizon/.local_settings.md5sum.txt" +if [[ ! -f ${MD5SUM_TXT_PATH} || $(md5sum -c --status ${MD5SUM_TXT_PATH};echo $?) != 0 ]]; then + md5sum /etc/openstack-dashboard/local_settings > ${MD5SUM_TXT_PATH} + if [[ "${KOLLA_INSTALL_TYPE}" == "binary" ]]; then + /usr/bin/manage.py compress --force + elif [[ "${KOLLA_INSTALL_TYPE}" == "source" ]]; then + /var/lib/kolla/venv/bin/python /var/lib/kolla/venv/bin/manage.py compress --force + fi +fi