refactor(templates): update service template file handling to use dynamic file name from constants
This commit is contained in:
@@ -16,7 +16,7 @@ class Services extends Command
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
protected $description = 'Generate service-templates.yaml based on /templates/compose directory';
|
protected $description = 'Generates service-templates json file based on /templates/compose directory';
|
||||||
|
|
||||||
public function handle(): int
|
public function handle(): int
|
||||||
{
|
{
|
||||||
@@ -33,7 +33,7 @@ class Services extends Command
|
|||||||
];
|
];
|
||||||
})->toJson(JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
|
})->toJson(JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
|
||||||
|
|
||||||
file_put_contents(base_path('templates/service-templates.json'), $serviceTemplatesJson.PHP_EOL);
|
file_put_contents(base_path('templates/'.config('constants.services.file_name')), $serviceTemplatesJson.PHP_EOL);
|
||||||
|
|
||||||
return self::SUCCESS;
|
return self::SUCCESS;
|
||||||
}
|
}
|
||||||
|
@@ -105,7 +105,7 @@ class Init extends Command
|
|||||||
$response = Http::retry(3, 1000)->get(config('constants.services.official'));
|
$response = Http::retry(3, 1000)->get(config('constants.services.official'));
|
||||||
if ($response->successful()) {
|
if ($response->successful()) {
|
||||||
$services = $response->json();
|
$services = $response->json();
|
||||||
File::put(base_path('templates/service-templates.json'), json_encode($services));
|
File::put(base_path('templates/'.config('constants.services.file_name')), json_encode($services));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -45,7 +45,7 @@ class SyncBunny extends Command
|
|||||||
$install_script = 'install.sh';
|
$install_script = 'install.sh';
|
||||||
$upgrade_script = 'upgrade.sh';
|
$upgrade_script = 'upgrade.sh';
|
||||||
$production_env = '.env.production';
|
$production_env = '.env.production';
|
||||||
$service_template = 'service-templates.json';
|
$service_template = config('constants.services.file_name');
|
||||||
$versions = 'versions.json';
|
$versions = 'versions.json';
|
||||||
|
|
||||||
$compose_file_location = "$parent_dir/$compose_file";
|
$compose_file_location = "$parent_dir/$compose_file";
|
||||||
@@ -102,7 +102,7 @@ class SyncBunny extends Command
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($only_template) {
|
if ($only_template) {
|
||||||
$this->info('About to sync service-templates.json to BunnyCDN.');
|
$this->info('About to sync '.config('constants.services.file_name').' to BunnyCDN.');
|
||||||
$confirmed = confirm('Are you sure you want to sync?');
|
$confirmed = confirm('Are you sure you want to sync?');
|
||||||
if (! $confirmed) {
|
if (! $confirmed) {
|
||||||
return;
|
return;
|
||||||
|
@@ -31,7 +31,7 @@ class PullTemplatesFromCDN implements ShouldBeEncrypted, ShouldQueue
|
|||||||
$response = Http::retry(3, 1000)->get(config('constants.services.official'));
|
$response = Http::retry(3, 1000)->get(config('constants.services.official'));
|
||||||
if ($response->successful()) {
|
if ($response->successful()) {
|
||||||
$services = $response->json();
|
$services = $response->json();
|
||||||
File::put(base_path('templates/service-templates.json'), json_encode($services));
|
File::put(base_path('templates/'.config('constants.services.file_name')), json_encode($services));
|
||||||
} else {
|
} else {
|
||||||
send_internal_notification('PullTemplatesAndVersions failed with: '.$response->status().' '.$response->body());
|
send_internal_notification('PullTemplatesAndVersions failed with: '.$response->status().' '.$response->body());
|
||||||
}
|
}
|
||||||
|
@@ -471,12 +471,12 @@ function get_service_templates(bool $force = false): Collection
|
|||||||
|
|
||||||
return collect($services);
|
return collect($services);
|
||||||
} catch (\Throwable) {
|
} catch (\Throwable) {
|
||||||
$services = File::get(base_path('templates/service-templates.json'));
|
$services = File::get(base_path('templates/'.config('constants.services.file_name')));
|
||||||
|
|
||||||
return collect(json_decode($services))->sortKeys();
|
return collect(json_decode($services))->sortKeys();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$services = File::get(base_path('templates/service-templates.json'));
|
$services = File::get(base_path('templates/'.config('constants.services.file_name')));
|
||||||
|
|
||||||
return collect(json_decode($services))->sortKeys();
|
return collect(json_decode($services))->sortKeys();
|
||||||
}
|
}
|
||||||
|
@@ -22,7 +22,8 @@ return [
|
|||||||
'services' => [
|
'services' => [
|
||||||
// Temporary disabled until cache is implemented
|
// Temporary disabled until cache is implemented
|
||||||
// 'official' => 'https://cdn.coollabs.io/coolify/service-templates.json',
|
// 'official' => 'https://cdn.coollabs.io/coolify/service-templates.json',
|
||||||
'official' => 'https://raw.githubusercontent.com/coollabsio/coolify/main/templates/service-templates.json',
|
'official' => 'https://raw.githubusercontent.com/coollabsio/coolify/main/templates/service-templates-latest.json',
|
||||||
|
'file_name' => 'service-templates-latest.json',
|
||||||
],
|
],
|
||||||
|
|
||||||
'terminal' => [
|
'terminal' => [
|
||||||
|
@@ -2,6 +2,9 @@
|
|||||||
<div>
|
<div>
|
||||||
<div class="flex gap-2">
|
<div class="flex gap-2">
|
||||||
<h2>Service Stack</h2>
|
<h2>Service Stack</h2>
|
||||||
|
@if (isDev())
|
||||||
|
<div>{{ $service->compose_parsing_version }}</div>
|
||||||
|
@endif
|
||||||
<x-forms.button wire:target='submit' type="submit">Save</x-forms.button>
|
<x-forms.button wire:target='submit' type="submit">Save</x-forms.button>
|
||||||
<x-modal-input buttonTitle="Edit Compose File" title="Edit Docker Compose" :closeOutside="false">
|
<x-modal-input buttonTitle="Edit Compose File" title="Edit Docker Compose" :closeOutside="false">
|
||||||
<livewire:project.service.edit-compose serviceId="{{ $service->id }}" />
|
<livewire:project.service.edit-compose serviceId="{{ $service->id }}" />
|
||||||
@@ -25,12 +28,12 @@
|
|||||||
@foreach ($fields as $serviceName => $field)
|
@foreach ($fields as $serviceName => $field)
|
||||||
<div class="flex items-center gap-2"><span
|
<div class="flex items-center gap-2"><span
|
||||||
class="font-bold">{{ data_get($field, 'serviceName') }}</span>{{ data_get($field, 'name') }}
|
class="font-bold">{{ data_get($field, 'serviceName') }}</span>{{ data_get($field, 'name') }}
|
||||||
@if (data_get($field, 'customHelper'))
|
@if (data_get($field, 'customHelper'))
|
||||||
<x-helper helper="{{ data_get($field, 'customHelper') }}" />
|
<x-helper helper="{{ data_get($field, 'customHelper') }}" />
|
||||||
@else
|
@else
|
||||||
<x-helper helper="Variable name: {{ $serviceName }}" />
|
<x-helper helper="Variable name: {{ $serviceName }}" />
|
||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
<x-forms.input type="{{ data_get($field, 'isPassword') ? 'password' : 'text' }}"
|
<x-forms.input type="{{ data_get($field, 'isPassword') ? 'password' : 'text' }}"
|
||||||
required="{{ str(data_get($field, 'rules'))?->contains('required') }}"
|
required="{{ str(data_get($field, 'rules'))?->contains('required') }}"
|
||||||
id="fields.{{ $serviceName }}.value"></x-forms.input>
|
id="fields.{{ $serviceName }}.value"></x-forms.input>
|
||||||
|
Reference in New Issue
Block a user