Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1,852 changes: 1,726 additions & 126 deletions .github/workflows/build.yaml

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,9 @@ controls extension loading. PIE requests remain unpinned, and compilation uses
`nproc` parallel jobs.

Protobuf, Vips and XML-RPC are built directly from their official upstream sources.
The existing XML-RPC **1.0.0RC3** pin is preserved on all supported PHP versions.
Protobuf on PHP 8.2–8.5 uses the latest upstream release. If a future release raises its minimum PHP
Vips and XML-RPC are only built for PHP 8.2–8.5 (see [PHP 8.6](docs/images/php.md#php-86-preview)).
The existing XML-RPC **1.0.0RC3** pin is preserved on those versions.
Protobuf on PHP 8.2–8.6 uses the latest upstream release. If a future release raises its minimum PHP
version, older PHP image builds can fail; there is no automatic fallback to an
older release. The existing CI matrix checks compatibility across PHP versions.

Expand Down
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,59 +55,73 @@ How the files in this repository are generated, and how the images are built and

### Debian PHP

The following images which are currently supported are based on `php:{VER}-fpm-bookworm`.
The following images which are currently supported are based on `php:{VER}-fpm-bookworm`
(PHP 8.6: `php:8.6-rc-fpm-trixie`, a preview, see [PHP 8.6](docs/images/php.md#php-86-preview)).

* `webdevops/php:8.2`
* `webdevops/php:8.3`
* `webdevops/php:8.4`
* `webdevops/php:8.5`
* `webdevops/php:8.6` (preview)
* `webdevops/php-dev:8.2`
* `webdevops/php-dev:8.3`
* `webdevops/php-dev:8.4`
* `webdevops/php-dev:8.5`
* `webdevops/php-dev:8.6` (preview)
* `webdevops/php-apache:8.2`
* `webdevops/php-apache:8.3`
* `webdevops/php-apache:8.4`
* `webdevops/php-apache:8.5`
* `webdevops/php-apache:8.6` (preview)
* `webdevops/php-apache-dev:8.2`
* `webdevops/php-apache-dev:8.3`
* `webdevops/php-apache-dev:8.4`
* `webdevops/php-apache-dev:8.5`
* `webdevops/php-apache-dev:8.6` (preview)
* `webdevops/php-nginx:8.2`
* `webdevops/php-nginx:8.3`
* `webdevops/php-nginx:8.4`
* `webdevops/php-nginx:8.5`
* `webdevops/php-nginx:8.6` (preview)
* `webdevops/php-nginx-dev:8.2`
* `webdevops/php-nginx-dev:8.3`
* `webdevops/php-nginx-dev:8.4`
* `webdevops/php-nginx-dev:8.5`
* `webdevops/php-nginx-dev:8.6` (preview)


### Alpine PHP

The following images which are currently supported are based on `php:{VER}-fpm-alpine`.
The following images which are currently supported are based on `php:{VER}-fpm-alpine`
(PHP 8.6: `php:8.6-rc-fpm-alpine`, a preview, see [PHP 8.6](docs/images/php.md#php-86-preview)).

* `webdevops/php:8.2-alpine`
* `webdevops/php:8.3-alpine`
* `webdevops/php:8.4-alpine`
* `webdevops/php:8.5-alpine`
* `webdevops/php:8.6-alpine` (preview)
* `webdevops/php-dev:8.2-alpine`
* `webdevops/php-dev:8.3-alpine`
* `webdevops/php-dev:8.4-alpine`
* `webdevops/php-dev:8.5-alpine`
* `webdevops/php-dev:8.6-alpine` (preview)
* `webdevops/php-apache:8.2-alpine`
* `webdevops/php-apache:8.3-alpine`
* `webdevops/php-apache:8.4-alpine`
* `webdevops/php-apache:8.5-alpine`
* `webdevops/php-apache:8.6-alpine` (preview)
* `webdevops/php-apache-dev:8.2-alpine`
* `webdevops/php-apache-dev:8.3-alpine`
* `webdevops/php-apache-dev:8.4-alpine`
* `webdevops/php-apache-dev:8.5-alpine`
* `webdevops/php-apache-dev:8.6-alpine` (preview)
* `webdevops/php-nginx:8.2-alpine`
* `webdevops/php-nginx:8.3-alpine`
* `webdevops/php-nginx:8.4-alpine`
* `webdevops/php-nginx:8.5-alpine`
* `webdevops/php-nginx:8.6-alpine` (preview)
* `webdevops/php-nginx-dev:8.2-alpine`
* `webdevops/php-nginx-dev:8.3-alpine`
* `webdevops/php-nginx-dev:8.4-alpine`
* `webdevops/php-nginx-dev:8.5-alpine`
* `webdevops/php-nginx-dev:8.6-alpine` (preview)
40 changes: 39 additions & 1 deletion ci/image-tests/Checks/PhpChecks.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use function array_combine;
use function array_map;
use function escapeshellarg;
use function in_array;
use function json_decode;
use function preg_quote;
use function sprintf;
Expand All @@ -34,8 +35,16 @@ trait PhpChecks
'8.3' => '8.3.36',
'8.4' => '8.4.27',
'8.5' => '8.5.12',
// TODO PHP 8.6: raise to the first stable 8.6 release once the images use php:8.6-fpm-*
'8.6' => '8.6.0RC7',
];

/**
* PHP versions whose images are still built from a release candidate.
* TODO PHP 8.6: remove 8.6 once PHP 8.6.0 is released.
*/
private const array RELEASE_CANDIDATE_PHP_VERSIONS = ['8.6'];

public function testPhpServiceDirectory(): void
{
$this->assertRootDirectory('/opt/docker/bin/service.d/php-fpm.d');
Expand Down Expand Up @@ -91,7 +100,12 @@ public function testPhpVersion(): void

$minimum = self::MINIMUM_PHP_VERSIONS[$minor] ?? self::fail(sprintf('No minimum version for PHP %s in %s.', $minor, self::class));
$version = trim($this->stdout("php -r 'echo PHP_VERSION;'"));
self::assertMatchesRegularExpression('/\A' . preg_quote($minor, '/') . '\.[0-9]+\z/', $version, 'a stable release of PHP ' . $minor);
if (in_array($minor, self::RELEASE_CANDIDATE_PHP_VERSIONS, true)) {
self::assertMatchesRegularExpression('/\A' . preg_quote($minor, '/') . '\.[0-9]+(RC[0-9]+)?\z/', $version, 'a release (candidate) of PHP ' . $minor);
} else {
self::assertMatchesRegularExpression('/\A' . preg_quote($minor, '/') . '\.[0-9]+\z/', $version, 'a stable release of PHP ' . $minor);
}

self::assertTrue(version_compare($version, $minimum, '>='), sprintf('PHP %s should be %s or newer', $version, $minimum));
}

Expand Down Expand Up @@ -178,6 +192,30 @@ public function testImapLoads(): void
self::assertContains('imap', $this->lines($this->stdout('php -m')));
}

/**
* The official PHP images, and so the images built on them, are thread safe (ZTS) from PHP 8.6 on.
*/
public function testPhpThreadSafety(): void
{
self::assertSame(self::image()->isThreadSafe() ? 'true' : 'false', $this->stdout("php -r 'var_export((bool) PHP_ZTS);'"));
}

/**
* The Debian images load the ionCube Loader up to PHP 8.5; the Alpine images and PHP 8.6 and later have none.
*/
public function testIonCubeLoaderUpToPhp85OnDebian(): void
{
$result = $this->assertCommandSucceeds("php -r 'var_export(extension_loaded(\"ionCube Loader\"));'");
$this->assertNoPhpErrors($result->stdout . $result->stderr);
if (!self::image()->hasIonCube()) {
self::assertSame('false', $result->stdout);
return;
}

self::assertSame('true', $result->stdout);
self::assertStringContainsString('with the ionCube PHP Loader', $this->stdout('php -v'));
}

public function testPhpScansTheImageIniFiles(): void
{
$files = $this->stdout('php -r "echo php_ini_scanned_files();"');
Expand Down
16 changes: 16 additions & 0 deletions ci/image-tests/Checks/PhpEnvironmentChecks.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,22 @@ public function testPhpMaxExecutionTimeFromTheEnvironment(): void
self::assertSame('finished', $this->stdout('cd /app && php -r \'$_GET = ["test" => "busy", "seconds" => "2"]; include "php-test.php";\' 2>&1', $container));
}

/**
* PHP_MAX_EXECUTION_TIME=1 and a request that sleeps for 3 s: thread-safe PHP (PHP 8.6) counts the elapsed time,
* waiting included, and stops the script; otherwise only the time PHP itself runs counts.
*/
public function testPhpMaxExecutionTimeCountsWaitingOnlyInThreadSafePhp(): void
{
$body = $this->phpFpmBody($this->environmentContainer(), 'test=sleep&seconds=3');
if (!self::image()->isThreadSafe()) {
self::assertSame('slept', $body);
return;
}

self::assertStringContainsString('Maximum execution time of 1 second exceeded', $body);
self::assertStringNotContainsString('slept', $body);
}

/**
* PHP_POST_MAX_SIZE=1M: PHP discards a body of 2 MiB. PHP_UPLOAD_MAX_FILESIZE=512K: an upload of 600 KiB fails with
* UPLOAD_ERR_INI_SIZE (1), one of 100 KiB arrives.
Expand Down
6 changes: 3 additions & 3 deletions ci/image-tests/Checks/PhpFpmEnvironmentChecks.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ public function testPhpFpmResourceLimitsFromTheEnvironment(): void

/**
* FPM_REQUEST_TERMINATE_TIMEOUT=4: PHP-FPM ends a request that sleeps for 8 s after 4 s, without a response.
* PHP_MAX_EXECUTION_TIME does not stop it, because time in sleep() does not count.
* The request lifts PHP_MAX_EXECUTION_TIME, which counts the time in sleep() in thread-safe PHP.
*/
public function testPhpFpmRequestTerminateTimeoutFromTheEnvironment(): void
{
$container = $this->environmentContainer();
$this->phpFpmBody($container, 'test=sha1');
$start = microtime(true);
$result = $this->phpFpmRequest($container, 'test=sleep&seconds=8');
$result = $this->phpFpmRequest($container, 'test=sleep&seconds=8&time_limit=0');
$seconds = microtime(true) - $start;
self::assertSame(2, $result->exitCode, 'PHP-FPM should close the connection before the request ends: ' . $result->describe());
self::assertStringNotContainsString('slept', $result->stdout);
Expand Down Expand Up @@ -149,7 +149,7 @@ private function phpFpmWorkersDuring(Container $container, int $requests, int $s
$this->assertCommandSucceeds(sprintf(
'for request in $(seq %d); do (%s < /dev/null > /dev/null 2>&1 &); done',
$requests,
self::phpFpmCommand('test=sleep&seconds=' . $seconds),
self::phpFpmCommand('test=sleep&time_limit=0&seconds=' . $seconds),
), $container);
$start = microtime(true);
$workers = 0;
Expand Down
18 changes: 14 additions & 4 deletions ci/image-tests/Checks/PhpModules.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,27 @@ final class PhpModules
'mbstring', 'memcached', 'mongodb', 'mysqli', 'mysqlnd', 'openssl', 'opentelemetry', 'pcntl', 'pcre', 'PDO',
'pdo_mysql', 'pdo_pgsql', 'pdo_sqlite', 'pgsql', 'Phar', 'posix', 'protobuf', 'Reflection', 'session',
'SimpleXML', 'soap', 'sockets', 'SPL', 'sqlite3', 'standard', 'sysvmsg', 'sysvsem', 'sysvshm', 'tokenizer',
'vips', 'xml', 'xmlreader', 'xmlrpc', 'xmlwriter', 'xsl', 'yaml', 'zip', 'zlib', 'gd', 'apcu', 'shmop',
'Zend OPcache', 'redis',
'xml', 'xmlreader', 'xmlwriter', 'xsl', 'yaml', 'zip', 'zlib', 'gd', 'apcu', 'shmop', 'Zend OPcache', 'redis',
];

/**
* The extensions, with imap where the PHP version has it. PHP-FPM loads the same ones as the CLI, pcntl included.
* The extensions, with imap, vips and xmlrpc where the PHP version has them. PHP-FPM loads the same ones as the
* CLI, pcntl included.
*
* @return list<string>
*/
public static function loaded(ImageUnderTest $image): array
{
return $image->hasImap() ? [...self::COMMON, 'imap'] : self::COMMON;
$modules = self::COMMON;
if ($image->hasImap()) {
$modules[] = 'imap';
}

if ($image->hasVipsAndXmlrpc()) {
$modules[] = 'vips';
$modules[] = 'xmlrpc';
}

return $modules;
}
}
5 changes: 3 additions & 2 deletions ci/image-tests/Checks/PhpWebEnvironmentChecks.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@
trait PhpWebEnvironmentChecks
{
/**
* A PHP request that takes longer than WEB_PHP_TIMEOUT (2 s) gets 504 from the web server.
* A PHP request that takes longer than WEB_PHP_TIMEOUT (2 s) gets 504 from the web server. The request lifts
* PHP_MAX_EXECUTION_TIME, which counts the time in sleep() in thread-safe PHP.
*/
public function testWebServerAnswers504AfterWebPhpTimeout(): void
{
$container = $this->environmentContainer();
// wait for the web server and PHP-FPM
$this->request('http://localhost/php-test.php?test=sha1', container: $container);

self::assertSame('504', $this->statusCode('http://localhost/php-test.php?test=sleep&seconds=5', container: $container));
self::assertSame('504', $this->statusCode('http://localhost/php-test.php?test=sleep&seconds=5&time_limit=0', container: $container));
}
}
5 changes: 5 additions & 0 deletions ci/image-tests/Fixtures/app/php-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@
break;

case 'sleep':
// time_limit=0 lifts max_execution_time first: in thread-safe PHP (8.6), the time in sleep() counts towards it
if (isset($_GET['time_limit'])) {
set_time_limit((int) $_GET['time_limit']);
}

sleep((int) ($_GET['seconds'] ?? 0));
echo 'slept';
break;
Expand Down
27 changes: 27 additions & 0 deletions ci/image-tests/ImageUnderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use function is_string;
use function preg_match;
use function sprintf;
use function version_compare;

/**
* The image the tests run against, with the settings that ci/console test:image passes in environment variables.
Expand Down Expand Up @@ -96,6 +97,32 @@ public function hasImap(): bool
return (bool)preg_match('/^8\.[123]$/', $this->phpMinorVersion());
}

/**
* The images have the vips and xmlrpc extensions up to PHP 8.5; both are abandoned upstream and do not build
* against PHP 8.6.
*/
public function hasVipsAndXmlrpc(): bool
{
return (bool)preg_match('/^8\.[2-5]$/', $this->phpMinorVersion());
}

/**
* The official PHP images, and so the images built on them, are thread safe (ZTS) from PHP 8.6 on.
*/
public function isThreadSafe(): bool
{
return version_compare($this->phpMinorVersion(), '8.6', '>=');
}

/**
* The Debian images have the ionCube Loader up to PHP 8.5. The Alpine images have none, and the images do not
* install it from PHP 8.6 on, also once ionCube supports these versions.
*/
public function hasIonCube(): bool
{
return !$this->isAlpine() && version_compare($this->phpMinorVersion(), '8.6', '<');
}

private static function environment(string $setting): string
{
$value = getenv(ImageTests::ENVIRONMENT_PREFIX . $setting);
Expand Down
36 changes: 36 additions & 0 deletions ci/tests/ImageTests/ImageUnderTestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,42 @@ public function testReferenceDefaultsToTheName(): void
self::assertFalse($image->hasImap(), 'PHP 8.4 and later have no imap');
}

public function testVipsAndXmlrpcUpToPhp85(): void
{
foreach (['8.2', '8.5-alpine'] as $tag) {
$image = new ImageUnderTest('webdevops/php:' . $tag, 'webdevops/php:' . $tag, 'debian', '12', true);
self::assertTrue($image->hasVipsAndXmlrpc(), $tag);
}

$image = new ImageUnderTest('webdevops/php:8.6', 'webdevops/php:8.6', 'debian', '13', true);
self::assertFalse($image->hasVipsAndXmlrpc(), 'PHP 8.6 has no vips and xmlrpc');
}

public function testThreadSafeFromPhp86(): void
{
$image = new ImageUnderTest('webdevops/php:8.5-alpine', 'webdevops/php:8.5-alpine', 'alpine', '3', true);
self::assertFalse($image->isThreadSafe(), 'PHP 8.5');

foreach (['8.6', '8.6-alpine'] as $tag) {
$image = new ImageUnderTest('webdevops/php:' . $tag, 'webdevops/php:' . $tag, 'debian', '13', true);
self::assertTrue($image->isThreadSafe(), $tag);
}
}

public function testIonCubeOnDebianUpToPhp85(): void
{
foreach (['8.2', '8.5'] as $tag) {
$image = new ImageUnderTest('webdevops/php:' . $tag, 'webdevops/php:' . $tag, 'debian', '12', true);
self::assertTrue($image->hasIonCube(), $tag);
}

$image = new ImageUnderTest('webdevops/php:8.5-alpine', 'webdevops/php:8.5-alpine', 'alpine', '3', true);
self::assertFalse($image->hasIonCube(), 'Alpine has no ionCube');

$image = new ImageUnderTest('webdevops/php:8.6', 'webdevops/php:8.6', 'debian', '13', true);
self::assertFalse($image->hasIonCube(), 'PHP 8.6 and later have no ionCube');
}

public function testNameIsRequired(): void
{
$this->expectException(RuntimeException::class);
Expand Down
4 changes: 4 additions & 0 deletions conf/console.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@ dockerTest:
OS_FAMILY: 'debian'
OS_VERSION: '12'
PHP_OFFICIAL: '1'
'php[^:]*:8.6$':
OS_FAMILY: 'debian'
OS_VERSION: '13'
PHP_OFFICIAL: '1'
5 changes: 3 additions & 2 deletions docker/php-apache-dev/8.2/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ RUN --mount=type=bind,from=ghcr.io/php/pie:bin,source=/pie,target=/usr/local/bin
# Install development environment
&& BLACKFIRE_INSTALL_METHOD=raw bash -c "$(curl -L https://installer.blackfire.io/installer.sh)" \
&& blackfire php:install \
&& echo 'deb https://packages.tideways.com/apt-packages-main any-version main' | tee /etc/apt/sources.list.d/tideways.list \
&& wget -qO - https://packages.tideways.com/key.gpg | apt-key add - \
&& install -d -m 0755 /etc/apt/keyrings \
&& curl -fsSL --proto '=https' --proto-redir '=https' --retry 3 https://packages.tideways.com/key.gpg -o /etc/apt/keyrings/tideways.asc \
&& echo 'deb [signed-by=/etc/apt/keyrings/tideways.asc] https://packages.tideways.com/apt-packages-main any-version main' | tee /etc/apt/sources.list.d/tideways.list \
&& apt-install tideways-php tideways-daemon \
&& PIE_WORKING_DIRECTORY=/tmp/pie pie install --no-interaction --no-cache \
--skip-enable-extension --make-parallel-jobs="$(nproc)" xdebug/xdebug \
Expand Down
5 changes: 3 additions & 2 deletions docker/php-apache-dev/8.3/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ RUN --mount=type=bind,from=ghcr.io/php/pie:bin,source=/pie,target=/usr/local/bin
# Install development environment
&& BLACKFIRE_INSTALL_METHOD=raw bash -c "$(curl -L https://installer.blackfire.io/installer.sh)" \
&& blackfire php:install \
&& echo 'deb https://packages.tideways.com/apt-packages-main any-version main' | tee /etc/apt/sources.list.d/tideways.list \
&& wget -qO - https://packages.tideways.com/key.gpg | apt-key add - \
&& install -d -m 0755 /etc/apt/keyrings \
&& curl -fsSL --proto '=https' --proto-redir '=https' --retry 3 https://packages.tideways.com/key.gpg -o /etc/apt/keyrings/tideways.asc \
&& echo 'deb [signed-by=/etc/apt/keyrings/tideways.asc] https://packages.tideways.com/apt-packages-main any-version main' | tee /etc/apt/sources.list.d/tideways.list \
&& apt-install tideways-php tideways-daemon \
&& PIE_WORKING_DIRECTORY=/tmp/pie pie install --no-interaction --no-cache \
--skip-enable-extension --make-parallel-jobs="$(nproc)" xdebug/xdebug \
Expand Down
5 changes: 3 additions & 2 deletions docker/php-apache-dev/8.4/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ RUN --mount=type=bind,from=ghcr.io/php/pie:bin,source=/pie,target=/usr/local/bin
# Install development environment
&& BLACKFIRE_INSTALL_METHOD=raw bash -c "$(curl -L https://installer.blackfire.io/installer.sh)" \
&& blackfire php:install \
&& echo 'deb https://packages.tideways.com/apt-packages-main any-version main' | tee /etc/apt/sources.list.d/tideways.list \
&& wget -qO - https://packages.tideways.com/key.gpg | apt-key add - \
&& install -d -m 0755 /etc/apt/keyrings \
&& curl -fsSL --proto '=https' --proto-redir '=https' --retry 3 https://packages.tideways.com/key.gpg -o /etc/apt/keyrings/tideways.asc \
&& echo 'deb [signed-by=/etc/apt/keyrings/tideways.asc] https://packages.tideways.com/apt-packages-main any-version main' | tee /etc/apt/sources.list.d/tideways.list \
&& apt-install tideways-php tideways-daemon \
&& PIE_WORKING_DIRECTORY=/tmp/pie pie install --no-interaction --no-cache \
--skip-enable-extension --make-parallel-jobs="$(nproc)" xdebug/xdebug \
Expand Down
Loading
Loading