diff --git a/Dockerfile b/Dockerfile index 39c26c3..f2edc01 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,25 +4,26 @@ FROM eumau/nginx-unit:${UNIT_VERSION}-php7.3 # set recommended PHP.ini settings # see https://secure.php.net/manual/en/opcache.installation.php RUN { \ - echo 'opcache.memory_consumption=128'; \ - echo 'opcache.interned_strings_buffer=8'; \ - echo 'opcache.max_accelerated_files=4000'; \ - echo 'opcache.revalidate_freq=2'; \ - echo 'opcache.fast_shutdown=1'; \ + echo 'opcache.memory_consumption=128'; \ + echo 'opcache.interned_strings_buffer=8'; \ + echo 'opcache.max_accelerated_files=4000'; \ + echo 'opcache.revalidate_freq=2'; \ + echo 'opcache.fast_shutdown=1'; \ } > /etc/php/7.3/embed/conf.d/opcache-recommended.ini + # https://wordpress.org/support/article/editing-wp-config-php/#configure-error-logging RUN { \ # https://www.php.net/manual/en/errorfunc.constants.php # https://github.com/docker-library/wordpress/issues/420#issuecomment-517839670 - echo 'error_reporting = E_ERROR | E_WARNING | E_PARSE | E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_COMPILE_WARNING | E_RECOVERABLE_ERROR'; \ - echo 'display_errors = Off'; \ - echo 'display_startup_errors = Off'; \ - echo 'log_errors = On'; \ - echo 'error_log = /dev/stderr'; \ - echo 'log_errors_max_len = 1024'; \ - echo 'ignore_repeated_errors = On'; \ - echo 'ignore_repeated_source = Off'; \ - echo 'html_errors = Off'; \ + echo 'error_reporting = E_ERROR | E_WARNING | E_PARSE | E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_COMPILE_WARNING | E_RECOVERABLE_ERROR'; \ + echo 'display_errors = Off'; \ + echo 'display_startup_errors = Off'; \ + echo 'log_errors = On'; \ + echo 'error_log = /dev/stderr'; \ + echo 'log_errors_max_len = 1024'; \ + echo 'ignore_repeated_errors = On'; \ + echo 'ignore_repeated_source = Off'; \ + echo 'html_errors = Off'; \ } > /etc/php/7.3/embed/conf.d/error-logging.ini VOLUME /var/www/html @@ -31,6 +32,9 @@ ENV WORDPRESS_VERSION 5.2.3 ENV WORDPRESS_SHA1 5efd37148788f3b14b295b2a9bf48a1a467aa303 RUN set -ex; \ + apt-get update && apt-get -y install --no-install-recommends \ + php7.3-mysql \ + && rm -rf /var/lib/apt/lists/* ; \ curl -o wordpress.tar.gz -fSL "https://wordpress.org/wordpress-${WORDPRESS_VERSION}.tar.gz"; \ echo "$WORDPRESS_SHA1 *wordpress.tar.gz" | sha1sum -c -; \ # upstream tarballs include ./wordpress/ so this gives us /usr/src/wordpress @@ -42,46 +46,43 @@ RUN set -ex; \ # port used by the listener in config.json EXPOSE 8080 -# application setup - -# launch Unit +# launch and configure Unit 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": "routes" } }, \ - "routes": [ \ - { "match": { "uri": "*.php" }, "action": { "pass": "applications/direct_php" } }, \ - { "action": { "share": "/var/www/html" } }, \ - { "action": { "pass": "applications/index_php" } } \ - ], \ - "applications": { \ - "index_php": { \ - "type": "php", \ - "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", \ - "index": "index.php" \ - } \ - } \ -}' \ - --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; \ - } + -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 \ + && curl -X PUT --data-binary \ + '{ \ + "listeners": { "*:8080": { "pass": "routes" } }, \ + "routes": [ \ + { "match": { "uri": "*.php" }, "action": { "pass": "applications/direct_php" } }, \ + { "match": { "uri": "!*/" }, "action": { "share": "/var/www/html" } }, \ + { "action": { "pass": "applications/index_php" } } \ + ], \ + "applications": { \ + "index_php": { \ + "type": "php", \ + "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", \ + "index": "index.php" \ + } \ + } \ + }' \ + --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; \ + } WORKDIR /var/www/html