Repository navigation
HQD-778: Add PHP 8.6 images #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| VERSION = 8.6 | ||
|
|
||
| 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) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,156 @@ | ||
| FROM php:8.6-cli-alpine | ||
|
|
||
| COPY --from=ghcr.io/php/pie:1.5.3-bin /pie /usr/local/bin/pie | ||
|
|
||
| ENV POSTFIX_MAILNAME=hiqdev.com | ||
| ENV XDEBUG_RELEASE=3.5.1 | ||
| ENV MEMCACHED_RELEASE=3.4.0 | ||
| ENV PECL_SSH2_RELEASE=1.6.1 | ||
| ENV IMAP_COMMIT=c441c79add125f5a01f88332805221edeebe47b0 | ||
| 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 --mount=type=secret,id=github_token \ | ||
| set -xe \ | ||
| # PIE downloads extension sources from GitHub; authenticate to avoid anonymous rate limits. | ||
| # Tracing is off while the token is read so that it never lands in build logs. | ||
| && { set +x; if [ -r /run/secrets/github_token ]; then export COMPOSER_AUTH="{\"github-oauth\":{\"github.com\":\"$(cat /run/secrets/github_token)\"}}"; fi; set -x; } \ | ||
| && 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 && \ | ||
|
|
||
| mkdir -p /usr/src/php/ext/imap && \ | ||
| curl -fsSL "https://github.com/php/pecl-mail-imap/archive/$IMAP_COMMIT.tar.gz" | tar -xz -C /usr/src/php/ext/imap --strip-components=1 && \ | ||
| docker-php-ext-configure imap --with-imap-ssl && \ | ||
| docker-php-ext-install imap && \ | ||
| pie install pecl/mailparse && \ | ||
| docker-php-ext-install zip bcmath soap pcntl gmp && \ | ||
|
|
||
| pie install imagick/imagick && \ | ||
|
|
||
| # SSH | ||
| pie install "pecl/ssh2:$PECL_SSH2_RELEASE" && \ | ||
|
|
||
| # 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 | ||
| pie install "xdebug/xdebug:$XDEBUG_RELEASE" \ | ||
|
|
||
| && pie install rdkafka/rdkafka \ | ||
|
|
||
| # Memcached | ||
| && pie install "php-memcached/php-memcached:$MEMCACHED_RELEASE" \ | ||
|
|
||
| # MongoDB | ||
| && pie install mongodb/mongodb-extension \ | ||
|
|
||
| # 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 \ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Keep package-signature verification enabled. This command downloads from an HTTP repository and permits untrusted or unsigned packages. An attacker who can replace the repository responses can supply modified package contents to the root build. The version pin does not authenticate those contents. Use HTTPS and remove
|
||
|
|
||
| && { 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 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,195 @@ | ||
| FROM php:8.6-fpm-alpine | ||
|
|
||
| COPY --from=ghcr.io/php/pie:1.5.3-bin /pie /usr/local/bin/pie | ||
|
|
||
| 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 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use a New Relic agent that supports PHP 8.6. The 12.6.0.34 installer rejects PHP 8.6 and skips its installation, but the installer can still exit successfully. Thus, a successful build does not guarantee that If
|
||
| ENV PECL_SSH2_RELEASE=1.6.1 | ||
| ENV IMAP_COMMIT=c441c79add125f5a01f88332805221edeebe47b0 | ||
| 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 | ||
|
|
||
| RUN --mount=type=secret,id=github_token \ | ||
| set -xe \ | ||
| # PIE downloads extension sources from GitHub; authenticate to avoid anonymous rate limits. | ||
| # Tracing is off while the token is read so that it never lands in build logs. | ||
| && { set +x; if [ -r /run/secrets/github_token ]; then export COMPOSER_AUTH="{\"github-oauth\":{\"github.com\":\"$(cat /run/secrets/github_token)\"}}"; fi; set -x; } \ | ||
| && 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 && \ | ||
|
|
||
| mkdir -p /usr/src/php/ext/imap && \ | ||
| curl -fsSL "https://github.com/php/pecl-mail-imap/archive/$IMAP_COMMIT.tar.gz" | tar -xz -C /usr/src/php/ext/imap --strip-components=1 && \ | ||
| docker-php-ext-configure imap --with-imap-ssl && \ | ||
| docker-php-ext-install imap && \ | ||
| pie install pecl/mailparse && \ | ||
| docker-php-ext-install zip bcmath soap pcntl gmp && \ | ||
|
|
||
| pie install imagick/imagick && \ | ||
|
|
||
| # SSH | ||
| pie install "pecl/ssh2:$PECL_SSH2_RELEASE" && \ | ||
|
|
||
| # 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 | ||
| pie install "xdebug/xdebug:$XDEBUG_RELEASE" \ | ||
|
|
||
| && pie install rdkafka/rdkafka \ | ||
|
|
||
| # Memcached | ||
| && pie install "php-memcached/php-memcached:$MEMCACHED_RELEASE" \ | ||
|
|
||
| # Sockets | ||
| && docker-php-ext-install sockets \ | ||
|
|
||
| # MongoDB | ||
| && pie install mongodb/mongodb-extension \ | ||
|
|
||
| && 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"] | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update the Xdebug pin in both images to a release that supports PHP 8.6.
XDEBUG_RELEASE=3.5.1pins a release whosecomposer.jsonrequiresphp >=8.0,<8.6. Both images install that release with plainpie installon a PHP 8.6 base. No fallback or platform-ignore flag is present, so the xdebug install step can fail. Thecli-alpinebuild fails at line 89, and thefpm-alpinebuild fails at line 98. Thefpm-alpineimage is also the base for the php-nginx 8.6 build.Set
XDEBUG_RELEASEin bothsrc/8.6/cli-alpine/Dockerfileandsrc/8.6/fpm-alpine/Dockerfileto an Xdebug release whosecomposer.jsonphpconstraint includes 8.6. Confirm the release's constraint before you pin it.