mirror of
https://github.com/ershisan99/coolify.git
synced 2025-12-17 20:49:32 +00:00
fix: new service template layout
This commit is contained in:
@@ -67,7 +67,7 @@ class ProjectController extends Controller
|
||||
}
|
||||
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),
|
||||
|
||||
@@ -6,9 +6,9 @@ use App\Models\Server;
|
||||
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 @@ class Select extends Component
|
||||
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);
|
||||
|
||||
@@ -100,12 +100,13 @@ class Service extends BaseModel
|
||||
}
|
||||
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 @@ class Service extends BaseModel
|
||||
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;
|
||||
});
|
||||
|
||||
@@ -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 @@ class ServiceApplication extends BaseModel
|
||||
}
|
||||
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()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user