Created
May 13, 2022 09:30
-
-
Save ikawka/9e6772509874e00ba472274636591cf5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM php:7.2-fpm-alpine | |
# docker-entrypoint.sh dependencies | |
RUN apk add --no-cache \ | |
# in theory, docker-entrypoint.sh is POSIX-compliant, but priority is a working, consistent image | |
bash \ | |
# BusyBox sed is not sufficient for some of our sed expressions | |
sed | |
# install the PHP extensions we need | |
RUN set -ex; \ | |
\ | |
apk add --no-cache --virtual .build-deps \ | |
libjpeg-turbo-dev \ | |
libpng-dev \ | |
; \ | |
\ | |
docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr; \ | |
docker-php-ext-install gd mysqli opcache zip; \ | |
\ | |
runDeps="$( \ | |
scanelf --needed --nobanner --format '%n#p' --recursive /usr/local/lib/php/extensions \ | |
| tr ',' '\n' \ | |
| sort -u \ | |
| awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ | |
)"; \ | |
apk add --virtual .wordpress-phpexts-rundeps $runDeps; \ | |
apk del .build-deps | |
# 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.enable_cli=1'; \ | |
} > /usr/local/etc/php/conf.d/opcache-recommended.ini | |
# https://codex.wordpress.org/Editing_wp-config.php#Configure_Error_Logging | |
RUN { \ | |
echo 'error_reporting = 4339'; \ | |
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'; \ | |
} > /usr/local/etc/php/conf.d/error-logging.ini | |
VOLUME /var/www/html | |
ENV WORDPRESS_VERSION 5.2.3 | |
ENV WORDPRESS_SHA1 5efd37148788f3b14b295b2a9bf48a1a467aa303 | |
RUN apk --no-cache add shadow && \ | |
usermod -u 1000 www-data && \ | |
groupmod -g 1000 www-data | |
RUN set -ex; \ | |
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 | |
tar -xzf wordpress.tar.gz -C /usr/src/; \ | |
rm wordpress.tar.gz; \ | |
chown -R www-data:www-data /usr/src/wordpress | |
COPY docker-entrypoint.sh /usr/local/bin/ | |
RUN rm -rf /usr/src/wordpress/wp-content/themes && \ | |
rm -rf /usr/src/wordpress/wp-content/plugins | |
ENTRYPOINT ["docker-entrypoint.sh"] | |
CMD ["php-fpm"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment