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.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
refactor(templates): update service template file handling to use dynamic file name from constants
Andras Bacsai39f25573bf4d
diff --git a/app/Console/Commands/Generate/Services.php b/app/Console/Commands/Generate/Services.phpindex 577e94ac8f..3dd30e2b81 100644--- a/app/Console/Commands/Generate/Services.php+++ b/app/Console/Commands/Generate/Services.php@@ -16,7 +16,7 @@ class Services extends Command/*** {@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{@@ -33,7 +33,7 @@ class Services extends Command];})->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;}diff --git a/app/Console/Commands/Init.php b/app/Console/Commands/Init.phpindex 1a7c0911f9..f1cdd29980 100644--- a/app/Console/Commands/Init.php+++ b/app/Console/Commands/Init.php@@ -105,7 +105,7 @@ class Init extends Command$response = Http::retry(3, 1000)->get(config('constants.services.official'));if ($response->successful()) {$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));}}diff --git a/app/Console/Commands/SyncBunny.php b/app/Console/Commands/SyncBunny.phpindex df19038286..6581bb5879 100644--- a/app/Console/Commands/SyncBunny.php+++ b/app/Console/Commands/SyncBunny.php@@ -45,7 +45,7 @@ class SyncBunny extends Command$install_script = 'install.sh';$upgrade_script = 'upgrade.sh';$production_env = '.env.production';- $service_template = 'service-templates.json';+ $service_template = config('constants.services.file_name');$versions = 'versions.json';$compose_file_location = "$parent_dir/$compose_file";@@ -102,7 +102,7 @@ class SyncBunny extends Command}}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?');if (! $confirmed) {return;diff --git a/app/Jobs/PullTemplatesFromCDN.php b/app/Jobs/PullTemplatesFromCDN.phpindex 9a4c991bc6..7e6b2e21a9 100644--- a/app/Jobs/PullTemplatesFromCDN.php+++ b/app/Jobs/PullTemplatesFromCDN.php@@ -31,7 +31,7 @@ class PullTemplatesFromCDN implements ShouldBeEncrypted, ShouldQueue$response = Http::retry(3, 1000)->get(config('constants.services.official'));if ($response->successful()) {$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 {send_internal_notification('PullTemplatesAndVersions failed with: '.$response->status().' '.$response->body());}diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.phpindex 624e0b0d19..964386e4c7 100644--- a/bootstrap/helpers/shared.php+++ b/bootstrap/helpers/shared.php@@ -471,12 +471,12 @@ function get_service_templates(bool $force = false): Collectionreturn collect($services);} 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();}} 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();}diff --git a/config/constants.php b/config/constants.phpindex c7a36d311a..ed0fdf174c 100644--- a/config/constants.php+++ b/config/constants.php@@ -22,7 +22,8 @@ return ['services' => [// Temporary disabled until cache is implemented// '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' => [diff --git a/resources/views/livewire/project/service/stack-form.blade.php b/resources/views/livewire/project/service/stack-form.blade.phpindex 8f86d43401..7583cabaf4 100644--- a/resources/views/livewire/project/service/stack-form.blade.php+++ b/resources/views/livewire/project/service/stack-form.blade.php@@ -2,6 +2,9 @@<div><div class="flex gap-2"><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-modal-input buttonTitle="Edit Compose File" title="Edit Docker Compose" :closeOutside="false"><livewire:project.service.edit-compose serviceId="{{ $service->id }}" />@@ -25,12 +28,12 @@@foreach ($fields as $serviceName => $field)<div class="flex items-center gap-2"><spanclass="font-bold">{{ data_get($field, 'serviceName') }}</span>{{ data_get($field, 'name') }}- @if (data_get($field, 'customHelper'))- <x-helper helper="{{ data_get($field, 'customHelper') }}" />- @else- <x-helper helper="Variable name: {{ $serviceName }}" />- @endif- </div>+ @if (data_get($field, 'customHelper'))+ <x-helper helper="{{ data_get($field, 'customHelper') }}" />+ @else+ <x-helper helper="Variable name: {{ $serviceName }}" />+ @endif+ </div><x-forms.input type="{{ data_get($field, 'isPassword') ? 'password' : 'text' }}"required="{{ str(data_get($field, 'rules'))?->contains('required') }}"id="fields.{{ $serviceName }}.value"></x-forms.input>