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(preview): docker compose preview URLs (#7959)

πŸ”οΈ Peak650186b1abca
diff --git a/app/Jobs/ApplicationPullRequestUpdateJob.php b/app/Jobs/ApplicationPullRequestUpdateJob.php
index 05453b6a3a..025daa12b0 100755
--- a/app/Jobs/ApplicationPullRequestUpdateJob.php
+++ b/app/Jobs/ApplicationPullRequestUpdateJob.php
@@ -47,7 +47,7 @@ class ApplicationPullRequestUpdateJob implements ShouldBeEncrypted, ShouldQueue
match ($this->status) {
ProcessStatus::QUEUED => $this->body = "The preview deployment for **{$serviceName}** is queued. ⏳\n\n",
ProcessStatus::IN_PROGRESS => $this->body = "The preview deployment for **{$serviceName}** is in progress. 🟑\n\n",
- ProcessStatus::FINISHED => $this->body = "The preview deployment for **{$serviceName}** is ready. 🟒\n\n".($this->preview->fqdn ? "[Open Preview]({$this->preview->fqdn}) | " : ''),
+ ProcessStatus::FINISHED => $this->body = "The preview deployment for **{$serviceName}** is ready. 🟒\n\n".$this->getPreviewLinks(),
ProcessStatus::ERROR => $this->body = "The preview deployment for **{$serviceName}** failed. πŸ”΄\n\n",
ProcessStatus::KILLED => $this->body = "The preview deployment for **{$serviceName}** was killed. ⚫\n\n",
ProcessStatus::CANCELLED => $this->body = "The preview deployment for **{$serviceName}** was cancelled. 🚫\n\n",
@@ -91,4 +91,27 @@ class ApplicationPullRequestUpdateJob implements ShouldBeEncrypted, ShouldQueue
{
githubApi(source: $this->application->source, endpoint: "/repos/{$this->application->git_repository}/issues/comments/{$this->preview->pull_request_issue_comment_id}", method: 'delete');
}
+
+ private function getPreviewLinks(): string
+ {
+ if ($this->application->build_pack === 'dockercompose') {
+ $dockerComposeDomains = json_decode($this->preview->docker_compose_domains, true) ?? [];
+ $links = [];
+
+ foreach ($dockerComposeDomains as $serviceName => $config) {
+ $domain = data_get($config, 'domain');
+ if (! empty($domain)) {
+ $firstDomain = str($domain)->explode(',')->first();
+ $firstDomain = trim($firstDomain);
+ if (! empty($firstDomain)) {
+ $links[] = "[Open {$serviceName}]({$firstDomain})";
+ }
+ }
+ }
+
+ return ! empty($links) ? implode(' | ', $links).' | ' : '';
+ }
+
+ return $this->preview->fqdn ? "[Open Preview]({$this->preview->fqdn}) | " : '';
+ }
}