diff --git a/phpfpm/7.4/Dockerfile b/phpfpm/7.4/Dockerfile new file mode 100644 index 0000000..f0b3c46 --- /dev/null +++ b/phpfpm/7.4/Dockerfile @@ -0,0 +1,38 @@ +FROM johnpbloch/phpfpm:7.4 + +RUN curl -L https://phar.phpunit.de/phpunit-8.phar > /tmp/phpunit.phar \ + && chmod +x /tmp/phpunit.phar \ + && mv /tmp/phpunit.phar /usr/local/bin/phpunit + +RUN apt-get update && apt-get install -y \ + git \ + subversion \ + wget \ + libxml2-dev \ + ssmtp \ + imagemagick \ + libmagickwand-dev \ + unzip \ + iproute2 \ + libicu-dev \ + && pecl install imagick \ + && docker-php-ext-enable imagick \ + && docker-php-ext-install soap intl \ + && echo "mailhub=mailcatcher:1025\nUseTLS=NO\nFromLineOverride=YES" > /etc/ssmtp/ssmtp.conf \ + && apt-get remove -y libmagickwand-dev libxml2-dev libicu-dev \ + && apt-get autoremove -y \ + && apt-get clean \ + && mkdir /var/www/.wp-cli \ + && chown www-data:www-data /var/www/.wp-cli + +RUN XDEBUG=$(find /usr/local/lib/php -name 'xdebug.so' | head -n 1 | tail -n 1) \ + && ln -s $XDEBUG /usr/local/lib/php/extensions/xdebug.so + +COPY entrypoint.sh /entrypoint.sh + +RUN chmod +x /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] +CMD ["php-fpm"] + +EXPOSE 9000 diff --git a/phpfpm/7.4/entrypoint.sh b/phpfpm/7.4/entrypoint.sh new file mode 100644 index 0000000..3b57fa4 --- /dev/null +++ b/phpfpm/7.4/entrypoint.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash + +# Ensure we have the host.docker.internal hostname available to linux as well +function fix_linux_internal_host() { + DOCKER_INTERNAL_HOST="host.docker.internal" + + if ! grep $DOCKER_INTERNAL_HOST /etc/hosts > /dev/null ; then + DOCKER_INTERNAL_IP=`/sbin/ip route|awk '/default/ { print $3 }'` + echo -e "$DOCKER_INTERNAL_IP\t$DOCKER_INTERNAL_HOST" | tee -a /etc/hosts > /dev/null + echo 'Added $DOCKER_INTERNAL_HOST to hosts /etc/hosts' + fi +} + +echo "Checking USER ID" +www_uid=`stat -c "%u" /var/www/html` +www_gid=`stat -c "%g" /var/www/html` + +echo "Host user is $www_uid:$www_gid" + +if [ ! $www_uid -eq 0 ]; then + echo "Updating www-data user and group to match host IDs" + usermod -u $www_uid www-data + groupmod -g $www_gid www-data + + fix_linux_internal_host +fi + +mkdir -p /var/www/.wp-cli/cache +chown www-data:www-data /var/www/.wp-cli/cache + +exec "$@" diff --git a/phpfpm/8.0/Dockerfile b/phpfpm/8.0/Dockerfile new file mode 100644 index 0000000..8846469 --- /dev/null +++ b/phpfpm/8.0/Dockerfile @@ -0,0 +1,38 @@ +FROM johnpbloch/phpfpm:8.0 + +RUN curl -L https://phar.phpunit.de/phpunit-8.phar > /tmp/phpunit.phar \ + && chmod +x /tmp/phpunit.phar \ + && mv /tmp/phpunit.phar /usr/local/bin/phpunit + +RUN apt-get update && apt-get install -y \ + git \ + subversion \ + wget \ + libxml2-dev \ + ssmtp \ + imagemagick \ + libmagickwand-dev \ + unzip \ + iproute2 \ + libicu-dev \ + && pecl install imagick \ + && docker-php-ext-enable imagick \ + && docker-php-ext-install soap intl \ + && echo "mailhub=mailcatcher:1025\nUseTLS=NO\nFromLineOverride=YES" > /etc/ssmtp/ssmtp.conf \ + && apt-get remove -y libmagickwand-dev libxml2-dev libicu-dev \ + && apt-get autoremove -y \ + && apt-get clean \ + && mkdir /var/www/.wp-cli \ + && chown www-data:www-data /var/www/.wp-cli + +RUN XDEBUG=$(find /usr/local/lib/php -name 'xdebug.so' | head -n 1 | tail -n 1) \ + && ln -s $XDEBUG /usr/local/lib/php/extensions/xdebug.so + +COPY entrypoint.sh /entrypoint.sh + +RUN chmod +x /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] +CMD ["php-fpm"] + +EXPOSE 9000 diff --git a/phpfpm/8.0/entrypoint.sh b/phpfpm/8.0/entrypoint.sh new file mode 100644 index 0000000..3b57fa4 --- /dev/null +++ b/phpfpm/8.0/entrypoint.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash + +# Ensure we have the host.docker.internal hostname available to linux as well +function fix_linux_internal_host() { + DOCKER_INTERNAL_HOST="host.docker.internal" + + if ! grep $DOCKER_INTERNAL_HOST /etc/hosts > /dev/null ; then + DOCKER_INTERNAL_IP=`/sbin/ip route|awk '/default/ { print $3 }'` + echo -e "$DOCKER_INTERNAL_IP\t$DOCKER_INTERNAL_HOST" | tee -a /etc/hosts > /dev/null + echo 'Added $DOCKER_INTERNAL_HOST to hosts /etc/hosts' + fi +} + +echo "Checking USER ID" +www_uid=`stat -c "%u" /var/www/html` +www_gid=`stat -c "%g" /var/www/html` + +echo "Host user is $www_uid:$www_gid" + +if [ ! $www_uid -eq 0 ]; then + echo "Updating www-data user and group to match host IDs" + usermod -u $www_uid www-data + groupmod -g $www_gid www-data + + fix_linux_internal_host +fi + +mkdir -p /var/www/.wp-cli/cache +chown www-data:www-data /var/www/.wp-cli/cache + +exec "$@" diff --git a/phpfpm/8.1/Dockerfile b/phpfpm/8.1/Dockerfile new file mode 100644 index 0000000..b3f6f39 --- /dev/null +++ b/phpfpm/8.1/Dockerfile @@ -0,0 +1,38 @@ +FROM johnpbloch/phpfpm:8.1 + +RUN curl -L https://phar.phpunit.de/phpunit-8.phar > /tmp/phpunit.phar \ + && chmod +x /tmp/phpunit.phar \ + && mv /tmp/phpunit.phar /usr/local/bin/phpunit + +RUN apt-get update && apt-get install -y \ + git \ + subversion \ + wget \ + libxml2-dev \ + ssmtp \ + imagemagick \ + libmagickwand-dev \ + unzip \ + iproute2 \ + libicu-dev \ + && pecl install imagick \ + && docker-php-ext-enable imagick \ + && docker-php-ext-install soap intl \ + && echo "mailhub=mailcatcher:1025\nUseTLS=NO\nFromLineOverride=YES" > /etc/ssmtp/ssmtp.conf \ + && apt-get remove -y libmagickwand-dev libxml2-dev libicu-dev \ + && apt-get autoremove -y \ + && apt-get clean \ + && mkdir /var/www/.wp-cli \ + && chown www-data:www-data /var/www/.wp-cli + +RUN XDEBUG=$(find /usr/local/lib/php -name 'xdebug.so' | head -n 1 | tail -n 1) \ + && ln -s $XDEBUG /usr/local/lib/php/extensions/xdebug.so + +COPY entrypoint.sh /entrypoint.sh + +RUN chmod +x /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] +CMD ["php-fpm"] + +EXPOSE 9000 diff --git a/phpfpm/8.1/entrypoint.sh b/phpfpm/8.1/entrypoint.sh new file mode 100644 index 0000000..3b57fa4 --- /dev/null +++ b/phpfpm/8.1/entrypoint.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash + +# Ensure we have the host.docker.internal hostname available to linux as well +function fix_linux_internal_host() { + DOCKER_INTERNAL_HOST="host.docker.internal" + + if ! grep $DOCKER_INTERNAL_HOST /etc/hosts > /dev/null ; then + DOCKER_INTERNAL_IP=`/sbin/ip route|awk '/default/ { print $3 }'` + echo -e "$DOCKER_INTERNAL_IP\t$DOCKER_INTERNAL_HOST" | tee -a /etc/hosts > /dev/null + echo 'Added $DOCKER_INTERNAL_HOST to hosts /etc/hosts' + fi +} + +echo "Checking USER ID" +www_uid=`stat -c "%u" /var/www/html` +www_gid=`stat -c "%g" /var/www/html` + +echo "Host user is $www_uid:$www_gid" + +if [ ! $www_uid -eq 0 ]; then + echo "Updating www-data user and group to match host IDs" + usermod -u $www_uid www-data + groupmod -g $www_gid www-data + + fix_linux_internal_host +fi + +mkdir -p /var/www/.wp-cli/cache +chown www-data:www-data /var/www/.wp-cli/cache + +exec "$@"