diff --git a/pica-dokuwiki/Dockerfile b/pica-dokuwiki/Dockerfile index ae5e13b63fca5b0ca8b35b9722c16efd2cf79697..17c22761e51cf87144e21d2202d359085884e1c1 100644 --- a/pica-dokuwiki/Dockerfile +++ b/pica-dokuwiki/Dockerfile @@ -3,17 +3,15 @@ LABEL maintainer="antoine@barbare.me" RUN apt-get update -y RUN apt-get install -y \ - curl \ - tar \ - php7.0 \ - php7.0-fpm \ - php7.0-gd \ - php7.0-xml + curl \ + tar \ + php7.0 \ + php7.0-fpm \ + php7.0-gd \ + php7.0-xml +USER nginx COPY nginx.conf /etc/nginx/nginx.conf -COPY supervisord.conf /etc/supervisord.conf -COPY entrypoint.sh /entrypoint.sh -COPY start.sh /start.sh RUN echo "cgi.fix_pathinfo = 0;" >> /etc/php/7.0/fpm/php.ini && \ sed -i -e "s|;daemonize\s*=\s*yes|daemonize = no|g" /etc/php/7.0/fpm/php-fpm.conf && \ @@ -21,19 +19,24 @@ RUN echo "cgi.fix_pathinfo = 0;" >> /etc/php/7.0/fpm/php.ini && \ sed -i -e "s|;listen\.owner\s*=\s*|listen.owner = |g" /etc/php/7.0/fpm/pool.d/www.conf && \ sed -i -e "s|;listen\.group\s*=\s*|listen.group = |g" /etc/php/7.0/fpm/pool.d/www.conf && \ sed -i -e "s|;listen\.mode\s*=\s*|listen.mode = |g" /etc/php/7.0/fpm/pool.d/www.conf && \ - chmod +x /start.sh -RUN cd /usr/share/nginx && \ - curl -O -L "https://download.dokuwiki.org/src/dokuwiki/dokuwiki-stable.tgz" && \ + +WORKDIR /usr/share/nginx +RUN curl -O -L "https://download.dokuwiki.org/src/dokuwiki/dokuwiki-stable.tgz" && \ tar -xzf dokuwiki-stable.tgz -C html --strip-components 1 && \ rm -Rf dokuwiki* -USER nginx EXPOSE 80 VOLUME ["/var/www/html"] HEALTHCHECK CMD curl -s 127.0.0.1:${DOKUWIKI_PORT:=80} +USER root +RUN apt-get remove -y \ + curl \ + tar + +COPY entrypoint.sh /entrypoint.sh +COPY run.sh /run.sh ENTRYPOINT ["/entrypoint.sh"] +CMD ["run.sh"] -USER root -CMD /start.sh diff --git a/pica-dokuwiki/entrypoint.sh b/pica-dokuwiki/entrypoint.sh index d1e1f6b0c09ba7e4d717c5efdd244dd08e34645a..2f4431a4c546149fa0dbfc119ccfd06ebe686adc 100755 --- a/pica-dokuwiki/entrypoint.sh +++ b/pica-dokuwiki/entrypoint.sh @@ -2,4 +2,3 @@ MAX_UPLOAD_SIZE=${MAX_UPLOAD_SIZE:-10M} sed -i "s/\${MAXSIZE}/$MAX_UPLOAD_SIZE/g" /etc/nginx/nginx.conf -/start.sh diff --git a/pica-dokuwiki/run.sh b/pica-dokuwiki/run.sh new file mode 100755 index 0000000000000000000000000000000000000000..f47135194f456d0c69d07c847ca4e123b7df6fa4 --- /dev/null +++ b/pica-dokuwiki/run.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +# EXPLAINING THE SCRIPT run.sh +# This is a poor man's supervisord. The only thing this script does is watching its forked (background) processes and as soon as one dies, it terminates all the others and exits with the code of the first dying process. +# see : https://github.com/dinkel/docker-nginx-phpfpm + +set -m + +php7.0-fpm & +nginx -g "daemon off;" & + +pids=`jobs -p` + +exitcode=0 + +function terminate() { + trap "" CHLD + + for pid in $pids; do + if ! kill -0 $pid 2>/dev/null; then + wait $pid + exitcode=$? + fi + done + + kill $pids 2>/dev/null +} + +trap terminate CHLD +wait + +exit $exitcode diff --git a/pica-dokuwiki/start.sh b/pica-dokuwiki/start.sh deleted file mode 100755 index 45b1bfc1fca3b6c950769aeba9c8c977331a24df..0000000000000000000000000000000000000000 --- a/pica-dokuwiki/start.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -set -e - -chown -R www-data /var/www -mkdir -p /var/run/php -exec /usr/bin/supervisord -c /etc/supervisord.conf