diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php index 6b677fa0e..88a836ecc 100644 --- a/app/Jobs/ApplicationDeploymentJob.php +++ b/app/Jobs/ApplicationDeploymentJob.php @@ -1712,9 +1712,10 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue 'expose' => $ports, 'networks' => [ $this->destination->network => [ - 'aliases' => [ - $this->container_name, - ], + 'aliases' => array_merge( + [$this->container_name], + $this->application->network_aliases ? explode(',', $this->application->network_aliases) : [] + ), ], ], 'mem_limit' => $this->application->limits_memory, diff --git a/app/Livewire/Project/Application/General.php b/app/Livewire/Project/Application/General.php index ff29b74e9..55f7d881e 100644 --- a/app/Livewire/Project/Application/General.php +++ b/app/Livewire/Project/Application/General.php @@ -68,6 +68,7 @@ class General extends Component 'application.publish_directory' => 'nullable', 'application.ports_exposes' => 'required', 'application.ports_mappings' => 'nullable', + 'application.network_aliases' => 'nullable', 'application.dockerfile' => 'nullable', 'application.docker_registry_image_name' => 'nullable', 'application.docker_registry_image_tag' => 'nullable', @@ -120,6 +121,7 @@ class General extends Component 'application.custom_labels' => 'Custom labels', 'application.dockerfile_target_build' => 'Dockerfile target build', 'application.custom_docker_run_options' => 'Custom docker run commands', + 'application.custom_network_aliases' => 'Custom docker network aliases', 'application.docker_compose_custom_start_command' => 'Docker compose custom start command', 'application.docker_compose_custom_build_command' => 'Docker compose custom build command', 'application.custom_nginx_configuration' => 'Custom Nginx configuration', diff --git a/app/Models/Application.php b/app/Models/Application.php index bfb2a1041..a0cbe92e7 100644 --- a/app/Models/Application.php +++ b/app/Models/Application.php @@ -43,6 +43,7 @@ use Visus\Cuid2\Cuid2; 'start_command' => ['type' => 'string', 'description' => 'Start command.'], 'ports_exposes' => ['type' => 'string', 'description' => 'Ports exposes.'], 'ports_mappings' => ['type' => 'string', 'nullable' => true, 'description' => 'Ports mappings.'], + 'network_aliases' => ['type' => 'string', 'nullable' => true, 'description' => 'Network aliases for Docker container.'], 'base_directory' => ['type' => 'string', 'description' => 'Base directory for all commands.'], 'publish_directory' => ['type' => 'string', 'description' => 'Publish directory.'], 'health_check_enabled' => ['type' => 'boolean', 'description' => 'Health check enabled.'], @@ -113,6 +114,8 @@ class Application extends BaseModel protected $appends = ['server_status']; + protected $casts = ['network_aliases' => 'array']; + protected static function booted() { static::addGlobalScope('withRelations', function ($builder) { diff --git a/database/migrations/2025_01_05_050736_add_network_aliases_to_applications_table.php b/database/migrations/2025_01_05_050736_add_network_aliases_to_applications_table.php new file mode 100644 index 000000000..a4e8018a0 --- /dev/null +++ b/database/migrations/2025_01_05_050736_add_network_aliases_to_applications_table.php @@ -0,0 +1,22 @@ +text('network_aliases')->nullable(); + }); + } + + public function down() + { + Schema::table('applications', function (Blueprint $table) { + $table->dropColumn('network_aliases'); + }); + } +}; diff --git a/resources/views/livewire/project/application/general.blade.php b/resources/views/livewire/project/application/general.blade.php index 4812fd4ba..b5a41f705 100644 --- a/resources/views/livewire/project/application/general.blade.php +++ b/resources/views/livewire/project/application/general.blade.php @@ -307,6 +307,11 @@ @endif + @if ($application->build_pack === 'dockerfile' || $application->build_pack === 'dockerimage') + + @endif