Skip to content

Commit

Permalink
feat: Allow to generate Dockerfile with PHP 8.3 image (#1234)
Browse files Browse the repository at this point in the history
  • Loading branch information
theofidry authored Dec 6, 2023
1 parent c985da9 commit 92fd474
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/DockerFileGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ final class DockerFileGenerator
Dockerfile;

private const PHP_DOCKER_IMAGES = [
'8.3.0' => '8.3-cli-alpine',
'8.2.0' => '8.2-cli-alpine',
'8.1.0' => '8.1-cli-alpine',
'8.0.0' => '8.0-cli-alpine',
Expand Down
31 changes: 31 additions & 0 deletions tests/DockerFileGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

use KevinGH\Box\RequirementChecker\Requirement;
use PHPUnit\Framework\TestCase;
use function sprintf;
use const PHP_MAJOR_VERSION;
use const PHP_MINOR_VERSION;

/**
* @covers \KevinGH\Box\DockerFileGenerator
Expand Down Expand Up @@ -334,5 +337,33 @@ public static function generatorRequirementsProvider(): iterable

Dockerfile,
];

$currentPhpMajorVersion = PHP_MAJOR_VERSION;
$currentPhpMinorVersion = PHP_MINOR_VERSION;

yield 'current PHP constraints' => [
[
Requirement::forPHP(
sprintf(
'~%s.%s.0',
$currentPhpMajorVersion,
$currentPhpMinorVersion,
),
null,
)
->toArray(),
],
'box.phar',
<<<Dockerfile
FROM php:{$currentPhpMajorVersion}.{$currentPhpMinorVersion}-cli-alpine
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
COPY box.phar /box.phar
ENTRYPOINT ["/box.phar"]
Dockerfile,
];
}
}

0 comments on commit 92fd474

Please sign in to comment.