Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

fix: custom container name will be the container name, not just internal network name

Andras Bacsai1249b1ece9cb
diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php
index b53c56d1c8..229cb2532e 100644
--- a/app/Jobs/ApplicationDeploymentJob.php
+++ b/app/Jobs/ApplicationDeploymentJob.php
@@ -194,6 +194,9 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue
$this->is_debug_enabled = $this->application->settings->is_debug_enabled;
$this->container_name = generateApplicationContainerName($this->application, $this->pull_request_id);
+ if ($this->application->settings->custom_internal_name && ! $this->application->settings->is_consistent_container_name_enabled) {
+ $this->container_name = $this->application->settings->custom_internal_name;
+ }
ray('New container name: ', $this->container_name);
savePrivateKeyToFs($this->server);
@@ -1570,23 +1573,6 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue
],
],
];
- if (isset($this->application->settings->custom_internal_name)) {
- $docker_compose['services'][$this->container_name]['networks'][$this->destination->network]['aliases'][] = $this->application->settings->custom_internal_name;
- }
- // if (str($this->saved_outputs->get('dotenv'))->isNotEmpty()) {
- // if (data_get($docker_compose, "services.{$this->container_name}.env_file")) {
- // $docker_compose['services'][$this->container_name]['env_file'][] = '.env';
- // } else {
- // $docker_compose['services'][$this->container_name]['env_file'] = ['.env'];
- // }
- // }
- // if ($this->env_filename) {
- // if (data_get($docker_compose, "services.{$this->container_name}.env_file")) {
- // $docker_compose['services'][$this->container_name]['env_file'][] = $this->env_filename;
- // } else {
- // $docker_compose['services'][$this->container_name]['env_file'] = [$this->env_filename];
- // }
- // }
if (! is_null($this->env_filename)) {
$docker_compose['services'][$this->container_name]['env_file'] = [$this->env_filename];
}
@@ -1697,32 +1683,28 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue
if (count($volume_names) > 0) {
$docker_compose['volumes'] = $volume_names;
}
- // if ($this->build_pack === 'dockerfile') {
- // $docker_compose['services'][$this->container_name]['build'] = [
- // 'context' => $this->workdir,
- // 'dockerfile' => $this->workdir . $this->dockerfile_location,
- // ];
- // }
if ($this->pull_request_id === 0) {
$custom_compose = convert_docker_run_to_compose($this->application->custom_docker_run_options);
if ((bool) $this->application->settings->is_consistent_container_name_enabled) {
- $docker_compose['services'][$this->application->uuid] = $docker_compose['services'][$this->container_name];
- if (count($custom_compose) > 0) {
- $ipv4 = data_get($custom_compose, 'ip.0');
- $ipv6 = data_get($custom_compose, 'ip6.0');
- data_forget($custom_compose, 'ip');
- data_forget($custom_compose, 'ip6');
- if ($ipv4 || $ipv6) {
- data_forget($docker_compose['services'][$this->application->uuid], 'networks');
- }
- if ($ipv4) {
- $docker_compose['services'][$this->application->uuid]['networks'][$this->destination->network]['ipv4_address'] = $ipv4;
- }
- if ($ipv6) {
- $docker_compose['services'][$this->application->uuid]['networks'][$this->destination->network]['ipv6_address'] = $ipv6;
+ if (! $this->application->settings->custom_internal_name) {
+ $docker_compose['services'][$this->application->uuid] = $docker_compose['services'][$this->container_name];
+ if (count($custom_compose) > 0) {
+ $ipv4 = data_get($custom_compose, 'ip.0');
+ $ipv6 = data_get($custom_compose, 'ip6.0');
+ data_forget($custom_compose, 'ip');
+ data_forget($custom_compose, 'ip6');
+ if ($ipv4 || $ipv6) {
+ data_forget($docker_compose['services'][$this->application->uuid], 'networks');
+ }
+ if ($ipv4) {
+ $docker_compose['services'][$this->application->uuid]['networks'][$this->destination->network]['ipv4_address'] = $ipv4;
+ }
+ if ($ipv6) {
+ $docker_compose['services'][$this->application->uuid]['networks'][$this->destination->network]['ipv6_address'] = $ipv6;
+ }
+ $docker_compose['services'][$this->application->uuid] = array_merge_recursive($docker_compose['services'][$this->application->uuid], $custom_compose);
}
- $docker_compose['services'][$this->application->uuid] = array_merge_recursive($docker_compose['services'][$this->application->uuid], $custom_compose);
}
} else {
if (count($custom_compose) > 0) {
diff --git a/resources/views/livewire/project/application/advanced.blade.php b/resources/views/livewire/project/application/advanced.blade.php
index ff96b228a1..19cb64a05b 100644
--- a/resources/views/livewire/project/application/advanced.blade.php
+++ b/resources/views/livewire/project/application/advanced.blade.php
@@ -31,12 +31,14 @@
helper="The deployed container will have the same name ({{ $application->uuid }}). <span class='font-bold dark:text-warning'>You will lose the rolling update feature!</span>"
instantSave id="application.settings.is_consistent_container_name_enabled"
label="Consistent Container Names" />
- <form class="flex items-end gap-2 pl-2" wire:submit.prevent='saveCustomName'>
- <x-forms.input
- helper="You can add a custom internal name for your container. This name will be used in the internal network. <br><br>The name will be converted to slug format when you save it. <span class='font-bold dark:text-warning'>You will lose the rolling update feature!</span>"
- instantSave id="application.settings.custom_internal_name" label="Add Custom Internal Name" />
- <x-forms.button type="submit">Save</x-forms.button>
- </form>
+ @if (!$application->settings->is_consistent_container_name_enabled)
+ <form class="flex items-end gap-2 pl-2" wire:submit.prevent='saveCustomName'>
+ <x-forms.input
+ helper="You can add a custom name for your container.<br><br>The name will be converted to slug format when you save it. <span class='font-bold dark:text-warning'>You will lose the rolling update feature!</span>"
+ instantSave id="application.settings.custom_internal_name" label="Custom Container Name" />
+ <x-forms.button type="submit">Save</x-forms.button>
+ </form>
+ @endif
@if ($application->build_pack === 'dockercompose')
<h3>Network</h3>
<x-forms.checkbox instantSave id="application.settings.connect_to_docker_network"