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(services): add CDN and default logo fallbacks

Andras Bacsai7b7d5a0aad5f
diff --git a/app/Livewire/GlobalSearch.php b/app/Livewire/GlobalSearch.php
index bf64ee8e9d..c6ed818e97 100644
--- a/app/Livewire/GlobalSearch.php
+++ b/app/Livewire/GlobalSearch.php
@@ -1507,8 +1507,7 @@ class GlobalSearch extends Component
'type' => 'one-click-service-'.$serviceKey,
'category' => 'Services',
'resourceType' => 'service',
- 'logo' => data_get($service, 'logo'),
- ] + array_filter([
+ ] + service_logo_urls(data_get($service, 'logo')) + array_filter([
'amd_only' => data_get($service, 'amd_only') ? true : null,
'arm_only' => data_get($service, 'arm_only') ? true : null,
]));
diff --git a/app/Livewire/Project/New/Select.php b/app/Livewire/Project/New/Select.php
index 4cffff8001..ba03041e2b 100644
--- a/app/Livewire/Project/New/Select.php
+++ b/app/Livewire/Project/New/Select.php
@@ -111,38 +111,14 @@ class Select extends Component
$templateLastUpdatedMap = $this->serviceTemplateLastUpdatedMap($services);
$services = collect($services)->map(function ($service, $key) use ($templateLastUpdatedMap) {
- $default_logo = 'svgs/default.webp';
- $logo = data_get($service, 'logo');
-
- if (is_string($logo) && str_starts_with($logo, 'svg/')) {
- $normalizedLogo = 'svgs/'.str($logo)->after('svg/');
- if (file_exists(public_path($normalizedLogo))) {
- $logo = $normalizedLogo;
- }
- }
-
- $hasLogo = is_string($logo)
- && basename($logo) !== basename($default_logo)
- && file_exists(public_path($logo));
-
- if (! $hasLogo) {
- $logo = $default_logo;
- }
-
- $local_logo_path = public_path($logo);
$serviceKey = (string) $key;
return [
'id' => $serviceKey,
'name' => str($serviceKey)->headline(),
'docsSlug' => str($serviceKey)->lower()->value(),
- 'has_logo' => $hasLogo,
- 'logo' => asset($logo),
- 'logo_github_url' => file_exists($local_logo_path)
- ? 'https://raw.githubusercontent.com/coollabsio/coolify/refs/heads/main/public/'.$logo
- : asset($default_logo),
'templateLastUpdated' => $templateLastUpdatedMap[$serviceKey] ?? null,
- ] + (array) $service;
+ ] + service_logo_urls(data_get($service, 'logo')) + (array) $service;
})->all();
// Extract unique categories from services
diff --git a/bootstrap/helpers/services.php b/bootstrap/helpers/services.php
index 07fdeb086f..96257a6323 100644
--- a/bootstrap/helpers/services.php
+++ b/bootstrap/helpers/services.php
@@ -1,5 +1,30 @@
<?php
+function service_logo_urls(mixed $logo): array
+{
+ $defaultLogo = 'svgs/default.webp';
+
+ if (! is_string($logo) || $logo === '' || basename($logo) === basename($defaultLogo)) {
+ return [
+ 'logo' => asset($defaultLogo),
+ 'logo_cdn_url' => asset($defaultLogo),
+ 'logo_default_url' => asset($defaultLogo),
+ ];
+ }
+
+ if (str_starts_with($logo, 'svg/')) {
+ $logo = 'svgs/'.str($logo)->after('svg/');
+ }
+
+ $logo = ltrim($logo, '/');
+
+ return [
+ 'logo' => asset($logo),
+ 'logo_cdn_url' => 'https://raw.githubusercontent.com/coollabsio/coolify/refs/heads/main/public/'.$logo,
+ 'logo_default_url' => asset($defaultLogo),
+ ];
+}
+
use App\Models\Application;
use App\Models\Service;
use App\Models\ServiceApplication;
diff --git a/resources/views/livewire/global-search.blade.php b/resources/views/livewire/global-search.blade.php
index 43d6e6b55a..9e714b59f9 100644
--- a/resources/views/livewire/global-search.blade.php
+++ b/resources/views/livewire/global-search.blade.php
@@ -655,7 +655,9 @@
class="search-result-item command-palette-item">
<template x-if="item.logo">
<div class="command-palette-item-icon">
- <img :src="'/' + item.logo" :alt="item.name">
+ <img :src="item.logo.startsWith('http') ? item.logo : '/' + item.logo"
+ :alt="item.name"
+ x-on:error="if (item.logo_cdn_url && !$el.dataset.cdnTried) { $el.dataset.cdnTried = 'true'; $el.src = item.logo_cdn_url; } else if (item.logo_default_url && !$el.dataset.defaultTried) { $el.dataset.defaultTried = 'true'; $el.src = item.logo_default_url; }">
</div>
</template>
<template x-if="!item.logo">
diff --git a/resources/views/livewire/project/new/select.blade.php b/resources/views/livewire/project/new/select.blade.php
index d8e0920ef1..aed3b96978 100644
--- a/resources/views/livewire/project/new/select.blade.php
+++ b/resources/views/livewire/project/new/select.blade.php
@@ -287,15 +287,8 @@
<div class="flex min-w-0 items-start gap-3">
<div
class="flex size-11 shrink-0 items-center justify-center overflow-hidden rounded-xl border border-neutral-200 bg-neutral-50 dark:border-white/[0.08] dark:bg-white/[0.04]">
- <template x-if="service.has_logo">
- <img class="h-full w-full object-contain p-2" :src="service.logo"
- onerror="this.onerror=null; this.src=this.getAttribute('data-fallback');"
- :data-fallback="service.logo_github_url" />
- </template>
- <template x-if="!service.has_logo">
- <x-reicon name="layers"
- class="size-6 text-neutral-400 dark:text-fg-faint" />
- </template>
+ <img class="h-full w-full object-contain p-2" :src="service.logo"
+ x-on:error="if (!$el.dataset.cdnTried) { $el.dataset.cdnTried = 'true'; $el.src = service.logo_cdn_url; } else if (!$el.dataset.defaultTried) { $el.dataset.defaultTried = 'true'; $el.src = service.logo_default_url; }" />
</div>
<div class="min-w-0 flex-1">
<h3 class="truncate text-[13px] font-semibold text-black dark:text-fg"
diff --git a/tests/Feature/ServiceTemplatesLastUpdatedHintTest.php b/tests/Feature/ServiceTemplatesLastUpdatedHintTest.php
index 08ae87821a..affea0c895 100644
--- a/tests/Feature/ServiceTemplatesLastUpdatedHintTest.php
+++ b/tests/Feature/ServiceTemplatesLastUpdatedHintTest.php
@@ -36,11 +36,14 @@ it('returns each service template last updated timestamp from the generated bund
->toBe(CarbonImmutable::parse($templateTimestamp)->timezone(config('app.timezone'))->format('M j, Y H:i'));
});
-it('uses a valid local icon or the default icon for every service', function () {
+it('returns local, CDN, and default logo fallbacks for every service', function () {
$services = (new Select)->loadServices()['services'];
expect($services['opnform']['logo'])->toBe(asset('svgs/opnform.svg'))
- ->and($services['pydio-cells']['logo'])->toBe(asset('svgs/default.webp'));
+ ->and($services['pydio-cells']['logo'])->toBe(asset('svgs/cells.svg'))
+ ->and($services['pydio-cells']['logo_cdn_url'])
+ ->toBe('https://raw.githubusercontent.com/coollabsio/coolify/refs/heads/main/public/svgs/cells.svg')
+ ->and($services['pydio-cells']['logo_default_url'])->toBe(asset('svgs/default.webp'));
});
it('crops wide database wordmarks to their icon artwork', function () {
@@ -127,6 +130,22 @@ it('renders the service templates last updated hint placeholder', function () {
$view->assertSee('@keydown.escape.stop="closeCategoryFilter(true)"', false);
});
+it('renders the local, CDN, and default service logo fallback chain', function () {
+ View::share('errors', new ViewErrorBag);
+
+ $view = $this->view('livewire.project.new.select', [
+ 'current_step' => 'type',
+ 'environments' => collect(),
+ ]);
+
+ $view->assertSee('service.logo_cdn_url', false);
+ $view->assertSee('service.logo_default_url', false);
+
+ expect(file_get_contents(resource_path('views/livewire/global-search.blade.php')))
+ ->toContain('item.logo_cdn_url')
+ ->toContain('item.logo_default_url');
+});
+
it('keeps service template keys for service selection and docs links', function () {
$services = collect((new Select)->loadServices()['services']);
$denoKv = $services->firstWhere('id', 'denoKV');