fix: services

This commit is contained in:
Andras Bacsai 2023-09-27 21:51:06 +02:00
parent fe8a7fc54f
commit d609fcaee1
5 changed files with 51 additions and 23 deletions

View File

@ -7,6 +7,8 @@
use Illuminate\Http\Client\Pool;
use Illuminate\Support\Facades\Http;
use function Laravel\Prompts\confirm;
class SyncBunny extends Command
{
/**
@ -14,7 +16,7 @@ class SyncBunny extends Command
*
* @var string
*/
protected $signature = 'sync:bunny';
protected $signature = 'sync:bunny {--only-template}';
/**
* The console command description.
@ -28,6 +30,7 @@ class SyncBunny extends Command
*/
public function handle()
{
$only_template = $this->option('only-template');
$bunny_cdn = "https://cdn.coollabs.io";
$bunny_cdn_path = "coolify";
$bunny_cdn_storage_name = "coolcdn";
@ -39,6 +42,7 @@ public function handle()
$install_script = "install.sh";
$upgrade_script = "upgrade.sh";
$production_env = ".env.production";
$service_template = "service-templates.json";
$versions = "versions.json";
@ -64,6 +68,19 @@ public function handle()
]);
});
try {
$confirmed = confirm('Are you sure?');
if (!$confirmed) {
return;
}
if ($only_template) {
Http::pool(fn (Pool $pool) => [
$pool->storage(file: "$parent_dir/templates/$service_template")->put("/$bunny_cdn_storage_name/$bunny_cdn_path/$service_template"),
$pool->purge("$bunny_cdn/$bunny_cdn_path/$service_template"),
]);
$this->info('Service template uploaded & purged...');
return;
}
Http::pool(fn (Pool $pool) => [
$pool->storage(file: "$parent_dir/$compose_file")->put("/$bunny_cdn_storage_name/$bunny_cdn_path/$compose_file"),
$pool->storage(file: "$parent_dir/$compose_file_prod")->put("/$bunny_cdn_storage_name/$bunny_cdn_path/$compose_file_prod"),
@ -72,7 +89,7 @@ public function handle()
$pool->storage(file: "$parent_dir/scripts/$install_script")->put("/$bunny_cdn_storage_name/$bunny_cdn_path/$install_script"),
$pool->storage(file: "$parent_dir/$versions")->put("/$bunny_cdn_storage_name/$bunny_cdn_path/$versions"),
]);
ray("{$bunny_cdn}/{$bunny_cdn_path}");
$this->info("{$bunny_cdn}/{$bunny_cdn_path}");
Http::pool(fn (Pool $pool) => [
$pool->purge("$bunny_cdn/$bunny_cdn_path/$compose_file"),
$pool->purge("$bunny_cdn/$bunny_cdn_path/$compose_file_prod"),
@ -81,9 +98,9 @@ public function handle()
$pool->purge("$bunny_cdn/$bunny_cdn_path/$install_script"),
$pool->purge("$bunny_cdn/$bunny_cdn_path/$versions"),
]);
echo "All files uploaded & purged...\n";
$this->info("All files uploaded & purged...");
} catch (\Throwable $e) {
echo $e->getMessage();
$this->error("Error: " . $e->getMessage());
}
}
}

View File

