diff --git a/.drone.yml b/.drone.yml index 9cdac91..f9d3ec9 100644 --- a/.drone.yml +++ b/.drone.yml @@ -3,7 +3,6 @@ kind: pipeline name: default steps: - # TODO: tags - name: docker image: plugins/docker settings: @@ -12,6 +11,7 @@ steps: from_secret: dockerhub_username password: from_secret: dockerhub_password + auto_tag: true when: branch: - master diff --git a/Dockerfile b/Dockerfile index b1c6b03..c271636 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,6 @@ ARG UNIT_VERSION=1.10.0 FROM eumau/nginx-unit:${UNIT_VERSION}-php7.3 + # set recommended PHP.ini settings # see https://secure.php.net/manual/en/opcache.installation.php RUN { \ @@ -25,6 +26,8 @@ RUN { \ } > /etc/php/7.3/embed/conf.d/error-logging.ini +VOLUME /var/www/html + ENV WORDPRESS_VERSION 5.2.3 ENV WORDPRESS_SHA1 5efd37148788f3b14b295b2a9bf48a1a467aa303 @@ -34,34 +37,63 @@ RUN set -ex; \ # upstream tarballs include ./wordpress/ so this gives us /usr/src/wordpress tar -xzf wordpress.tar.gz -C /usr/src/; \ rm wordpress.tar.gz; \ - chown -R www-data:www-data /usr/src/wordpress + chown -R www-data:www-data /usr/src/wordpress; \ + chown -R www-data:www-data /var/www/html # port used by the listener in config.json -EXPOSE 8080 +EXPOSE 8090 8091 # application setup -RUN mkdir -p /var/www/html && echo ' /var/www/html/index.php && chown -R www-data:www-data /var/www/html -VOLUME /var/www/html # launch Unit -RUN unitd --control unix:/var/run/control.unit.sock \ -# upload the app config to Unit - && curl -X PUT --data-binary '{ \ +RUN \ + [ -f /var/www/html/index.php ] || { \ + touch /var/www/html/index.php /var/www/html/index.php.remove; \ + } \ + && unitd --control unix:/var/run/control.unit.sock \ + # upload the app config to Unit + && curl -X PUT --data-binary '{ \ "listeners": { \ - "*:8080": { \ - "pass": "applications/wordpress" \ + "*:8090": { \ + "application": "script_index_php" \ + }, \ + "*:8091": { \ + "application": "direct_php" \ } \ }, \ "applications": { \ - "wordpress": { \ + "script_index_php": { \ "type": "php", \ - "user": "www-data", \ - "group": "www-data", \ - "root": "/var/www/html" \ + "processes": { \ + "max": 20, \ + "spare": 5 \ + }, \ + "user": "www-data", \ + "group": "www-data", \ + "root": "/var/www/html", \ + "script": "index.php" \ + }, \ + "direct_php": { \ + "type": "php", \ + "processes": { \ + "max": 5, \ + "spare": 0 \ + }, \ + "user": "www-data", \ + "group": "www-data", \ + "root": "/var/www/html", \ + "script": "index.php" \ } \ } \ - }' --unix-socket /var/run/control.unit.sock http://localhost/config/ + }' --unix-socket /var/run/control.unit.sock http://localhost/config/ \ + && [ -f /var/www/html/index.php.remove ] && { \ + rm /var/www/html/index.php /var/www/html/index.php.remove; \ + } -VOLUME /www -# COPY docker-entrypoint.sh /usr/local/bin/ -# ENTRYPOINT ["docker-entrypoint.sh"] +WORKDIR /var/www/html + +COPY docker-entrypoint.sh /usr/local/bin/ +ENTRYPOINT ["docker-entrypoint.sh"] + +STOPSIGNAL SIGTERM +CMD ["unitd", "--no-daemon", "--control", "unix:/var/run/control.unit.sock"] diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh old mode 100644 new mode 100755 index 524b315..cb79c22 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -23,7 +23,7 @@ file_env() { unset "$fileVar" } -if [[ "$1" == unitd ]] || [ "$1" == php-fpm ]; then +if [[ "$1" == apache2* ]] || [ "$1" == unitd ]; then if [ "$(id -u)" = '0' ]; then case "$1" in apache2*)