diff --git a/app/Livewire/Project/Application/Advanced.php b/app/Livewire/Project/Application/Advanced.php index 278cab5a1..d35867e8f 100644 --- a/app/Livewire/Project/Application/Advanced.php +++ b/app/Livewire/Project/Application/Advanced.php @@ -27,6 +27,8 @@ class Advanced extends Component 'application.settings.gpu_count' => 'string|required', 'application.settings.gpu_device_ids' => 'string|required', 'application.settings.gpu_options' => 'string|required', + 'application.settings.is_raw_compose_deployment_enabled' => 'boolean|required', + 'application.settings.connect_to_docker_network' => 'boolean|required', ]; public function mount() { $this->is_force_https_enabled = $this->application->isForceHttpsEnabled(); @@ -54,8 +56,14 @@ class Advanced extends Component $this->application->settings->is_stripprefix_enabled = $this->is_stripprefix_enabled; $this->dispatch('resetDefaultLabels', false); } + if ($this->application->settings->is_raw_compose_deployment_enabled) { + $this->application->parseRawCompose(); + } else { + $this->application->parseCompose(); + } $this->application->settings->save(); $this->dispatch('success', 'Settings saved.'); + $this->dispatch('configurationChanged'); } public function submit() { if ($this->application->settings->gpu_count && $this->application->settings->gpu_device_ids) { diff --git a/app/Livewire/Project/Application/General.php b/app/Livewire/Project/Application/General.php index 022a7b710..6926e52cb 100644 --- a/app/Livewire/Project/Application/General.php +++ b/app/Livewire/Project/Application/General.php @@ -34,7 +34,8 @@ class General extends Component public $parsedServiceDomains = []; protected $listeners = [ - 'resetDefaultLabels' + 'resetDefaultLabels', + 'configurationChanged' => '$refresh' ]; protected $rules = [ 'application.name' => 'required', @@ -72,7 +73,6 @@ class General extends Component 'application.post_deployment_command' => 'nullable', 'application.post_deployment_command_container' => 'nullable', 'application.settings.is_static' => 'boolean|required', - 'application.settings.is_raw_compose_deployment_enabled' => 'boolean|required', 'application.settings.is_build_server_enabled' => 'boolean|required', 'application.watch_paths' => 'nullable', ]; @@ -108,7 +108,6 @@ class General extends Component 'application.docker_compose_custom_start_command' => 'Docker compose custom start command', 'application.docker_compose_custom_build_command' => 'Docker compose custom build command', 'application.settings.is_static' => 'Is static', - 'application.settings.is_raw_compose_deployment_enabled' => 'Is raw compose deployment enabled', 'application.settings.is_build_server_enabled' => 'Is build server enabled', 'application.watch_paths' => 'Watch paths', ]; @@ -337,11 +336,6 @@ class General extends Component check_domain_usage(resource: $this->application); } } - if ($this->application->settings->is_raw_compose_deployment_enabled) { - $this->application->parseRawCompose(); - } else { - $this->parsedServices = $this->application->parseCompose(); - } } $this->application->custom_labels = base64_encode($this->customLabels); $this->application->save(); diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.php index 966b1db59..25c8cfb81 100644 --- a/bootstrap/helpers/shared.php +++ b/bootstrap/helpers/shared.php @@ -1424,6 +1424,14 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal foreach ($definedNetwork as $key => $network) { $networks->put($network, null); } + if (data_get($resource, 'settings.connect_to_docker_network')) { + $network = $resource->destination->network; + $networks->put($network, null); + $topLevelNetworks->put($network, [ + 'name' => $network, + 'external' => true + ]); + } data_set($service, 'networks', $networks->toArray()); // Get variables from the service foreach ($serviceVariables as $variableName => $variable) { @@ -1585,7 +1593,6 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal $fqdns = data_get($domains, "$serviceName.domain"); if ($fqdns) { $fqdns = str($fqdns)->explode(','); - $uuid = new Cuid2(7); if ($pull_request_id !== 0) { $fqdns = $fqdns->map(function ($fqdn) use ($pull_request_id, $resource) { $preview = ApplicationPreview::findPreviewByApplicationAndPullId($resource->id, $pull_request_id); @@ -1604,13 +1611,13 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal }); } $serviceLabels = $serviceLabels->merge(fqdnLabelsForTraefik( - uuid: $uuid, + uuid: $resource->uuid, domains: $fqdns, serviceLabels: $serviceLabels )); $serviceLabels = $serviceLabels->merge(fqdnLabelsForCaddy( network: $resource->destination->network, - uuid: $uuid, + uuid: $resource->uuid, domains: $fqdns, serviceLabels: $serviceLabels )); diff --git a/database/migrations/2024_04_25_073615_add_docker_network_to_application_settings.php b/database/migrations/2024_04_25_073615_add_docker_network_to_application_settings.php new file mode 100644 index 000000000..aeae6f77d --- /dev/null +++ b/database/migrations/2024_04_25_073615_add_docker_network_to_application_settings.php @@ -0,0 +1,29 @@ +boolean('connect_to_docker_network')->default(false); + + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('application_settings', function (Blueprint $table) { + $table->dropColumn('connect_to_docker_network'); + }); + } +}; diff --git a/resources/views/livewire/project/application/advanced.blade.php b/resources/views/livewire/project/application/advanced.blade.php index 75a55c5b9..5d2922a7e 100644 --- a/resources/views/livewire/project/application/advanced.blade.php +++ b/resources/views/livewire/project/application/advanced.blade.php @@ -25,8 +25,21 @@ instantSave id="is_gzip_enabled" /> -

Logs

+ @if ($application->build_pack === 'dockercompose') + + @endif + @if ($application->build_pack === 'dockercompose') +

Network

+
+ +
+ @endif @if (!$application->settings->is_raw_compose_deployment_enabled) +

Logs

@endif diff --git a/resources/views/livewire/project/application/general.blade.php b/resources/views/livewire/project/application/general.blade.php index 558db9c3c..de83b03ee 100644 --- a/resources/views/livewire/project/application/general.blade.php +++ b/resources/views/livewire/project/application/general.blade.php @@ -4,7 +4,7 @@

General

Save - +
General configuration for your application.
@@ -38,13 +38,8 @@
@endif @if ($application->build_pack === 'dockercompose') -
- -
@if (count($parsedServices) > 0 && !$application->settings->is_raw_compose_deployment_enabled) -

Domains

+

Domains

@foreach (data_get($parsedServices, 'services') as $serviceName => $service) @if (!isDatabaseImage(data_get($service, 'image')))