@ -23,6 +23,7 @@ class Select extends Component
public array $parameters;
public Collection|array $services = [];
public bool $loadingServices = true;
public bool $loading = false;
public ?string $existingPostgresqlUrl = null;
@ -61,19 +62,19 @@ public function loadServices(bool $forceReload = false)
}
if (isDev()) {
$cached = Cache::remember('services', 3600, function () {
$services = File::get(base_path('examples/service-templates.json'));
$services = collect(json_decode($services));
$services = File::get(base_path('templates/service-templates.json'));
$services = collect(json_decode($services))->sortKeys();
$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'));
$services = Http::get(config('constants.services.official'));
if ($services->failed()) {
throw new \Exception($services->body());
}
$services = collect($services->json());
$services = collect($services->json())->sortKeys();
$this->emit('success', 'Successfully reloaded services from the internet.');
return $services;
});
@ -89,6 +90,8 @@ public function loadServices(bool $forceReload = false)
public function setType(string $type)
{
$this->type = $type;
if ($this->loading) return;
$this->loading = true;
if ($type === "existing-postgresql") {
$this->current_step = $type;
return;

View File

@ -15,7 +15,7 @@
],
],
'services' => [
'offical' => 'https://cdn.coollabs.io/coolify/service-templates.json',
'official' => 'https://cdn.coollabs.io/coolify/service-templates.json',
],
'limits' => [
'trial_period'=> 7,

View File

@ -12,7 +12,7 @@
<div class="grid justify-start grid-cols-1 gap-2 text-left xl:grid-cols-3">
<div class="box group" wire:click="setType('public')">
<div class="flex flex-col mx-6">
<div class="group-hover:text-white">
<div class="text-xl font-bold text-white group-hover:text-white">
Public Repository
</div>
<div class="text-xs group-hover:text-white">
@ -22,7 +22,7 @@
</div>
<div class="box group" wire:click="setType('private-gh-app')">
<div class="flex flex-col mx-6">
<div class="group-hover:text-white">
<div class="text-xl font-bold text-white group-hover:text-white">
Private Repository
</div>
<div class="text-xs group-hover:text-white">
@ -32,7 +32,7 @@
</div>
<div class="box group" wire:click="setType('private-deploy-key')">
<div class="flex flex-col mx-6">
<div class="group-hover:text-white">
<div class="text-xl font-bold text-white group-hover:text-white">
Private Repository (with deploy key)
</div>
<div class="text-xs group-hover:text-white">
@ -44,7 +44,7 @@
<div class="grid justify-start grid-cols-1 gap-2 text-left xl:grid-cols-3">
<div class="box group" wire:click="setType('dockerfile')">
<div class="flex flex-col mx-6">
<div class="group-hover:text-white">
<div class="text-xl font-bold text-white group-hover:text-white">
Based on a Dockerfile
</div>
<div class="text-xs group-hover:text-white">
@ -54,7 +54,7 @@
</div>
<div class="box group" wire:click="setType('docker-compose-empty')">
<div class="flex flex-col mx-6">
<div class="group-hover:text-white">
<div class="text-xl font-bold text-white group-hover:text-white">
Based on a Docker Compose
</div>
<div class="text-xs group-hover:text-white">
@ -67,7 +67,7 @@
<div class="grid justify-start grid-cols-1 gap-2 text-left xl:grid-cols-3">
<div class="box group" wire:click="setType('postgresql')">
<div class="flex flex-col mx-6">
<div class="group-hover:text-white">
<div class="text-xl font-bold text-white group-hover:text-white">
New PostgreSQL
</div>
<div class="text-xs group-hover:text-white">
@ -88,26 +88,28 @@
</div>
<div class="flex items-center gap-2">
<h2 class="py-4">Services</h2>
<x-forms.button wire:click='loadServices(true)'>Reload Services from Templates</x-forms.button>
<x-forms.button wire:click='loadServices(true)'>Reload Services List</x-forms.button>
</div>
<div class="grid justify-start grid-cols-1 gap-2 text-left xl:grid-cols-3">
@if ($loadingServices)
<span class="loading loading-xs loading-spinner"></span>
@else
@foreach ($services as $serviceName => $service)
<div class="box group" wire:click="setType('one-click-service-{{ $serviceName }}')">
<button class="text-left box group"
wire:loading.attr="disabled" wire:click="setType('one-click-service-{{ $serviceName }}')">
<div class="flex flex-col mx-6">
<div class="group-hover:text-white">
<div class="text-xl font-bold text-white group-hover:text-white">
{{ Str::headline($serviceName) }}
</div>
<div class="text-xs group-hover:text-white">
</div>
@if (data_get($service, 'slogan'))
<div class="text-xs">
{{ data_get($service, 'slogan') }}
</div>
@endif
</div>
</button>
@endforeach
@endif
</div>
@endif
@if ($current_step === 'servers')

File diff suppressed because one or more lines are too long