diff --git a/src/7.0/fpm/Dockerfile b/src/7.0/fpm/Dockerfile index 8d51b0e..0e108bc 100644 --- a/src/7.0/fpm/Dockerfile +++ b/src/7.0/fpm/Dockerfile @@ -53,7 +53,7 @@ RUN { \ echo "opcache.enable=1"; \ echo "opcache.memory_consumption=1024"; \ echo "opcache.max_accelerated_files=9000"; \ - echo "opcache_revalidate_freq=120"; \ + echo "opcache.revalidate_freq=30"; \ echo "opcache.interned_strings_buffer=16"; \ } | tee -a /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini diff --git a/src/7.0/fpm/hiqdev-docker-entrypoint b/src/7.0/fpm/hiqdev-docker-entrypoint index 9449c98..fe89c32 100755 --- a/src/7.0/fpm/hiqdev-docker-entrypoint +++ b/src/7.0/fpm/hiqdev-docker-entrypoint @@ -5,7 +5,7 @@ set -e postconf -e myhostname=$(hostname) if [ "$ENV" = "dev" ]; then - # Diable Opcache + # Disble Opcache echo "Environment is set to DEV" echo "[ opcache ] Disabled" sed -i "s/opcache.enable\s*=\s*[[:digit:]]/opcache.enable=0/" /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini diff --git a/src/7.1/fpm/hiqdev-docker-entrypoint b/src/7.1/fpm/hiqdev-docker-entrypoint index 97ed375..b361154 100755 --- a/src/7.1/fpm/hiqdev-docker-entrypoint +++ b/src/7.1/fpm/hiqdev-docker-entrypoint @@ -5,7 +5,7 @@ set -e postconf -e myhostname=$(hostname) if [ "$ENV" = "dev" ]; then - # Diable Opcache + # Disable Opcache echo "Environment is set to DEV" echo "[ opcache ] Disabled" sed -i "s/opcache.enable\s*=\s*[[:digit:]]/opcache.enable=0/" /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini diff --git a/src/7.2/fpm/hiqdev-docker-entrypoint b/src/7.2/fpm/hiqdev-docker-entrypoint index b4f057a..bcd5dcf 100755 --- a/src/7.2/fpm/hiqdev-docker-entrypoint +++ b/src/7.2/fpm/hiqdev-docker-entrypoint @@ -5,7 +5,7 @@ set -e postconf -e myhostname=$(hostname) if [ "$ENV" != "prod" ]; then - # Diable Opcache + # Disable Opcache echo "Environment is set to DEV" echo "[ opcache ] Disabled" sed -i "s/opcache.revalidate_freq\s*=\s*[[:digit:]]/opcache.revalidate_freq=0/" /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini diff --git a/src/7.3/fpm/hiqdev-docker-entrypoint b/src/7.3/fpm/hiqdev-docker-entrypoint index 34a22f6..a805297 100755 --- a/src/7.3/fpm/hiqdev-docker-entrypoint +++ b/src/7.3/fpm/hiqdev-docker-entrypoint @@ -5,7 +5,7 @@ set -e postconf -e myhostname=$(hostname) if [ "$ENV" != "prod" ]; then - # Diable Opcache + # Disable Opcache echo "Environment is set to DEV" echo "[ opcache ] Configuring dev mode" sed -i "s/opcache.revalidate_freq\s*=\s*[[:digit:]]/opcache.revalidate_freq=0/" /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini diff --git a/src/7.4/fpm-alpine/hiqdev-docker-entrypoint b/src/7.4/fpm-alpine/hiqdev-docker-entrypoint index 5e46b7c..6e4d09b 100755 --- a/src/7.4/fpm-alpine/hiqdev-docker-entrypoint +++ b/src/7.4/fpm-alpine/hiqdev-docker-entrypoint @@ -7,7 +7,7 @@ postconf -e myhostname=$(hostname) if [ "$ENV" != "prod" ]; then echo "Environment is set to DEV" - # Diable Opcache + # Disable Opcache echo "[ opcache ] Configuring dev mode" sed -i "s/opcache.revalidate_freq\s*=\s*[[:digit:]]\+/opcache.revalidate_freq=0/" /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini @@ -43,7 +43,7 @@ if [ "$ENV" != "prod" ]; then fi if [ -n "$XDEBUG_START_WITH_REQUEST" ]; then echo "[ xdebug ] Set xdebug.remote_autostart to $XDEBUG_START_WITH_REQUEST" - sed -i "s/xdebug.start_with_request\s*=\s*.*/xdebug.start_with_request=$XDEBUG_START_WITH_REQUEST" /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini + sed -i "s/xdebug.start_with_request\s*=\s*.*/xdebug.start_with_request=$XDEBUG_START_WITH_REQUEST/" /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini fi fi fi diff --git a/src/7.4/fpm/hiqdev-docker-entrypoint b/src/7.4/fpm/hiqdev-docker-entrypoint index 5e46b7c..6e4d09b 100755 --- a/src/7.4/fpm/hiqdev-docker-entrypoint +++ b/src/7.4/fpm/hiqdev-docker-entrypoint @@ -7,7 +7,7 @@ postconf -e myhostname=$(hostname) if [ "$ENV" != "prod" ]; then echo "Environment is set to DEV" - # Diable Opcache + # Disable Opcache echo "[ opcache ] Configuring dev mode" sed -i "s/opcache.revalidate_freq\s*=\s*[[:digit:]]\+/opcache.revalidate_freq=0/" /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini @@ -43,7 +43,7 @@ if [ "$ENV" != "prod" ]; then fi if [ -n "$XDEBUG_START_WITH_REQUEST" ]; then echo "[ xdebug ] Set xdebug.remote_autostart to $XDEBUG_START_WITH_REQUEST" - sed -i "s/xdebug.start_with_request\s*=\s*.*/xdebug.start_with_request=$XDEBUG_START_WITH_REQUEST" /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini + sed -i "s/xdebug.start_with_request\s*=\s*.*/xdebug.start_with_request=$XDEBUG_START_WITH_REQUEST/" /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini fi fi fi diff --git a/src/8.0/fpm-alpine/hiqdev-docker-entrypoint b/src/8.0/fpm-alpine/hiqdev-docker-entrypoint index 36c175e..9762d2b 100755 --- a/src/8.0/fpm-alpine/hiqdev-docker-entrypoint +++ b/src/8.0/fpm-alpine/hiqdev-docker-entrypoint @@ -7,7 +7,7 @@ postconf -e myhostname=$(hostname) if [ "$ENV" != "prod" ]; then echo "Environment is set to DEV" - # Diable Opcache + # Disable Opcache echo "[ opcache ] Configuring dev mode" sed -i "s/opcache.revalidate_freq\s*=\s*[[:digit:]]\+/opcache.revalidate_freq=0/" /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini @@ -40,7 +40,7 @@ if [ "$ENV" != "prod" ]; then if [ -n "$XDEBUG_START_WITH_REQUEST" ]; then echo "[ xdebug ] Set xdebug.remote_autostart to $XDEBUG_START_WITH_REQUEST" - sed -i "s/xdebug.start_with_request\s*=\s*.*/xdebug.start_with_request=$XDEBUG_START_WITH_REQUEST" /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini + sed -i "s/xdebug.start_with_request\s*=\s*.*/xdebug.start_with_request=$XDEBUG_START_WITH_REQUEST/" /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini fi fi fi diff --git a/src/8.0/fpm/hiqdev-docker-entrypoint b/src/8.0/fpm/hiqdev-docker-entrypoint index 36c175e..9762d2b 100755 --- a/src/8.0/fpm/hiqdev-docker-entrypoint +++ b/src/8.0/fpm/hiqdev-docker-entrypoint @@ -7,7 +7,7 @@ postconf -e myhostname=$(hostname) if [ "$ENV" != "prod" ]; then echo "Environment is set to DEV" - # Diable Opcache + # Disable Opcache echo "[ opcache ] Configuring dev mode" sed -i "s/opcache.revalidate_freq\s*=\s*[[:digit:]]\+/opcache.revalidate_freq=0/" /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini @@ -40,7 +40,7 @@ if [ "$ENV" != "prod" ]; then if [ -n "$XDEBUG_START_WITH_REQUEST" ]; then echo "[ xdebug ] Set xdebug.remote_autostart to $XDEBUG_START_WITH_REQUEST" - sed -i "s/xdebug.start_with_request\s*=\s*.*/xdebug.start_with_request=$XDEBUG_START_WITH_REQUEST" /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini + sed -i "s/xdebug.start_with_request\s*=\s*.*/xdebug.start_with_request=$XDEBUG_START_WITH_REQUEST/" /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini fi fi fi diff --git a/src/8.1/fpm-alpine/hiqdev-docker-entrypoint b/src/8.1/fpm-alpine/hiqdev-docker-entrypoint index a403270..6ef060b 100755 --- a/src/8.1/fpm-alpine/hiqdev-docker-entrypoint +++ b/src/8.1/fpm-alpine/hiqdev-docker-entrypoint @@ -24,7 +24,7 @@ fi if [ "$ENV" != "prod" ]; then echo "Environment is set to DEV" - # Diable Opcache + # Disable Opcache echo "[ opcache ] Configuring dev mode" sed -i "s/opcache.revalidate_freq\s*=\s*[[:digit:]]\+/opcache.revalidate_freq=0/" /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini @@ -60,7 +60,7 @@ if [ "$ENV" != "prod" ]; then fi if [ -n "$XDEBUG_START_WITH_REQUEST" ]; then echo "[ xdebug ] Set xdebug.remote_autostart to $XDEBUG_START_WITH_REQUEST" - sed -i "s/xdebug.start_with_request\s*=\s*.*/xdebug.start_with_request=$XDEBUG_START_WITH_REQUEST" /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini + sed -i "s/xdebug.start_with_request\s*=\s*.*/xdebug.start_with_request=$XDEBUG_START_WITH_REQUEST/" /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini fi fi fi diff --git a/src/8.2/fpm-alpine/Dockerfile b/src/8.2/fpm-alpine/Dockerfile index 300d3ff..b127ea2 100644 --- a/src/8.2/fpm-alpine/Dockerfile +++ b/src/8.2/fpm-alpine/Dockerfile @@ -168,12 +168,14 @@ RUN { \ echo '[www]'; \ echo "pm.max_requests = $FPM_MAX_REQUESTS"; \ echo 'catch_workers_output = yes'; \ + } | tee -a /usr/local/etc/php-fpm.d/www.conf && \ + { \ echo '[global]'; \ echo "process.max = $FPM_PROCESS_MAX"; \ echo 'emergency_restart_threshold = 10'; \ echo 'emergency_restart_interval = 2s'; \ echo 'process_control_timeout = 10s'; \ - } | tee -a /usr/local/etc/php-fpm.d/www.conf && \ + } | tee -a /usr/local/etc/php-fpm.conf && \ { \ echo "log_errors = On"; \ echo "max_execution_time = $PHP_MAX_EXECUTION_TIME"; \ diff --git a/src/8.2/fpm-alpine/hiqdev-docker-entrypoint b/src/8.2/fpm-alpine/hiqdev-docker-entrypoint index a403270..6ef060b 100755 --- a/src/8.2/fpm-alpine/hiqdev-docker-entrypoint +++ b/src/8.2/fpm-alpine/hiqdev-docker-entrypoint @@ -24,7 +24,7 @@ fi if [ "$ENV" != "prod" ]; then echo "Environment is set to DEV" - # Diable Opcache + # Disable Opcache echo "[ opcache ] Configuring dev mode" sed -i "s/opcache.revalidate_freq\s*=\s*[[:digit:]]\+/opcache.revalidate_freq=0/" /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini @@ -60,7 +60,7 @@ if [ "$ENV" != "prod" ]; then fi if [ -n "$XDEBUG_START_WITH_REQUEST" ]; then echo "[ xdebug ] Set xdebug.remote_autostart to $XDEBUG_START_WITH_REQUEST" - sed -i "s/xdebug.start_with_request\s*=\s*.*/xdebug.start_with_request=$XDEBUG_START_WITH_REQUEST" /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini + sed -i "s/xdebug.start_with_request\s*=\s*.*/xdebug.start_with_request=$XDEBUG_START_WITH_REQUEST/" /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini fi fi fi diff --git a/src/8.3/fpm-alpine/Dockerfile b/src/8.3/fpm-alpine/Dockerfile index 9a5ecf8..b6abf5d 100644 --- a/src/8.3/fpm-alpine/Dockerfile +++ b/src/8.3/fpm-alpine/Dockerfile @@ -174,12 +174,14 @@ RUN { \ echo '[www]'; \ echo "pm.max_requests = $FPM_MAX_REQUESTS"; \ echo 'catch_workers_output = yes'; \ + } | tee -a /usr/local/etc/php-fpm.d/www.conf && \ + { \ echo '[global]'; \ echo "process.max = $FPM_PROCESS_MAX"; \ echo 'emergency_restart_threshold = 10'; \ echo 'emergency_restart_interval = 2s'; \ echo 'process_control_timeout = 10s'; \ - } | tee -a /usr/local/etc/php-fpm.d/www.conf && \ + } | tee -a /usr/local/etc/php-fpm.conf && \ { \ echo "log_errors = On"; \ echo "max_execution_time = $PHP_MAX_EXECUTION_TIME"; \ diff --git a/src/8.3/fpm-alpine/hiqdev-docker-entrypoint b/src/8.3/fpm-alpine/hiqdev-docker-entrypoint index a403270..6ef060b 100755 --- a/src/8.3/fpm-alpine/hiqdev-docker-entrypoint +++ b/src/8.3/fpm-alpine/hiqdev-docker-entrypoint @@ -24,7 +24,7 @@ fi if [ "$ENV" != "prod" ]; then echo "Environment is set to DEV" - # Diable Opcache + # Disable Opcache echo "[ opcache ] Configuring dev mode" sed -i "s/opcache.revalidate_freq\s*=\s*[[:digit:]]\+/opcache.revalidate_freq=0/" /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini @@ -60,7 +60,7 @@ if [ "$ENV" != "prod" ]; then fi if [ -n "$XDEBUG_START_WITH_REQUEST" ]; then echo "[ xdebug ] Set xdebug.remote_autostart to $XDEBUG_START_WITH_REQUEST" - sed -i "s/xdebug.start_with_request\s*=\s*.*/xdebug.start_with_request=$XDEBUG_START_WITH_REQUEST" /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini + sed -i "s/xdebug.start_with_request\s*=\s*.*/xdebug.start_with_request=$XDEBUG_START_WITH_REQUEST/" /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini fi fi fi diff --git a/src/8.4/fpm-alpine/Dockerfile b/src/8.4/fpm-alpine/Dockerfile index 207c223..d49ff13 100644 --- a/src/8.4/fpm-alpine/Dockerfile +++ b/src/8.4/fpm-alpine/Dockerfile @@ -165,12 +165,14 @@ RUN { \ echo '[www]'; \ echo "pm.max_requests = $FPM_MAX_REQUESTS"; \ echo 'catch_workers_output = yes'; \ + } | tee -a /usr/local/etc/php-fpm.d/www.conf && \ + { \ echo '[global]'; \ echo "process.max = $FPM_PROCESS_MAX"; \ echo 'emergency_restart_threshold = 10'; \ echo 'emergency_restart_interval = 2s'; \ echo 'process_control_timeout = 10s'; \ - } | tee -a /usr/local/etc/php-fpm.d/www.conf && \ + } | tee -a /usr/local/etc/php-fpm.conf && \ { \ echo "log_errors = On"; \ echo "max_execution_time = $PHP_MAX_EXECUTION_TIME"; \ diff --git a/src/8.4/fpm-alpine/hiqdev-docker-entrypoint b/src/8.4/fpm-alpine/hiqdev-docker-entrypoint index f760106..c05be5f 100755 --- a/src/8.4/fpm-alpine/hiqdev-docker-entrypoint +++ b/src/8.4/fpm-alpine/hiqdev-docker-entrypoint @@ -24,7 +24,7 @@ fi if [ "$ENV" != "prod" ]; then echo "Environment is set to DEV" - # Diable Opcache + # Disable Opcache echo "[ opcache ] Configuring dev mode" sed -i "s/opcache.revalidate_freq\s*=\s*[[:digit:]]\+/opcache.revalidate_freq=0/" /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini @@ -60,7 +60,7 @@ if [ "$ENV" != "prod" ]; then fi if [ -n "$XDEBUG_START_WITH_REQUEST" ]; then echo "[ xdebug ] Set xdebug.start_with_request to $XDEBUG_START_WITH_REQUEST" - sed -i "s/xdebug.start_with_request\s*=\s*.*/xdebug.start_with_request=$XDEBUG_START_WITH_REQUEST" /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini + sed -i "s/xdebug.start_with_request\s*=\s*.*/xdebug.start_with_request=$XDEBUG_START_WITH_REQUEST/" /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini fi fi fi diff --git a/src/8.5/Makefile b/src/8.5/Makefile new file mode 100644 index 0000000..e1d3120 --- /dev/null +++ b/src/8.5/Makefile @@ -0,0 +1,12 @@ +VERSION = 8.5 + +builds = fpm-alpine cli-alpine + +all: $(builds) push_$(builds) + +$(builds): + echo "🔧 Building PHP image for $@" + docker build -t hiqdev/php:$(VERSION)-$@ $@ + docker push hiqdev/php:$(VERSION)-$@ + +.PHONY: all $(builds) push_$(builds) diff --git a/src/8.5/cli-alpine/Dockerfile b/src/8.5/cli-alpine/Dockerfile new file mode 100644 index 0000000..ebd8445 --- /dev/null +++ b/src/8.5/cli-alpine/Dockerfile @@ -0,0 +1,153 @@ +FROM php:8.5-cli-alpine + +ENV POSTFIX_MAILNAME=hiqdev.com +ENV XDEBUG_RELEASE=3.5.1 +ENV MEMCACHED_RELEASE=3.4.0 +ENV PECL_SSH2_RELEASE=1.5.0 +ENV GNU_LIBICONV_RELEASE=1.18-r0 + +# PHP options +ENV PHP_MAX_EXECUTION_TIME=3000 +ENV PHP_MAX_INPUT_VARS=20000 +ENV PHP_ERROR_REPORTING="E_ALL & ~E_NOTICE" +ENV PHP_POST_MAX_SIZE=60M +ENV PHP_UPLOAD_MAX_FILESIZE=25M +ENV PHP_SESS_GC_MAXLIFETIME=2592000 + +RUN set -xe \ + && apk update \ + && apk add --no-cache --virtual .php-deps \ + imagemagick \ + ghostscript \ + make \ + libssh2 \ + icu \ + gmp-dev \ + librdkafka-dev \ + libpq-dev \ + libzip-dev \ + libxml2-dev \ + libmemcached-dev \ + imap-dev \ + libgomp \ + && apk add --no-cache --virtual .tools \ + openssh-client \ + git \ + iproute2 \ + bind-tools \ + gnupg \ + unzip \ + bash \ + postgresql-client \ + postfix \ + && apk add --no-cache --virtual .build-deps \ + $PHPIZE_DEPS \ + zlib-dev \ + icu-dev \ + g++ \ + freetype-dev \ + libpng-dev \ + imagemagick-dev \ + libjpeg-turbo-dev \ + ghc \ + autoconf \ + krb5-dev \ + libssh2-dev \ + zlib-dev \ + patch \ + && \ + docker-php-ext-configure intl && \ + docker-php-ext-install intl && \ + docker-php-ext-enable intl && \ + + pecl install imap && \ + pecl install mailparse && \ + docker-php-ext-install zip bcmath soap pcntl gmp && \ + docker-php-ext-enable mailparse imap && \ + + pecl install imagick && \ + docker-php-ext-enable imagick && \ + + # SSH + pecl install ssh2-$PECL_SSH2_RELEASE && \ + docker-php-ext-enable ssh2 && \ + + # GD + export CFLAGS="$PHP_CFLAGS" CPPFLAGS="$PHP_CPPFLAGS" LDFLAGS="$PHP_LDFLAGS" && \ + docker-php-ext-configure gd --with-freetype --with-jpeg && \ + docker-php-ext-install gd && \ + + # PostgreSQL + docker-php-ext-install pdo_pgsql pgsql && \ + + # XDebug + pecl install "xdebug-$XDEBUG_RELEASE" && \ + docker-php-ext-enable xdebug \ + + && pecl install rdkafka \ + && docker-php-ext-enable rdkafka \ + + # Memcached + && pecl install memcached-$MEMCACHED_RELEASE \ + && docker-php-ext-enable memcached \ + + # MongoDB + && pecl install mongodb \ + && docker-php-ext-enable mongodb \ + + # Sockets + && docker-php-ext-install sockets \ + + && apk add gnu-libiconv="$GNU_LIBICONV_RELEASE" --update-cache --repository http://dl-cdn.alpinelinux.org/alpine/latest-stable/community/ --allow-untrusted \ + + && { find /usr/local/lib -type f -print0 | xargs -0r strip --strip-all -p 2>/dev/null || true; } \ + && apk del .build-deps \ + && rm -rf /tmp/* /usr/local/lib/php/doc/* /var/cache/apk/* \ + +ENV LD_PRELOAD=/usr/lib/preloadable_libiconv.so + +# General settings +RUN { \ + echo "memory_limit=256M"; \ + } | tee -a /usr/local/etc/php/conf.d/docker-php-general.ini \ + + # Disable Git safe directory check + && git config --global --add safe.directory '*' \ + + && { \ + echo "opcache.enable=1"; \ + echo "opcache.memory_consumption=1024"; \ + echo "opcache.max_accelerated_files=9000"; \ + echo "opcache_revalidate_freq=120"; \ + echo "opcache.interned_strings_buffer=16"; \ + } | tee -a /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini \ + + # Disable XDebug by default + && sed -i "1s/^/;/" /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ + && { \ + echo "xdebug.max_nesting_level=500"; \ + echo "xdebug.mode=debug"; \ + echo "xdebug.client_host=127.0.0.1"; \ + echo "xdebug.client_port=9003"; \ + echo "xdebug.start_with_request=trigger"; \ + } | tee -a /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ + && \ + { \ + echo "log_errors = On"; \ + echo "max_execution_time = $PHP_MAX_EXECUTION_TIME"; \ + echo "max_input_vars = $PHP_MAX_INPUT_VARS"; \ + echo "error_reporting = $PHP_ERROR_REPORTING"; \ + echo "post_max_size = $PHP_POST_MAX_SIZE"; \ + echo "upload_max_filesize = $PHP_UPLOAD_MAX_FILESIZE"; \ + echo "session.gc_maxlifetime = $PHP_SESS_GC_MAXLIFETIME"; \ + echo "mail.add_x_header = Off"; \ + } | tee -a /usr/local/etc/php/php.ini + +# Composer +COPY --from=composer:2 /usr/bin/composer /usr/bin/composer + +# FreeCDB +COPY --from=hiqdev/freecdb /usr/bin/cdbmake /usr/bin/cdbdump /usr/bin/cdbget /usr/bin/cdbstats /usr/bin/ + +RUN mkdir /app +WORKDIR /app diff --git a/src/8.5/fpm-alpine/Dockerfile b/src/8.5/fpm-alpine/Dockerfile new file mode 100644 index 0000000..afb4597 --- /dev/null +++ b/src/8.5/fpm-alpine/Dockerfile @@ -0,0 +1,194 @@ +FROM php:8.5-fpm-alpine + +ENV POSTFIX_MAILNAME=hiqdev.com +ENV XDEBUG_RELEASE=3.5.1 +ENV MEMCACHED_RELEASE=3.4.0 +ENV NEW_RELIC_AGENT_VERSION=12.6.0.34 +ENV PECL_SSH2_RELEASE=1.5.0 +ENV GNU_LIBICONV_RELEASE=1.18-r0 + +# PHP-FPM options +ENV FPM_MAX_CHILDREN=300 +ENV FPM_START_SERVERS=50 +ENV FPM_MIN_SPARE_SERVERS=20 +ENV FPM_MAX_SPARE_SERVERS=50 +ENV FPM_MAX_REQUESTS=10000 +ENV FPM_PROCESS_MAX=512 + +# PHP Options +ENV PHP_MAX_EXECUTION_TIME=3000 +ENV PHP_MAX_INPUT_VARS=20000 +ENV PHP_ERROR_REPORTING="E_ALL & ~E_DEPRECATED & ~E_NOTICE" +ENV PHP_POST_MAX_SIZE=60M +ENV PHP_UPLOAD_MAX_FILESIZE=25M +ENV PHP_SESS_GC_MAXLIFETIME=2592000 + +COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/ + +RUN set -xe \ + && apk update \ + && apk add --no-cache --virtual .php-deps \ + imagemagick \ + ghostscript \ + make \ + libssh2 \ + icu \ + gmp-dev \ + librdkafka-dev \ + libpq-dev \ + libzip-dev \ + libxml2-dev \ + libmemcached-dev \ + imap-dev \ + libgomp \ + && apk add --no-cache --virtual .tools \ + openssh-client \ + git \ + iproute2 \ + bind-tools \ + gnupg \ + unzip \ + bash \ + postgresql-client \ + postfix \ + && apk add --no-cache --virtual .build-deps \ + $PHPIZE_DEPS \ + zlib-dev \ + icu-dev \ + g++ \ + freetype-dev \ + libpng-dev \ + imagemagick-dev \ + libjpeg-turbo-dev \ + ghc \ + autoconf \ + krb5-dev \ + libssh2-dev \ + zlib-dev \ + patch \ + && \ + docker-php-ext-configure intl && \ + docker-php-ext-install intl && \ + docker-php-ext-enable intl && \ + + pecl install imap && \ + pecl install mailparse && \ + docker-php-ext-install zip bcmath soap pcntl gmp && \ + docker-php-ext-enable mailparse imap && \ + + pecl install imagick && \ + docker-php-ext-enable imagick && \ + + # SSH + pecl install ssh2-$PECL_SSH2_RELEASE && \ + docker-php-ext-enable ssh2 && \ + + # GD + export CFLAGS="$PHP_CFLAGS" CPPFLAGS="$PHP_CPPFLAGS" LDFLAGS="$PHP_LDFLAGS" && \ + docker-php-ext-configure gd --with-freetype --with-jpeg && \ + docker-php-ext-install gd && \ + + # PostgreSQL + docker-php-ext-install pdo_pgsql pgsql && \ + + # XDebug + pecl install "xdebug-$XDEBUG_RELEASE" && \ + docker-php-ext-enable xdebug \ + + && pecl install rdkafka \ + && docker-php-ext-enable rdkafka \ + + # Memcached + && pecl install memcached-$MEMCACHED_RELEASE \ + && docker-php-ext-enable memcached \ + + # Sockets + && docker-php-ext-install sockets \ + + # MongoDB + && pecl install mongodb \ + && docker-php-ext-enable mongodb \ + + && apk add gnu-libiconv=$GNU_LIBICONV_RELEASE --update-cache --repository http://dl-cdn.alpinelinux.org/alpine/latest-stable/community/ --allow-untrusted \ + + # New Relic + && curl -L https://download.newrelic.com/php_agent/archive/$NEW_RELIC_AGENT_VERSION/newrelic-php5-$NEW_RELIC_AGENT_VERSION-linux-musl.tar.gz | tar -C /tmp -zx \ + && NR_INSTALL_USE_CP_NOT_LN=1 NR_INSTALL_SILENT=1 /tmp/newrelic-php5-$NEW_RELIC_AGENT_VERSION-linux-musl/newrelic-install install \ + && rm -rf /tmp/newrelic-php5-* /tmp/nrinstall* \ + + && { find /usr/local/lib -type f -print0 | xargs -0r strip --strip-all -p 2>/dev/null || true; } \ + && apk del .build-deps \ + && rm -rf /tmp/* /usr/local/lib/php/doc/* /var/cache/apk/* + +ENV LD_PRELOAD=/usr/lib/preloadable_libiconv.so + +# General settings +RUN { \ + echo "memory_limit=256M"; \ + } | tee -a /usr/local/etc/php/conf.d/docker-php-general.ini \ + + # Disable Git safe directory check + && git config --global --add safe.directory '*' \ + + && { \ + echo "opcache.enable=1"; \ + echo "opcache.memory_consumption=1024"; \ + echo "opcache.max_accelerated_files=9000"; \ + echo "opcache_revalidate_freq=120"; \ + echo "opcache.interned_strings_buffer=16"; \ + } | tee -a /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini \ + + # Disable XDebug by default + && sed -i "1s/^/;/" /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ + && { \ + echo "xdebug.max_nesting_level=500"; \ + echo "xdebug.mode=debug"; \ + echo "xdebug.client_host=127.0.0.1"; \ + echo "xdebug.client_port=9003"; \ + echo "xdebug.start_with_request=trigger"; \ + } | tee -a /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \ + + # Tune configs + sed -i "s/max_children\s*=\s*[[:digit:]]\+/max_children = $FPM_MAX_CHILDREN/" /usr/local/etc/php-fpm.d/www.conf && \ + sed -i "s/start_servers\s*=\s*[[:digit:]]\+/start_servers = $FPM_START_SERVERS/" /usr/local/etc/php-fpm.d/www.conf && \ + sed -i "s/min_spare_servers\s*=\s*[[:digit:]]\+/min_spare_servers = $FPM_MIN_SPARE_SERVERS/" /usr/local/etc/php-fpm.d/www.conf && \ + sed -i "s/pm.max_spare_servers\s*=\s*[[:digit:]]\+/pm.max_spare_servers = $FPM_MAX_SPARE_SERVERS/" /usr/local/etc/php-fpm.d/www.conf && \ + + # FPM monitoring + sed -i "s/.*pm.status_path = .*$/pm.status_path = \/fpm_status/g" /usr/local/etc/php-fpm.d/www.conf && \ + sed -i "s/.*ping.path = .*$/ping.path = \/fpm_ping/g" /usr/local/etc/php-fpm.d/www.conf && \ + sed -i "s/.*ping.response = .*$/ping.response = pong/g" /usr/local/etc/php-fpm.d/www.conf && \ + { \ + echo '[www]'; \ + echo "pm.max_requests = $FPM_MAX_REQUESTS"; \ + echo 'catch_workers_output = yes'; \ + } | tee -a /usr/local/etc/php-fpm.d/www.conf && \ + { \ + echo '[global]'; \ + echo "process.max = $FPM_PROCESS_MAX"; \ + echo 'emergency_restart_threshold = 10'; \ + echo 'emergency_restart_interval = 2s'; \ + echo 'process_control_timeout = 10s'; \ + } | tee -a /usr/local/etc/php-fpm.conf && \ + { \ + echo "log_errors = On"; \ + echo "max_execution_time = $PHP_MAX_EXECUTION_TIME"; \ + echo "max_input_vars = $PHP_MAX_INPUT_VARS"; \ + echo "error_reporting = $PHP_ERROR_REPORTING"; \ + echo "post_max_size = $PHP_POST_MAX_SIZE"; \ + echo "upload_max_filesize = $PHP_UPLOAD_MAX_FILESIZE"; \ + echo "session.gc_maxlifetime = $PHP_SESS_GC_MAXLIFETIME"; \ + echo "mail.add_x_header = Off"; \ + } | tee -a /usr/local/etc/php/php.ini + +# Composer +COPY --from=composer:2 /usr/bin/composer /usr/bin/composer +# FreeCDB +COPY --from=hiqdev/freecdb /usr/bin/cdbmake /usr/bin/cdbdump /usr/bin/cdbget /usr/bin/cdbstats /usr/bin/ + +RUN mkdir /app +WORKDIR /app + +COPY hiqdev-docker-entrypoint /usr/local/bin +ENTRYPOINT ["hiqdev-docker-entrypoint"] +CMD ["php-fpm"] diff --git a/src/8.5/fpm-alpine/hiqdev-docker-entrypoint b/src/8.5/fpm-alpine/hiqdev-docker-entrypoint new file mode 100755 index 0000000..c05be5f --- /dev/null +++ b/src/8.5/fpm-alpine/hiqdev-docker-entrypoint @@ -0,0 +1,82 @@ +#!/bin/bash +set -e + +# Update `myhostname` in Postfix in order to send emails +postconf -e myhostname=$(hostname) + +if [ -n "$NEW_RELIC_LICENSE_KEY" ]; then + echo '[ New Relic ] Enabled' + + sed -i 's/;extension/extension/' $(php -r "echo(PHP_CONFIG_FILE_SCAN_DIR);")/newrelic.ini + sed -i -e "s/REPLACE_WITH_REAL_KEY/$NEW_RELIC_LICENSE_KEY/" $(php -r "echo(PHP_CONFIG_FILE_SCAN_DIR);")/newrelic.ini + sed -i -e '$anewrelic.distributed_tracing_enabled=true' $(php -r "echo(PHP_CONFIG_FILE_SCAN_DIR);")/newrelic.ini + + if [ -n "$NEW_RELIC_DAEMON_ADDRESS" ]; then + echo "[ New Relic ] Daemon address set to $NEW_RELIC_DAEMON_ADDRESS:31339" + echo "newrelic.daemon.address=\"$NEW_RELIC_DAEMON_ADDRESS:31339\"" >> $(php -r "echo(PHP_CONFIG_FILE_SCAN_DIR);")/newrelic.ini + fi + if [ -n "$NEW_RELIC_APPNAME" ]; then + echo "[ New Relic ] App name set to $NEW_RELIC_APPNAME" + sed -i -e "s/newrelic.appname[[:space:]]=[[:space:]].*/newrelic.appname=\"$NEW_RELIC_APPNAME\"/" $(php -r "echo(PHP_CONFIG_FILE_SCAN_DIR);")/newrelic.ini + fi +fi + +if [ "$ENV" != "prod" ]; then + echo "Environment is set to DEV" + + # Disable Opcache + echo "[ opcache ] Configuring dev mode" + sed -i "s/opcache.revalidate_freq\s*=\s*[[:digit:]]\+/opcache.revalidate_freq=0/" /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini + + # Enable Blackfire + if [ "$PHP_BLACKFIRE_ENABLED" = "1" ]; then + echo "[ blackfire ] Enabling Blackfire" + sed -i "s/^;//" /usr/local/etc/php/conf.d/blackfire.ini + fi + + # Enable XDebug if not disabled explicitly + if [ "$PHP_XDEBUG_ENABLED" != "0" ]; then + echo "[ xdebug ] Enabled" + sed -i "1s/^;//" /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini + + if [ -z "$XDEBUG_CLIENT_HOST" ]; then + docker_host_ip=$( (dig +time=1 +tries=2 +short host.docker.internal | grep -v ';;' | head -1) || true ) + if [ "$docker_host_ip" != "" ]; then + # MacOS + XDEBUG_CLIENT_HOST=$docker_host_ip + else + # Linux + XDEBUG_CLIENT_HOST=$(ip route show | awk '/default/ {print $3}') + fi + fi + + if [ -n "$XDEBUG_CLIENT_HOST" ]; then + echo "[ xdebug ] Set client host to $XDEBUG_CLIENT_HOST" + sed -i "s/xdebug.client_host\s*=\s*.*/xdebug.client_host=$XDEBUG_CLIENT_HOST/" /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini + fi + if [ -n "$XDEBUG_CLIENT_PORT" ]; then + echo "[ xdebug ] Set client port to $XDEBUG_CLIENT_PORT" + sed -i "s/xdebug.client_port\s*=\s*.*/xdebug.client_port=$XDEBUG_CLIENT_PORT/" /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini + fi + if [ -n "$XDEBUG_START_WITH_REQUEST" ]; then + echo "[ xdebug ] Set xdebug.start_with_request to $XDEBUG_START_WITH_REQUEST" + sed -i "s/xdebug.start_with_request\s*=\s*.*/xdebug.start_with_request=$XDEBUG_START_WITH_REQUEST/" /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini + fi + fi +fi + +# first arg is `-f` or `--some-option` +if [ "${1#-}" != "$1" ]; then + set -- php-fpm "$@" +fi + +# first arg is `sh` or `bash` +if [ "$1" = 'sh' ] || [ "$1" = 'bash' ]; then + # GitLab Says: + # To ensure a job can run, its Docker image must: + # - Provide sh or bash + # - Define an ENTRYPOINT that starts a shell when passed sh/bash as argument + set -- "$@" +fi + +exec "$@"