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.

feat: able to add several domains to compose based previews

Andras Bacsai7fd0deedb14a
diff --git a/app/Console/Commands/ServicesGenerate.php b/app/Console/Commands/ServicesGenerate.php
index 8ad4dcde38..0471e23246 100644
--- a/app/Console/Commands/ServicesGenerate.php
+++ b/app/Console/Commands/ServicesGenerate.php
@@ -26,7 +26,6 @@ class ServicesGenerate extends Command
*/
public function handle()
{
- // ray()->clearAll();
$files = array_diff(scandir(base_path('templates/compose')), ['.', '..']);
$files = array_filter($files, function ($file) {
return strpos($file, '.yaml') !== false;
diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php
index d5e60412ac..8a949da5a4 100644
--- a/app/Jobs/ApplicationDeploymentJob.php
+++ b/app/Jobs/ApplicationDeploymentJob.php
@@ -113,7 +113,6 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
public $tries = 1;
public function __construct(int $application_deployment_queue_id)
{
- ray()->clearAll();
$this->application_deployment_queue = ApplicationDeploymentQueue::find($application_deployment_queue_id);
$this->application = Application::find($this->application_deployment_queue->application_id);
$this->build_pack = data_get($this->application, 'build_pack');
@@ -373,7 +372,7 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
$yaml = $composeFile = $this->application->docker_compose_raw;
$this->save_environment_variables();
} else {
- $composeFile = $this->application->parseCompose(pull_request_id: $this->pull_request_id);
+ $composeFile = $this->application->parseCompose(pull_request_id: $this->pull_request_id, preview_id: data_get($this, 'preview.id'));
$this->save_environment_variables();
if (!is_null($this->env_filename)) {
$services = collect($composeFile['services']);
diff --git a/app/Livewire/Project/Application/Heading.php b/app/Livewire/Project/Application/Heading.php
index 619be693dc..473d006711 100644
--- a/app/Livewire/Project/Application/Heading.php
+++ b/app/Livewire/Project/Application/Heading.php
@@ -25,6 +25,7 @@ class Heading extends Component
return [
"echo-private:team.{$teamId},ApplicationStatusChanged" => 'check_status',
"compose_loaded" => '$refresh',
+ "update_links" => '$refresh',
];
}
public function mount()
diff --git a/app/Livewire/Project/Application/Previews.php b/app/Livewire/Project/Application/Previews.php
index 1f4a144a90..90815a7557 100644
--- a/app/Livewire/Project/Application/Previews.php
+++ b/app/Livewire/Project/Application/Previews.php
@@ -43,7 +43,7 @@ class Previews extends Component
try {
$success = true;
$preview = $this->application->previews->find($preview_id);
- if (isset($preview->fqdn)) {
+ if (data_get_str($preview, 'fqdn')->isNotEmpty()) {
$preview->fqdn = str($preview->fqdn)->replaceEnd(',', '')->trim();
$preview->fqdn = str($preview->fqdn)->replaceStart(',', '')->trim();
$preview->fqdn = str($preview->fqdn)->trim()->lower();
@@ -79,7 +79,7 @@ class Previews extends Component
$random = new Cuid2(7);
$preview_fqdn = str_replace('{{random}}', $random, $template);
$preview_fqdn = str_replace('{{domain}}', $host, $preview_fqdn);
- $preview_fqdn = str_replace('{{pr_id}}', $preview_id, $preview_fqdn);
+ $preview_fqdn = str_replace('{{pr_id}}', $preview->pull_request_id, $preview_fqdn);
$preview_fqdn = "$schema://$preview_fqdn";
$preview->fqdn = $preview_fqdn;
$preview->save();
@@ -88,17 +88,34 @@ class Previews extends Component
public function add(int $pull_request_id, string|null $pull_request_html_url = null)
{
try {
- $this->setDeploymentUuid();
- $found = ApplicationPreview::where('application_id', $this->application->id)->where('pull_request_id', $pull_request_id)->first();
- if (!$found && !is_null($pull_request_html_url)) {
- ApplicationPreview::create([
- 'application_id' => $this->application->id,
- 'pull_request_id' => $pull_request_id,
- 'pull_request_html_url' => $pull_request_html_url
- ]);
+ if ($this->application->build_pack === 'dockercompose') {
+ $this->setDeploymentUuid();
+ $found = ApplicationPreview::where('application_id', $this->application->id)->where('pull_request_id', $pull_request_id)->first();
+ if (!$found && !is_null($pull_request_html_url)) {
+ $found = ApplicationPreview::create([
+ 'application_id' => $this->application->id,
+ 'pull_request_id' => $pull_request_id,
+ 'pull_request_html_url' => $pull_request_html_url,
+ 'docker_compose_domains' => $this->application->docker_compose_domains,
+ ]);
+ }
+ $found->generate_preview_fqdn_compose();
+ $this->application->refresh();
+ } else {
+ $this->setDeploymentUuid();
+ $found = ApplicationPreview::where('application_id', $this->application->id)->where('pull_request_id', $pull_request_id)->first();
+ if (!$found && !is_null($pull_request_html_url)) {
+ $found = ApplicationPreview::create([
+ 'application_id' => $this->application->id,
+ 'pull_request_id' => $pull_request_id,
+ 'pull_request_html_url' => $pull_request_html_url,
+ ]);
+ }
+ $this->application->generate_preview_fqdn($pull_request_id);
+ $this->application->refresh();
+ $this->dispatch('update_links');
+ $this->dispatch('success', 'Preview added.');
}
- $this->application->generate_preview_fqdn($pull_request_id);
- $this->application->refresh();
} catch (\Throwable $e) {
return handleError($e, $this);
}
@@ -152,7 +169,7 @@ class Previews extends Component
}
}
GetContainersStatus::dispatchSync($this->application->destination->server);
- $this->application->refresh();
+ $this->dispatch('reloadWindow');
} catch (\Throwable $e) {
return handleError($e, $this);
}
@@ -172,15 +189,10 @@ class Previews extends Component
}
ApplicationPreview::where('application_id', $this->application->id)->where('pull_request_id', $pull_request_id)->first()->delete();
$this->application->refresh();
+ $this->dispatch('update_links');
+ $this->dispatch('success', 'Preview deleted.');
} catch (\Throwable $e) {
return handleError($e, $this);
}
}
-
- public function previewRefresh()
- {
- $this->application->previews->each(function ($preview) {
- $preview->refresh();
- });
- }
}
diff --git a/app/Livewire/Project/Application/PreviewsCompose.php b/app/Livewire/Project/Application/PreviewsCompose.php
new file mode 100644
index 0000000000..85d8d81c9f
--- /dev/null
+++ b/app/Livewire/Project/Application/PreviewsCompose.php
@@ -0,0 +1,56 @@
+<?php
+
+namespace App\Livewire\Project\Application;
+
+use App\Models\ApplicationPreview;
+use Livewire\Component;
+use Spatie\Url\Url;
+use Visus\Cuid2\Cuid2;
+
+class PreviewsCompose extends Component
+{
+ public $service;
+ public $serviceName;
+ public ApplicationPreview $preview;
+ public function render()
+ {
+ return view('livewire.project.application.previews-compose');
+ }
+ public function save()
+ {
+ $domain = data_get($this->service, 'domain');
+ $docker_compose_domains = data_get($this->preview, 'docker_compose_domains');
+ $docker_compose_domains = json_decode($docker_compose_domains, true);
+ $docker_compose_domains[$this->serviceName]['domain'] = $domain;
+ $this->preview->docker_compose_domains = json_encode($docker_compose_domains);
+ $this->preview->save();
+ $this->dispatch('update_links');
+ $this->dispatch('success', 'Domain saved.');
+ }
+ public function generate()
+ {
+ $domains = collect(json_decode($this->preview->application->docker_compose_domains)) ?? collect();
+ $domain = $domains->first(function ($_, $key) {
+ return $key === $this->serviceName;
+ });
+ if ($domain) {
+ $domain = data_get($domain, 'domain');
+ $url = Url::fromString($domain);
+ $template = $this->preview->application->preview_url_template;
+ $host = $url->getHost();
+ $schema = $url->getScheme();
+ $random = new Cuid2(7);
+ $preview_fqdn = str_replace('{{random}}', $random, $template);
+ $preview_fqdn = str_replace('{{domain}}', $host, $preview_fqdn);
+ $preview_fqdn = str_replace('{{pr_id}}', $this->preview->pull_request_id, $preview_fqdn);
+ $preview_fqdn = "$schema://$preview_fqdn";
+ $docker_compose_domains = data_get($this->preview, 'docker_compose_domains');
+ $docker_compose_domains = json_decode($docker_compose_domains, true);
+ $docker_compose_domains[$this->serviceName]['domain'] = $this->service->domain = $preview_fqdn;
+ $this->preview->docker_compose_domains = json_encode($docker_compose_domains);
+ $this->preview->save();
+ }
+ $this->dispatch('update_links');
+ $this->dispatch('success', 'Domain generated.');
+ }
+}
diff --git a/app/Models/Application.php b/app/Models/Application.php
index e0ed328f9c..e606735df1 100644
--- a/app/Models/Application.php
+++ b/app/Models/Application.php
@@ -861,14 +861,10 @@ class Application extends BaseModel
instant_remote_process($commands, $this->destination->server, false);
}
- function parseCompose(int $pull_request_id = 0)
+ function parseCompose(int $pull_request_id = 0, ?int $preview_id = null)
{
if ($this->docker_compose_raw) {
- $mainCompose = parseDockerComposeFile(resource: $this, isNew: false, pull_request_id: $pull_request_id);
- if ($this->getMorphClass() === 'App\Models\Application' && $this->docker_compose_pr_raw) {
- parseDockerComposeFile(resource: $this, isNew: false, pull_request_id: $pull_request_id, is_pr: true);
- }
- return $mainCompose;
+ return parseDockerComposeFile(resource: $this, isNew: false, pull_request_id: $pull_request_id, preview_id: $preview_id);
} else {
return collect([]);
}
@@ -1052,7 +1048,8 @@ class Application extends BaseModel
}
}
}
- function generate_preview_fqdn(int $pull_request_id) {
+ function generate_preview_fqdn(int $pull_request_id)
+ {
$preview = ApplicationPreview::findPreviewByApplicationAndPullId($this->id, $pull_request_id);
if (is_null(data_get($preview, 'fqdn')) && $this->fqdn) {
if (str($this->fqdn)->contains(',')) {
diff --git a/app/Models/ApplicationPreview.php b/app/Models/ApplicationPreview.php
index 87dce056e7..7c7297af27 100644
--- a/app/Models/ApplicationPreview.php
+++ b/app/Models/ApplicationPreview.php
@@ -2,6 +2,9 @@
namespace App\Models;
+use Spatie\Url\Url;
+use Visus\Cuid2\Cuid2;
+
class ApplicationPreview extends BaseModel
{
protected $guarded = [];
@@ -34,4 +37,26 @@ class ApplicationPreview extends BaseModel
{
return $this->belongsTo(Application::class);
}
+ function generate_preview_fqdn_compose()
+ {
+ $domains = collect(json_decode($this->application->docker_compose_domains)) ?? collect();
+ foreach ($domains as $service_name => $domain) {
+ $domain = data_get($domain, 'domain');
+ $url = Url::fromString($domain);
+ $template = $this->application->preview_url_template;
+ $host = $url->getHost();
+ $schema = $url->getScheme();
+ $random = new Cuid2(7);
+ $preview_fqdn = str_replace('{{random}}', $random, $template);
+ $preview_fqdn = str_replace('{{domain}}', $host, $preview_fqdn);
+ $preview_fqdn = str_replace('{{pr_id}}', $this->pull_request_id, $preview_fqdn);
+ $preview_fqdn = "$schema://$preview_fqdn";
+ $docker_compose_domains = data_get($this, 'docker_compose_domains');
+ $docker_compose_domains = json_decode($docker_compose_domains, true);
+ $docker_compose_domains[$service_name]['domain'] = $preview_fqdn;
+ $docker_compose_domains = json_encode($docker_compose_domains);
+ $this->docker_compose_domains = $docker_compose_domains;
+ $this->save();
+ }
+ }
}
diff --git a/bootstrap/helpers/docker.php b/bootstrap/helpers/docker.php
index 0ce5787586..fb980c2962 100644
--- a/bootstrap/helpers/docker.php
+++ b/bootstrap/helpers/docker.php
@@ -488,8 +488,10 @@ function generateLabelsApplication(Application $application, ?ApplicationPreview
));
}
} else {
- if ($preview->fqdn) {
+ if (data_get($preview,'fqdn')) {
$domains = Str::of(data_get($preview, 'fqdn'))->explode(',');
+ } else {
+ $domains = collect([]);
}
$labels = $labels->merge(fqdnLabelsForTraefik(
uuid: $appUuid,
diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.php
index 240d78b33e..d6b0523952 100644
--- a/bootstrap/helpers/shared.php
+++ b/bootstrap/helpers/shared.php
@@ -657,9 +657,8 @@ function getTopLevelNetworks(Service|Application $resource)
}
}
-function parseDockerComposeFile(Service|Application $resource, bool $isNew = false, int $pull_request_id = 0, bool $is_pr = false)
+function parseDockerComposeFile(Service|Application $resource, bool $isNew = false, int $pull_request_id = 0, ?int $preview_id = null)
{
- // ray()->clearAll();
if ($resource->getMorphClass() === 'App\Models\Service') {
if ($resource->docker_compose_raw) {
try {
@@ -1283,20 +1282,11 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal
$isSameDockerComposeFile = false;
if ($resource->dockerComposePrLocation() === $resource->dockerComposeLocation()) {
$isSameDockerComposeFile = true;
- $is_pr = false;
}
- if ($is_pr) {
- try {
- $yaml = Yaml::parse($resource->docker_compose_pr_raw);
- } catch (\Exception $e) {
- return;
- }
- } else {
- try {
- $yaml = Yaml::parse($resource->docker_compose_raw);
- } catch (\Exception $e) {
- return;
- }
+ try {
+ $yaml = Yaml::parse($resource->docker_compose_raw);
+ } catch (\Exception $e) {
+ return;
}
$server = $resource->destination->server;
$topLevelVolumes = collect(data_get($yaml, 'volumes', []));
@@ -1330,7 +1320,7 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal
if ($pull_request_id !== 0) {
$definedNetwork = collect(["{$resource->uuid}-$pull_request_id"]);
}
- $services = collect($services)->map(function ($service, $serviceName) use ($topLevelVolumes, $topLevelNetworks, $definedNetwork, $isNew, $generatedServiceFQDNS, $resource, $server, $pull_request_id) {
+ $services = collect($services)->map(function ($service, $serviceName) use ($topLevelVolumes, $topLevelNetworks, $definedNetwork, $isNew, $generatedServiceFQDNS, $resource, $server, $pull_request_id, $preview_id) {
$serviceVolumes = collect(data_get($service, 'volumes', []));
$servicePorts = collect(data_get($service, 'ports', []));
$serviceNetworks = collect(data_get($service, 'networks', []));
@@ -1716,21 +1706,14 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal
if ($fqdns) {
$fqdns = str($fqdns)->explode(',');
if ($pull_request_id !== 0) {
- $fqdns = $fqdns->map(function ($fqdn) use ($pull_request_id, $resource) {
- $preview = ApplicationPreview::findPreviewByApplicationAndPullId($resource->id, $pull_request_id);
- $url = Url::fromString($fqdn);
- $template = $resource->preview_url_template;
- $host = $url->getHost();
- $schema = $url->getScheme();
- $random = new Cuid2(7);
- $preview_fqdn = str_replace('{{random}}', $random, $template);
- $preview_fqdn = str_replace('{{domain}}', $host, $preview_fqdn);
- $preview_fqdn = str_replace('{{pr_id}}', $pull_request_id, $preview_fqdn);
- $preview_fqdn = "$schema://$preview_fqdn";
- $preview->fqdn = $preview_fqdn;
- $preview->save();
- return $preview_fqdn;
- });
+ $preview = $resource->previews()->find($preview_id);
+ $docker_compose_domains = collect(json_decode(data_get($preview, 'docker_compose_domains')));
+ $found_fqdn = data_get($docker_compose_domains, "$serviceName.domain");
+ if ($found_fqdn) {
+ $fqdns = collect($found_fqdn);
+ } else {
+ $fqdns = collect([]);
+ }
}
$serviceLabels = $serviceLabels->merge(fqdnLabelsForTraefik(
uuid: $resource->uuid,
@@ -1797,13 +1780,8 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal
$resource->docker_compose_raw = Yaml::dump($yaml, 10, 2);
$resource->docker_compose = Yaml::dump($finalServices, 10, 2);
} else {
- if ($is_pr) {
- $resource->docker_compose_pr_raw = Yaml::dump($yaml, 10, 2);
- $resource->docker_compose_pr = Yaml::dump($finalServices, 10, 2);
- } else {
- $resource->docker_compose_raw = Yaml::dump($yaml, 10, 2);
- $resource->docker_compose = Yaml::dump($finalServices, 10, 2);
- }
+ $resource->docker_compose_raw = Yaml::dump($yaml, 10, 2);
+ $resource->docker_compose = Yaml::dump($finalServices, 10, 2);
}
$resource->save();
return collect($finalServices);
diff --git a/database/migrations/2024_06_05_101019_add_docker_compose_pr_domains.php b/database/migrations/2024_06_05_101019_add_docker_compose_pr_domains.php
new file mode 100644
index 0000000000..a4b8ea35b8
--- /dev/null
+++ b/database/migrations/2024_06_05_101019_add_docker_compose_pr_domains.php
@@ -0,0 +1,28 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration
+{
+ /**
+ * Run the migrations.
+ */
+ public function up(): void
+ {
+ Schema::table('application_previews', function (Blueprint $table) {
+ $table->text('docker_compose_domains')->nullable();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down(): void
+ {
+ Schema::table('application_previews', function (Blueprint $table) {
+ $table->dropColumn('docker_compose_domains');
+ });
+ }
+};
diff --git a/resources/views/components/applications/links.blade.php b/resources/views/components/applications/links.blade.php
index a14d0e3aef..cf9e9c0291 100644
--- a/resources/views/components/applications/links.blade.php
+++ b/resources/views/components/applications/links.blade.php
@@ -45,24 +45,48 @@
</a>
@endforeach
@endif
- @if (data_get($application, 'previews', collect([]))->count() > 0)
- @foreach (data_get($application, 'previews') as $preview)
- @if (data_get($preview, 'fqdn'))
- <a class="dropdown-item" target="_blank"
- href="{{ getFqdnWithoutPort(data_get($preview, 'fqdn')) }}">
- <svg xmlns="http://www.w3.org/2000/svg" class="w-6 h-6" viewBox="0 0 24 24" stroke-width="1.5"
- stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
- <path stroke="none" d="M0 0h24v24H0z" fill="none" />
- <path d="M9 15l6 -6" />
- <path d="M11 6l.463 -.536a5 5 0 0 1 7.071 7.072l-.534 .464" />
- <path
- 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" />
- </svg>
- PR{{ data_get($preview, 'pull_request_id') }} |
- {{ data_get($preview, 'fqdn') }}
- </a>
- @endif
- @endforeach
+ @if (data_get($application, 'previews', collect())->count() > 0)
+ @if (data_get($application, 'build_pack') === 'dockercompose')
+ @foreach ($application->previews as $preview)
+ @foreach (collect(json_decode($preview->docker_compose_domains)) as $fqdn)
+ @if (data_get($fqdn, 'domain'))
+ @foreach (explode(',', data_get($fqdn, 'domain')) as $domain)
+ <a class="dropdown-item" target="_blank" href="{{ getFqdnWithoutPort($domain) }}">
+ <svg xmlns="http://www.w3.org/2000/svg" class="w-6 h-6" viewBox="0 0 24 24"
+ stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round"
+ stroke-linejoin="round">
+ <path stroke="none" d="M0 0h24v24H0z" fill="none" />
+ <path d="M9 15l6 -6" />
+ <path d="M11 6l.463 -.536a5 5 0 0 1 7.071 7.072l-.534 .464" />
+ <path
+ 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" />
+ </svg>PR{{ data_get($preview, 'pull_request_id') }} |
+ {{ getFqdnWithoutPort($domain) }}
+ </a>
+ @endforeach
+ @endif
+ @endforeach
+ @endforeach
+ @else
+ @foreach (data_get($application, 'previews') as $preview)
+ @if (data_get($preview, 'fqdn'))
+ <a class="dropdown-item" target="_blank"
+ href="{{ getFqdnWithoutPort(data_get($preview, 'fqdn')) }}">
+ <svg xmlns="http://www.w3.org/2000/svg" class="w-6 h-6" viewBox="0 0 24 24"
+ stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round"
+ stroke-linejoin="round">
+ <path stroke="none" d="M0 0h24v24H0z" fill="none" />
+ <path d="M9 15l6 -6" />
+ <path d="M11 6l.463 -.536a5 5 0 0 1 7.071 7.072l-.534 .464" />
+ <path
+ 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" />
+ </svg>
+ PR{{ data_get($preview, 'pull_request_id') }} |
+ {{ data_get($preview, 'fqdn') }}
+ </a>
+ @endif
+ @endforeach
+ @endif
@endif
@if (data_get($application, 'ports_mappings_array'))
@foreach ($application->ports_mappings_array as $port)
diff --git a/resources/views/livewire/project/application/previews-compose.blade.php b/resources/views/livewire/project/application/previews-compose.blade.php
new file mode 100644
index 0000000000..4e50ad18d9
--- /dev/null
+++ b/resources/views/livewire/project/application/previews-compose.blade.php
@@ -0,0 +1,7 @@
+<form wire:submit="save" class="flex items-end gap-2">
+ <x-forms.input helper="One domain per preview." label="Domains for {{ str($serviceName)->headline() }}"
+ id="service.domain"></x-forms.input>
+ <x-forms.button type="submit">Save</x-forms.button>
+ <x-forms.button wire:click="generate">Generate
+ Domain</x-forms.button>
+</form>
diff --git a/resources/views/livewire/project/application/previews.blade.php b/resources/views/livewire/project/application/previews.blade.php
index f069157a3e..e98e0fca28 100644
--- a/resources/views/livewire/project/application/previews.blade.php
+++ b/resources/views/livewire/project/application/previews.blade.php
@@ -42,11 +42,16 @@
<td class="flex flex-col gap-1 md:flex-row">
<x-forms.button
wire:click="add('{{ data_get($pull_request, 'number') }}', '{{ data_get($pull_request, 'html_url') }}')">
- Add
+ Configure
</x-forms.button>
<x-forms.button
wire:click="deploy('{{ data_get($pull_request, 'number') }}', '{{ data_get($pull_request, 'html_url') }}')">
- Deploy
+ <svg xmlns="http://www.w3.org/2000/svg" class="w-5 h-5 dark:text-warning"
+ viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"
+ fill="none" stroke-linecap="round" stroke-linejoin="round">
+ <path stroke="none" d="M0 0h24v24H0z" fill="none" />
+ <path d="M7 4v16l13 -8z" />
+ </svg>Deploy
</x-forms.button>
</td>
</tr>
@@ -58,7 +63,7 @@
</div>
</div>
@if ($application->previews->count() > 0)
- <div class="pb-4">Previews</div>
+ <h3 class="py-4">Deployed Previews</h3>
<div class="flex flex-wrap w-full gap-4">
@foreach (data_get($application, 'previews') as $previewName => $preview)
<div class="flex flex-col w-full p-4 border dark:border-coolgray-200">
@@ -81,21 +86,25 @@
<x-external-link />
</a>
</div>
- <form wire:submit="save_preview('{{ $preview->id }}')" class="flex items-end gap-2 pt-4">
- <x-forms.input label="Domain" helper="One domain per preview."
- id="application.previews.{{ $previewName }}.fqdn"></x-forms.input>
- <x-forms.button type="submit">Save</x-forms.button>
- <x-forms.button wire:click="generate_preview('{{ $preview->id }}')">Generate
- Domain</x-forms.button>
- </form>
+
+ @if ($application->build_pack === 'dockercompose')
+ <div class="flex flex-col gap-4 pt-4">
+ @foreach (collect(json_decode($preview->docker_compose_domains)) as $serviceName => $service)
+ <livewire:project.application.previews-compose wire:key="{{ $preview->id }}"
+ :service="$service" :serviceName="$serviceName" :preview="$preview" />
+ @endforeach
+ </div>
+ @else
+ <form wire:submit="save_preview('{{ $preview->id }}')" class="flex items-end gap-2 pt-4">
+ <x-forms.input label="Domain" helper="One domain per preview."
+ id="application.previews.{{ $previewName }}.fqdn"></x-forms.input>
+ <x-forms.button type="submit">Save</x-forms.button>
+ <x-forms.button wire:click="generate_preview('{{ $preview->id }}')">Generate
+ Domain</x-forms.button>
+ </form>
+ @endif
<div class="flex items-center gap-2 pt-6">
- <x-forms.button wire:click="deploy({{ data_get($preview, 'pull_request_id') }})">
- @if (data_get($preview, 'status') === 'exited')
- Deploy
- @else
- Redeploy
- @endif
- </x-forms.button>
+
@if (count($parameters) > 0)
<a
href="{{ route('project.application.deployment.index', [...$parameters, 'pull_request_id' => data_get($preview, 'pull_request_id')]) }}">
@@ -111,6 +120,27 @@
</a>
@endif
<div class="flex-1"></div>
+ <x-forms.button wire:click="deploy({{ data_get($preview, 'pull_request_id') }})">
+ @if (data_get($preview, 'status') === 'exited')
+ <svg xmlns="http://www.w3.org/2000/svg" class="w-5 h-5 dark:text-warning"
+ viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" fill="none"
+ stroke-linecap="round" stroke-linejoin="round">
+ <path stroke="none" d="M0 0h24v24H0z" fill="none" />
+ <path d="M7 4v16l13 -8z" />
+ </svg>
+ Deploy
+ @else
+ <svg xmlns="http://www.w3.org/2000/svg" class="w-5 h-5 dark:text-orange-400"
+ viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none"
+ stroke-linecap="round" stroke-linejoin="round">
+ <path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
+ <path
+ d="M10.09 4.01l.496 -.495a2 2 0 0 1 2.828 0l7.071 7.07a2 2 0 0 1 0 2.83l-7.07 7.07a2 2 0 0 1 -2.83 0l-7.07 -7.07a2 2 0 0 1 0 -2.83l3.535 -3.535h-3.988">
+ </path>
+ <path d="M7.05 11.038v-3.988"></path>
+ </svg> Redeploy
+ @endif
+ </x-forms.button>
@if (data_get($preview, 'status') !== 'exited')
<x-modal-confirmation isErrorButton
action="stop({{ data_get($preview, 'pull_request_id') }})">