From 6ad739a53cac0bbd761ab0cde6db76ab6e41e915 Mon Sep 17 00:00:00 2001 From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com> Date: Wed, 9 Sep 2026 14:41:44 +0200 Subject: [PATCH] feat(docker): limit container name prefixes to 30 characters --- app/Livewire/Project/Application/Advanced.php | 2 +- app/Models/ApplicationSetting.php | 6 ++++++ bootstrap/helpers/api.php | 3 ++- .../views/livewire/project/application/advanced.blade.php | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/Livewire/Project/Application/Advanced.php b/app/Livewire/Project/Application/Advanced.php index b3564df0bb..a57d529bcb 100644 --- a/app/Livewire/Project/Application/Advanced.php +++ b/app/Livewire/Project/Application/Advanced.php @@ -70,7 +70,7 @@ class Advanced extends Component #[Validate(['string', 'nullable'])] public ?string $customInternalName = null; - #[Validate(['string', 'nullable', 'max:47'])] + #[Validate(['string', 'nullable', 'max:'.ApplicationSetting::MAX_CONTAINER_NAME_PREFIX_LENGTH])] public ?string $customContainerNamePrefix = null; #[Validate(['boolean'])] diff --git a/app/Models/ApplicationSetting.php b/app/Models/ApplicationSetting.php index 60fb9b2336..18b26f454f 100644 --- a/app/Models/ApplicationSetting.php +++ b/app/Models/ApplicationSetting.php @@ -50,6 +50,12 @@ use OpenApi\Attributes as OA; )] class ApplicationSetting extends Model { + /** + * Keeps generated names (prefix, timestamp and for compose apps the service name) well below the + * 63 character DNS label limit, with room for a longer suffix in the future. + */ + public const MAX_CONTAINER_NAME_PREFIX_LENGTH = 30; + protected $casts = [ 'is_static' => 'boolean', 'is_spa' => 'boolean', diff --git a/bootstrap/helpers/api.php b/bootstrap/helpers/api.php index 81676ab070..b32870a5f7 100644 --- a/bootstrap/helpers/api.php +++ b/bootstrap/helpers/api.php @@ -4,6 +4,7 @@ use App\Actions\Shared\MigrateResourceToDestination; use App\Enums\BuildPackTypes; use App\Enums\RedirectTypes; use App\Enums\StaticImageTypes; +use App\Models\ApplicationSetting; use App\Models\Environment; use App\Models\StandaloneDocker; use App\Models\SwarmDocker; @@ -141,7 +142,7 @@ function sharedDataApplications() 'gpu_options' => 'string|nullable', 'is_consistent_container_name_enabled' => 'boolean', 'custom_internal_name' => 'string|nullable', - 'custom_container_name_prefix' => 'string|nullable|max:47', + 'custom_container_name_prefix' => 'string|nullable|max:'.ApplicationSetting::MAX_CONTAINER_NAME_PREFIX_LENGTH, 'preview_url_template' => 'string', 'max_restart_count' => 'integer|min:0', 'stop_grace_period' => 'nullable|integer|min:'.MIN_STOP_GRACE_PERIOD_SECONDS.'|max:'.MAX_STOP_GRACE_PERIOD_SECONDS, diff --git a/resources/views/livewire/project/application/advanced.blade.php b/resources/views/livewire/project/application/advanced.blade.php index 3a5549e0ea..27b40546bb 100644 --- a/resources/views/livewire/project/application/advanced.blade.php +++ b/resources/views/livewire/project/application/advanced.blade.php @@ -56,7 +56,7 @@