|
1 FROM php:7.3-fpm-alpine |
|
2 |
|
3 # docker-entrypoint.sh dependencies |
|
4 RUN apk add --no-cache \ |
|
5 # in theory, docker-entrypoint.sh is POSIX-compliant, but priority is a working, consistent image |
|
6 bash \ |
|
7 # BusyBox sed is not sufficient for some of our sed expressions |
|
8 sed \ |
|
9 less \ |
|
10 mysql-client ; \ |
|
11 apk add --no-cache --virtual .composer-rundeps git subversion openssh mercurial tini patch make zip unzip coreutils; |
|
12 |
|
13 |
|
14 RUN set -ex; \ |
|
15 \ |
|
16 # install the PHP extensions we need |
|
17 apk add --no-cache --virtual .build-deps \ |
|
18 libjpeg-turbo-dev \ |
|
19 libpng-dev \ |
|
20 libzip-dev \ |
|
21 zlib-dev; \ |
|
22 docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr; \ |
|
23 docker-php-ext-configure zip --with-libzip; \ |
|
24 docker-php-ext-install -j$(getconf _NPROCESSORS_ONLN) gd mysqli opcache zip; \ |
|
25 runDeps="$( \ |
|
26 scanelf --needed --nobanner --format '%n#p' --recursive /usr/local/lib/php/extensions \ |
|
27 | tr ',' '\n' \ |
|
28 | sort -u \ |
|
29 | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ |
|
30 )"; \ |
|
31 apk add --virtual .wordpress-phpexts-rundeps $runDeps; \ |
|
32 # install composer dependencies |
|
33 apk add --no-cache --virtual .composer-phpext-rundeps $runDeps; \ |
|
34 printf "# composer php cli ini settings\n\ |
|
35 date.timezone=UTC\n\ |
|
36 memory_limit=-1\n\ |
|
37 opcache.enable_cli=1\n\ |
|
38 " > $PHP_INI_DIR/php-cli.ini ; \ |
|
39 # clean |
|
40 apk del .build-deps |
|
41 |
|
42 # install composer |
|
43 ENV COMPOSER_ALLOW_SUPERUSER 1 |
|
44 ENV COMPOSER_HOME /tmp |
|
45 ENV COMPOSER_VERSION 1.8.5 |
|
46 |
|
47 RUN curl --silent --fail --location --retry 3 --output /tmp/installer.php --url https://raw.githubusercontent.com/composer/getcomposer.org/cb19f2aa3aeaa2006c0cd69a7ef011eb31463067/web/installer \ |
|
48 && php -r " \ |
|
49 \$signature = '48e3236262b34d30969dca3c37281b3b4bbe3221bda826ac6a9a62d6444cdb0dcd0615698a5cbe587c3f0fe57a54d8f5'; \ |
|
50 \$hash = hash('sha384', file_get_contents('/tmp/installer.php')); \ |
|
51 if (!hash_equals(\$signature, \$hash)) { \ |
|
52 unlink('/tmp/installer.php'); \ |
|
53 echo 'Integrity check failed, installer is either corrupt or worse.' . PHP_EOL; \ |
|
54 exit(1); \ |
|
55 }" \ |
|
56 && php /tmp/installer.php --no-ansi --install-dir=/usr/bin --filename=composer --version=${COMPOSER_VERSION} \ |
|
57 && composer --ansi --version --no-interaction \ |
|
58 && rm -f /tmp/installer.php |
|
59 |
|
60 |
|
61 |
|
62 # set recommended PHP.ini settings |
|
63 # see https://secure.php.net/manual/en/opcache.installation.php |
|
64 RUN { \ |
|
65 echo 'opcache.memory_consumption=128'; \ |
|
66 echo 'opcache.interned_strings_buffer=8'; \ |
|
67 echo 'opcache.max_accelerated_files=4000'; \ |
|
68 echo 'opcache.revalidate_freq=2'; \ |
|
69 echo 'opcache.fast_shutdown=1'; \ |
|
70 echo 'opcache.enable_cli=1'; \ |
|
71 } > /usr/local/etc/php/conf.d/opcache-recommended.ini |
|
72 # https://codex.wordpress.org/Editing_wp-config.php#Configure_Error_Logging |
|
73 RUN { \ |
|
74 echo 'error_reporting = 4339'; \ |
|
75 echo 'display_errors = Off'; \ |
|
76 echo 'display_startup_errors = Off'; \ |
|
77 echo 'log_errors = On'; \ |
|
78 echo 'error_log = /dev/stderr'; \ |
|
79 echo 'log_errors_max_len = 1024'; \ |
|
80 echo 'ignore_repeated_errors = On'; \ |
|
81 echo 'ignore_repeated_source = Off'; \ |
|
82 echo 'html_errors = Off'; \ |
|
83 } > /usr/local/etc/php/conf.d/error-logging.ini |
|
84 |
|
85 VOLUME /var/www/html |
|
86 |
|
87 COPY ./docker-entrypoint.sh /usr/local/bin/ |
|
88 RUN chmod +x /usr/local/bin/docker-entrypoint.sh |
|
89 |
|
90 ENTRYPOINT ["docker-entrypoint.sh"] |
|
91 CMD ["php-fpm"] |
|
92 |