feat(docker): use ISO 8601 timestamp suffix for generated container names (#11702)

This commit is contained in:
🏔️ Peak
2026-09-09 15:01:53 +02:00
committed by GitHub
parent 45501131bb
commit 62df33ba3d
3 changed files with 25 additions and 2 deletions
+1 -1
View File
@@ -339,7 +339,7 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue
if ($containerName === 'coolify-proxy') {
continue;
}
if (preg_match('/-(\d{12})/', $containerName)) {
if (isGeneratedContainerName($containerName)) {
continue;
}
$containerIp = data_get($container, 'IPv4Address');
+15 -1
View File
@@ -350,7 +350,7 @@ function generateApplicationContainerName(Application $application, $pull_reques
$consistent_container_name = $application->settings->is_consistent_container_name_enabled;
$name = $consistent_container_name ? ($application->settings->custom_internal_name ?: $application->uuid) : $application->uuid;
$now = now()->format('Hisu');
$now = now()->format('Ymd\THis');
if ($pull_request_id !== 0 && $pull_request_id !== null) {
return $name.'-pr-'.$pull_request_id;
} else {
@@ -361,6 +361,20 @@ function generateApplicationContainerName(Application $application, $pull_reques
return $application->uuid.'-'.$now;
}
}
/**
* Generated (rolling update) container names end with the timestamp from generateApplicationContainerName().
* Drop the legacy pattern once containers created before the ISO 8601 suffix are gone.
*/
function isGeneratedContainerName(string $containerName): bool
{
$isoTimestampSuffix = '/-\d{8}T\d{6}$/';
$legacyTimestampSuffix = '/-\d{12}$/';
return preg_match($isoTimestampSuffix, $containerName) === 1
|| preg_match($legacyTimestampSuffix, $containerName) === 1;
}
function get_port_from_dockerfile($dockerfile): ?int
{
$dockerfile_array = explode("\n", $dockerfile);
@@ -55,3 +55,12 @@ it('ignores the custom container name when consistent naming is disabled', funct
expect(generateApplicationContainerName($application))->toStartWith('application-uuid-');
});
it('recognises generated container names in both timestamp formats', function () {
expect(isGeneratedContainerName('application-uuid-20260908T141530'))->toBeTrue()
->and(isGeneratedContainerName('my-api-20260908T141530'))->toBeTrue()
->and(isGeneratedContainerName('application-uuid-192238854305'))->toBeTrue()
->and(isGeneratedContainerName('application-uuid'))->toBeFalse()
->and(isGeneratedContainerName('application-uuid-pr-42'))->toBeFalse()
->and(isGeneratedContainerName('my-api'))->toBeFalse();
});