Merge pull request #1548 from coollabsio/next
fix: compose domains & links
This commit is contained in:
commit
f1aa97e374
@ -146,7 +146,6 @@ class General extends Component
|
|||||||
$this->parsedServiceDomains[$serviceName]['domain'] = $domain;
|
$this->parsedServiceDomains[$serviceName]['domain'] = $domain;
|
||||||
$this->application->docker_compose_domains = json_encode($this->parsedServiceDomains);
|
$this->application->docker_compose_domains = json_encode($this->parsedServiceDomains);
|
||||||
$this->application->save();
|
$this->application->save();
|
||||||
$this->dispatch('success', 'Domain generated.');
|
|
||||||
}
|
}
|
||||||
return $domain;
|
return $domain;
|
||||||
}
|
}
|
||||||
|
@ -966,66 +966,79 @@ class Application extends BaseModel
|
|||||||
function loadComposeFile($isInit = false)
|
function loadComposeFile($isInit = false)
|
||||||
{
|
{
|
||||||
$initialDockerComposeLocation = $this->docker_compose_location;
|
$initialDockerComposeLocation = $this->docker_compose_location;
|
||||||
// $initialDockerComposePrLocation = $this->docker_compose_pr_location;
|
if ($isInit && $this->docker_compose_raw) {
|
||||||
if ($this->build_pack === 'dockercompose') {
|
return;
|
||||||
if ($isInit && $this->docker_compose_raw) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$uuid = new Cuid2();
|
|
||||||
['commands' => $cloneCommand] = $this->generateGitImportCommands(deployment_uuid: $uuid, only_checkout: true, exec_in_docker: false, custom_base_dir: '.');
|
|
||||||
$workdir = rtrim($this->base_directory, '/');
|
|
||||||
$composeFile = $this->docker_compose_location;
|
|
||||||
// $prComposeFile = $this->docker_compose_pr_location;
|
|
||||||
$fileList = collect([".$workdir$composeFile"]);
|
|
||||||
// if ($composeFile !== $prComposeFile) {
|
|
||||||
// $fileList->push(".$prComposeFile");
|
|
||||||
// }
|
|
||||||
$commands = collect([
|
|
||||||
"mkdir -p /tmp/{$uuid} && cd /tmp/{$uuid}",
|
|
||||||
$cloneCommand,
|
|
||||||
"git sparse-checkout init --cone",
|
|
||||||
"git sparse-checkout set {$fileList->implode(' ')}",
|
|
||||||
"git read-tree -mu HEAD",
|
|
||||||
"cat .$workdir$composeFile",
|
|
||||||
]);
|
|
||||||
$composeFileContent = instant_remote_process($commands, $this->destination->server, false);
|
|
||||||
if (!$composeFileContent) {
|
|
||||||
$this->docker_compose_location = $initialDockerComposeLocation;
|
|
||||||
$this->save();
|
|
||||||
throw new \Exception("Could not load base compose file from $workdir$composeFile");
|
|
||||||
} else {
|
|
||||||
$this->docker_compose_raw = $composeFileContent;
|
|
||||||
$this->save();
|
|
||||||
}
|
|
||||||
// if ($composeFile === $prComposeFile) {
|
|
||||||
// $this->docker_compose_pr_raw = $composeFileContent;
|
|
||||||
// $this->save();
|
|
||||||
// } else {
|
|
||||||
// $commands = collect([
|
|
||||||
// "cd /tmp/{$uuid}",
|
|
||||||
// "cat .$workdir$prComposeFile",
|
|
||||||
// ]);
|
|
||||||
// $composePrFileContent = instant_remote_process($commands, $this->destination->server, false);
|
|
||||||
// if (!$composePrFileContent) {
|
|
||||||
// $this->docker_compose_pr_location = $initialDockerComposePrLocation;
|
|
||||||
// $this->save();
|
|
||||||
// throw new \Exception("Could not load compose file from $workdir$prComposeFile");
|
|
||||||
// } else {
|
|
||||||
// $this->docker_compose_pr_raw = $composePrFileContent;
|
|
||||||
// $this->save();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
$commands = collect([
|
|
||||||
"rm -rf /tmp/{$uuid}",
|
|
||||||
]);
|
|
||||||
instant_remote_process($commands, $this->destination->server, false);
|
|
||||||
return [
|
|
||||||
'parsedServices' => $this->parseCompose(),
|
|
||||||
'initialDockerComposeLocation' => $this->docker_compose_location,
|
|
||||||
'initialDockerComposePrLocation' => $this->docker_compose_pr_location,
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
$uuid = new Cuid2();
|
||||||
|
['commands' => $cloneCommand] = $this->generateGitImportCommands(deployment_uuid: $uuid, only_checkout: true, exec_in_docker: false, custom_base_dir: '.');
|
||||||
|
$workdir = rtrim($this->base_directory, '/');
|
||||||
|
$composeFile = $this->docker_compose_location;
|
||||||
|
// $prComposeFile = $this->docker_compose_pr_location;
|
||||||
|
$fileList = collect([".$workdir$composeFile"]);
|
||||||
|
// if ($composeFile !== $prComposeFile) {
|
||||||
|
// $fileList->push(".$prComposeFile");
|
||||||
|
// }
|
||||||
|
$commands = collect([
|
||||||
|
"mkdir -p /tmp/{$uuid} && cd /tmp/{$uuid}",
|
||||||
|
$cloneCommand,
|
||||||
|
"git sparse-checkout init --cone",
|
||||||
|
"git sparse-checkout set {$fileList->implode(' ')}",
|
||||||
|
"git read-tree -mu HEAD",
|
||||||
|
"cat .$workdir$composeFile",
|
||||||
|
]);
|
||||||
|
$composeFileContent = instant_remote_process($commands, $this->destination->server, false);
|
||||||
|
if (!$composeFileContent) {
|
||||||
|
$this->docker_compose_location = $initialDockerComposeLocation;
|
||||||
|
$this->save();
|
||||||
|
throw new \Exception("Could not load base compose file from $workdir$composeFile");
|
||||||
|
} else {
|
||||||
|
$this->docker_compose_raw = $composeFileContent;
|
||||||
|
$this->save();
|
||||||
|
}
|
||||||
|
// if ($composeFile === $prComposeFile) {
|
||||||
|
// $this->docker_compose_pr_raw = $composeFileContent;
|
||||||
|
// $this->save();
|
||||||
|
// } else {
|
||||||
|
// $commands = collect([
|
||||||
|
// "cd /tmp/{$uuid}",
|
||||||
|
// "cat .$workdir$prComposeFile",
|
||||||
|
// ]);
|
||||||
|
// $composePrFileContent = instant_remote_process($commands, $this->destination->server, false);
|
||||||
|
// if (!$composePrFileContent) {
|
||||||
|
// $this->docker_compose_pr_location = $initialDockerComposePrLocation;
|
||||||
|
// $this->save();
|
||||||
|
// throw new \Exception("Could not load compose file from $workdir$prComposeFile");
|
||||||
|
// } else {
|
||||||
|
// $this->docker_compose_pr_raw = $composePrFileContent;
|
||||||
|
// $this->save();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
$commands = collect([
|
||||||
|
"rm -rf /tmp/{$uuid}",
|
||||||
|
]);
|
||||||
|
instant_remote_process($commands, $this->destination->server, false);
|
||||||
|
$parsedServices = $this->parseCompose();
|
||||||
|
if ($this->docker_compose_domains) {
|
||||||
|
$json = collect(json_decode($this->docker_compose_domains));
|
||||||
|
$names = collect(data_get($parsedServices, 'services'))->keys()->toArray();
|
||||||
|
$jsonNames = $json->keys()->toArray();
|
||||||
|
$diff = array_diff($jsonNames, $names);
|
||||||
|
$json = $json->filter(function ($value, $key) use ($diff) {
|
||||||
|
return !in_array($key, $diff);
|
||||||
|
});
|
||||||
|
if ($json) {
|
||||||
|
$this->docker_compose_domains = json_encode($json);
|
||||||
|
} else {
|
||||||
|
$this->docker_compose_domains = null;
|
||||||
|
}
|
||||||
|
$this->save();
|
||||||
|
}
|
||||||
|
return [
|
||||||
|
'parsedServices' => $parsedServices,
|
||||||
|
'initialDockerComposeLocation' => $this->docker_compose_location,
|
||||||
|
'initialDockerComposePrLocation' => $this->docker_compose_pr_location,
|
||||||
|
];
|
||||||
}
|
}
|
||||||
function parseContainerLabels(?ApplicationPreview $preview = null)
|
function parseContainerLabels(?ApplicationPreview $preview = null)
|
||||||
{
|
{
|
||||||
|
@ -23,20 +23,22 @@
|
|||||||
@if (data_get($application, 'build_pack') === 'dockercompose')
|
@if (data_get($application, 'build_pack') === 'dockercompose')
|
||||||
@foreach (collect(json_decode($this->application->docker_compose_domains)) as $fqdn)
|
@foreach (collect(json_decode($this->application->docker_compose_domains)) as $fqdn)
|
||||||
@if (data_get($fqdn, 'domain'))
|
@if (data_get($fqdn, 'domain'))
|
||||||
<li>
|
@foreach (explode(',', data_get($fqdn, 'domain')) as $domain)
|
||||||
<a class="text-xs text-white rounded-none hover:no-underline hover:bg-coollabs hover:text-white"
|
<li>
|
||||||
target="_blank" href="{{ getFqdnWithoutPort(data_get($fqdn, 'domain')) }}">
|
<a class="text-xs text-white rounded-none hover:no-underline hover:bg-coollabs hover:text-white"
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" class="w-6 h-6" viewBox="0 0 24 24"
|
target="_blank" href="{{ getFqdnWithoutPort($domain) }}">
|
||||||
stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round"
|
<svg xmlns="http://www.w3.org/2000/svg" class="w-6 h-6" viewBox="0 0 24 24"
|
||||||
stroke-linejoin="round">
|
stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round"
|
||||||
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
stroke-linejoin="round">
|
||||||
<path d="M9 15l6 -6" />
|
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
||||||
<path d="M11 6l.463 -.536a5 5 0 0 1 7.071 7.072l-.534 .464" />
|
<path d="M9 15l6 -6" />
|
||||||
<path
|
<path d="M11 6l.463 -.536a5 5 0 0 1 7.071 7.072l-.534 .464" />
|
||||||
d="M13 18l-.397 .534a5.068 5.068 0 0 1 -7.127 0a4.972 4.972 0 0 1 0 -7.071l.524 -.463" />
|
<path
|
||||||
</svg>{{ getFqdnWithoutPort(data_get($fqdn, 'domain')) }}
|
d="M13 18l-.397 .534a5.068 5.068 0 0 1 -7.127 0a4.972 4.972 0 0 1 0 -7.071l.524 -.463" />
|
||||||
</a>
|
</svg>{{ getFqdnWithoutPort($domain) }}
|
||||||
</li>
|
</a>
|
||||||
|
</li>
|
||||||
|
@endforeach
|
||||||
@endif
|
@endif
|
||||||
@endforeach
|
@endforeach
|
||||||
@endif
|
@endif
|
||||||
|
@ -230,14 +230,7 @@
|
|||||||
<li class="step step-secondary">Select a Server</li>
|
<li class="step step-secondary">Select a Server</li>
|
||||||
<li class="step step-secondary">Select a Destination</li>
|
<li class="step step-secondary">Select a Destination</li>
|
||||||
</ul>
|
</ul>
|
||||||
<a wire:navigate href="{{ route('destination.new', ['server_id' => $server_id]) }}"
|
|
||||||
class="items-center justify-center pb-10 text-center box-without-bg group bg-coollabs hover:bg-coollabs-100">
|
|
||||||
<div class="flex flex-col mx-6 ">
|
|
||||||
<div class="font-bold text-white">
|
|
||||||
+ Add New
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</a>
|
|
||||||
<div class="flex flex-col justify-center gap-2 text-left xl:flex-row xl:flex-wrap">
|
<div class="flex flex-col justify-center gap-2 text-left xl:flex-row xl:flex-wrap">
|
||||||
|
|
||||||
@foreach ($standaloneDockers as $standaloneDocker)
|
@foreach ($standaloneDockers as $standaloneDocker)
|
||||||
@ -260,6 +253,14 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
<a wire:navigate href="{{ route('destination.new', ['server_id' => $server_id]) }}"
|
||||||
|
class="items-center justify-center pb-10 text-center box-without-bg group bg-coollabs hover:bg-coollabs-100">
|
||||||
|
<div class="flex flex-col mx-6 ">
|
||||||
|
<div class="font-bold text-white">
|
||||||
|
+ Add New
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
@if ($current_step === 'existing-postgresql')
|
@if ($current_step === 'existing-postgresql')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user