fix: new service template layout

This commit is contained in:
Andras Bacsai 2023-09-25 17:41:35 +02:00
parent ee20c3339e
commit 0f8ccac775
6 changed files with 46 additions and 17 deletions

View File

@ -67,7 +67,7 @@ public function new()
}
if ($type->startsWith('one-click-service-')) {
$oneClickServiceName = $type->after('one-click-service-')->value();
$oneClickService = data_get($services, $oneClickServiceName);
$oneClickService = data_get($services, "$oneClickServiceName.compose");
if ($oneClickService) {
$service = Service::create([
'name' => "$oneClickServiceName-" . Str::random(10),

View File

@ -6,9 +6,9 @@
use Countable;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Http;
use Livewire\Component;
use Illuminate\Support\Str;
class Select extends Component
{
@ -57,17 +57,27 @@ public function loadServices(bool $forceReload = false)
if ($forceReload) {
Cache::forget('services');
}
$cached = Cache::remember('services', 3600, function () {
$services = Http::get(config('constants.services.offical'));
if ($services->failed()) {
throw new \Exception($services->body());
}
if (isDev()) {
$cached = Cache::remember('services', 3600, function () {
$services = File::get(base_path('examples/service-templates.json'));
$services = collect(json_decode($services));
$this->emit('success', 'Successfully reloaded services from filesystem (development mode).');
return $services;
});
} else {
$cached = Cache::remember('services', 3600, function () {
$services = Http::get(config('constants.services.offical'));
if ($services->failed()) {
throw new \Exception($services->body());
}
$services = collect($services->json());
$this->emit('success', 'Successfully reloaded services from the internet.');
return $services;
});
$services = collect($services->json());
$this->emit('success', 'Successfully reloaded services from the internet.');
return $services;
});
}
$this->services = $cached;
} catch (\Throwable $e) {
ray($e);
return handleError($e, $this);

View File

@ -100,12 +100,13 @@ public function saveComposeConfigs()
}
private function generateFqdn($serviceVariables, $serviceName)
{
if (Str::of($serviceVariables)->contains('SERVICE_FQDN') || Str::of($serviceVariables)->contains('SERVICE_URL')) {
// Add sslip.io to the service
// if (Str::of($serviceVariables)->contains('SERVICE_FQDN') || Str::of($serviceVariables)->contains('SERVICE_URL')) {
$defaultUsableFqdn = "http://$serviceName-{$this->uuid}.{$this->server->ip}.sslip.io";
if (isDev()) {
$defaultUsableFqdn = "http://$serviceName-{$this->uuid}.127.0.0.1.sslip.io";
}
}
// }
return $defaultUsableFqdn ?? null;
}
public function parse(bool $isNew = false): Collection
@ -498,7 +499,6 @@ public function parse(bool $isNew = false): Collection
data_forget($service, 'is_database');
data_set($service, 'restart', RESTART_MODE);
data_set($service, 'container_name', $container_name);
data_forget($service, 'documentation');
data_forget($service, 'volumes.*.content');
return $service;
});

View File

@ -3,7 +3,7 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Symfony\Component\Yaml\Yaml;
use Illuminate\Support\Facades\Cache;
class ServiceApplication extends BaseModel
{
@ -16,7 +16,10 @@ public function type()
}
public function documentation()
{
return data_get(Yaml::parse($this->service->docker_compose_raw), "services.{$this->name}.documentation", 'https://coolify.io/docs');
$services = Cache::get('services', []);
$service = data_get($services, $this->name, []);
ray($this->name);
return data_get($service, 'documentation', 'https://coolify.io/docs');
}
public function service()
{

View File

@ -0,0 +1,5 @@
services:
uptime-kuma:
image: louislam/uptime-kuma:1
volumes:
- uptime-kuma:/app/data

View File

@ -1,3 +1,14 @@
{
"plausible-analytics": "dmVyc2lvbjogIjMuMyIKc2VydmljZXM6CiAgcGxhdXNpYmxlOgogICAgaW1hZ2U6IHBsYXVzaWJsZS9hbmFseXRpY3M6djIuMAogICAgY29tbWFuZDogc2ggLWMgInNsZWVwIDEwICYmIC9lbnRyeXBvaW50LnNoIGRiIGNyZWF0ZWRiICYmIC9lbnRyeXBvaW50LnNoIGRiIG1pZ3JhdGUgJiYgL2VudHJ5cG9pbnQuc2ggcnVuIgogICAgZW52aXJvbm1lbnQ6CiAgICAgIC0gREFUQUJBU0VfVVJMPXBvc3RncmVzOi8vcG9zdGdyZXM6JFNFUlZJQ0VfUEFTU1dPUkRfUE9TVEdSRVNAcGxhdXNpYmxlX2RiL3BsYXVzaWJsZQogICAgICAtIEJBU0VfVVJMPSRTRVJWSUNFX0ZRRE5fUEx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fdGhyZWFkcz48L2RlZmF1bHQ+PC9wcm9maWxlcz48L2NsaWNraG91c2U+CiAgICAgIC0gdHlwZTogYmluZAogICAgICAgIHNvdXJjZTogLi9jbGlja2hvdXNlL2NsaWNraG91c2UtdXNlci1jb25maWcueG1sCiAgICAgICAgdGFyZ2V0OiAvZXRjL2NsaWNraG91c2Utc2VydmVyL3VzZXJzLmQvbG9nZ2luZy54bWwKICAgICAgICByZWFkX29ubHk6IHRydWUKICAgICAgICBjb250ZW50OiA+LQogICAgICAgICAgPGNsaWNraG91c2U+PGxvZ2dlcj48bGV2ZWw+d2FybmluZzwvbGV2ZWw+PGNvbnNvbGU+dHJ1ZTwvY29uc29sZT48L2xvZ2dlcj48cXVlcnlfdGhyZWFkX2xvZwogICAgICAgICAgcmVtb3ZlPSJyZW1vdmUiLz48cXVlcnlfbG9nIHJlbW92ZT0icmVtb3ZlIi8+PHRleHRfbG9nCiAgICAgICAgICByZW1vdmU9InJlbW92ZSIvPjx0cmFjZV9sb2cgcmVtb3ZlPSJyZW1vdmUiLz48bWV0cmljX2xvZwogICAgICAgICAgcmVtb3ZlPSJyZW1vdmUiLz48YXN5bmNocm9ub3VzX21ldHJpY19sb2cKICAgICAgICAgIHJlbW92ZT0icmVtb3ZlIi8+PHNlc3Npb25fbG9nIHJlbW92ZT0icmVtb3ZlIi8+PHBhcnRfbG9nCiAgICAgICAgICByZW1vdmU9InJlbW92ZSIvPjwvY2xpY2tob3VzZT4KICAgIHVsaW1pdHM6CiAgICAgIG5vZmlsZToKICAgICAgICBzb2Z0OiAyNjIxNDQKICAgICAgICBoYXJkOiAyNjIxNDQK"
"plausible-analytics": {
"documentation": "https://plausible.io/docs",
"compose": "dmVyc2lvbjogIjMuMyIKc2VydmljZXM6CiAgcGxhdXNpYmxlLWFuYWx5dGljczoKICAgIGltYWdlOiBwbGF1c2libGUvYW5hbHl0aWNzOnYyLjAKICAgIGNvbW1hbmQ6IHNoIC1jICJzbGVlcCAxMCAmJiAvZW50cnl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OgogICAgICBub2ZpbGU6CiAgICAgICAgc29mdDogMjYyMTQ0CiAgICAgICAgaGFyZDogMjYyMTQ0Cg=="
},
"uptime-kuma": {
"documentation": "https://github.com/louislam/uptime-kuma",
"compose": "c2VydmljZXM6CiAgdXB0aW1lLWt1bWE6CiAgICBpbWFnZTogbG91aXNsYW0vdXB0aW1lLWt1bWE6MQogICAgdm9sdW1lczoKICAgICAgLSB1cHRpbWUta3VtYTovYXBwL2RhdGEK"
},
"uptime-kuma-with-database": {
"documentation": "https://github.com/louislam/uptime-kuma",
"compose": "c2VydmljZXM6CiAgdXB0aW1lLWt1bWE6CiAgICBpbWFnZTogbG91aXNsYW0vdXB0aW1lLWt1bWE6MQogICAgdm9sdW1lczoKICAgICAgLSB1cHRpbWUta3VtYTovYXBwL2RhdGEK"
}
}