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
feat: add readonly labels
Andras Bacsaic0e88df3e802
diff --git a/app/Http/Controllers/Api/ApplicationsController.php b/app/Http/Controllers/Api/ApplicationsController.phpindex d8175ffe90..bb8c440500 100644--- a/app/Http/Controllers/Api/ApplicationsController.php+++ b/app/Http/Controllers/Api/ApplicationsController.php@@ -732,8 +732,10 @@ class ApplicationsController extends Controller$application->environment_id = $environment->id;$application->save();$application->refresh();- $application->custom_labels = str(implode('|coolify|', generateLabelsApplication($application)))->replace('|coolify|', "\n");- $application->save();+ if (! $application->settings->is_container_label_readonly_enabled) {+ $application->custom_labels = str(implode('|coolify|', generateLabelsApplication($application)))->replace('|coolify|', "\n");+ $application->save();+ }$application->isConfigurationChanged(true);if ($instantDeploy) {@@ -826,8 +828,10 @@ class ApplicationsController extends Controller$application->source_id = $githubApp->id;$application->save();$application->refresh();- $application->custom_labels = str(implode('|coolify|', generateLabelsApplication($application)))->replace('|coolify|', "\n");- $application->save();+ if (! $application->settings->is_container_label_readonly_enabled) {+ $application->custom_labels = str(implode('|coolify|', generateLabelsApplication($application)))->replace('|coolify|', "\n");+ $application->save();+ }$application->isConfigurationChanged(true);if ($instantDeploy) {@@ -916,8 +920,10 @@ class ApplicationsController extends Controller$application->environment_id = $environment->id;$application->save();$application->refresh();- $application->custom_labels = str(implode('|coolify|', generateLabelsApplication($application)))->replace('|coolify|', "\n");- $application->save();+ if (! $application->settings->is_container_label_readonly_enabled) {+ $application->custom_labels = str(implode('|coolify|', generateLabelsApplication($application)))->replace('|coolify|', "\n");+ $application->save();+ }$application->isConfigurationChanged(true);if ($instantDeploy) {@@ -996,8 +1002,10 @@ class ApplicationsController extends Controller$application->git_branch = 'main';$application->save();$application->refresh();- $application->custom_labels = str(implode('|coolify|', generateLabelsApplication($application)))->replace('|coolify|', "\n");- $application->save();+ if (! $application->settings->is_container_label_readonly_enabled) {+ $application->custom_labels = str(implode('|coolify|', generateLabelsApplication($application)))->replace('|coolify|', "\n");+ $application->save();+ }$application->isConfigurationChanged(true);if ($instantDeploy) {@@ -1052,8 +1060,10 @@ class ApplicationsController extends Controller$application->git_branch = 'main';$application->save();$application->refresh();- $application->custom_labels = str(implode('|coolify|', generateLabelsApplication($application)))->replace('|coolify|', "\n");- $application->save();+ if (! $application->settings->is_container_label_readonly_enabled) {+ $application->custom_labels = str(implode('|coolify|', generateLabelsApplication($application)))->replace('|coolify|', "\n");+ $application->save();+ }$application->isConfigurationChanged(true);if ($instantDeploy) {@@ -1494,8 +1504,10 @@ class ApplicationsController extends Controller$fqdn = str($fqdn)->replaceEnd(',', '')->trim();$fqdn = str($fqdn)->replaceStart(',', '')->trim();$application->fqdn = $fqdn;- $customLabels = str(implode('|coolify|', generateLabelsApplication($application)))->replace('|coolify|', "\n");- $application->custom_labels = base64_encode($customLabels);+ if (! $application->settings->is_container_label_readonly_enabled) {+ $customLabels = str(implode('|coolify|', generateLabelsApplication($application)))->replace('|coolify|', "\n");+ $application->custom_labels = base64_encode($customLabels);+ }$request->offsetUnset('domains');}diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.phpindex ac48945f5f..ba9eb005e4 100644--- a/app/Jobs/ApplicationDeploymentJob.php+++ b/app/Jobs/ApplicationDeploymentJob.php@@ -1523,7 +1523,9 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue$this->application->custom_labels = base64_encode($labels->implode("\n"));$this->application->save();} else {- $labels = collect(generateLabelsApplication($this->application, $this->preview));+ if (! $this->application->settings->is_container_label_readonly_enabled) {+ $labels = collect(generateLabelsApplication($this->application, $this->preview));+ }}if ($this->pull_request_id !== 0) {$labels = collect(generateLabelsApplication($this->application, $this->preview));diff --git a/app/Livewire/Project/Application/General.php b/app/Livewire/Project/Application/General.phpindex 91828d42c7..ac603f331c 100644--- a/app/Livewire/Project/Application/General.php+++ b/app/Livewire/Project/Application/General.php@@ -84,6 +84,7 @@ class General extends Component'application.settings.is_static' => 'boolean|required','application.settings.is_build_server_enabled' => 'boolean|required','application.settings.is_container_label_escape_enabled' => 'boolean|required',+ 'application.settings.is_container_label_readonly_enabled' => 'boolean|required','application.watch_paths' => 'nullable','application.redirect' => 'string|required',];@@ -119,6 +120,7 @@ class General extends Component'application.settings.is_static' => 'Is static','application.settings.is_build_server_enabled' => 'Is build server enabled','application.settings.is_container_label_escape_enabled' => 'Is container label escape enabled',+ 'application.settings.is_container_label_readonly_enabled' => 'Is container label readonly','application.watch_paths' => 'Watch paths','application.redirect' => 'Redirect',];@@ -143,7 +145,7 @@ class General extends Component$this->ports_exposes = $this->application->ports_exposes;$this->is_container_label_escape_enabled = $this->application->settings->is_container_label_escape_enabled;$this->customLabels = $this->application->parseContainerLabels();- if (! $this->customLabels && $this->application->destination->server->proxyType() !== 'NONE') {+ if (! $this->customLabels && $this->application->destination->server->proxyType() !== 'NONE' && ! $this->application->settings->is_container_label_readonly_enabled) {$this->customLabels = str(implode('|coolify|', generateLabelsApplication($this->application)))->replace('|coolify|', "\n");$this->application->custom_labels = base64_encode($this->customLabels);$this->application->save();@@ -290,6 +292,9 @@ class General extends Componentpublic function resetDefaultLabels(){+ if ($this->application->settings->is_container_label_readonly_enabled) {+ return;+ }$this->customLabels = str(implode('|coolify|', generateLabelsApplication($this->application)))->replace('|coolify|', "\n");$this->ports_exposes = $this->application->ports_exposes;$this->is_container_label_escape_enabled = $this->application->settings->is_container_label_escape_enabled;@@ -350,7 +355,7 @@ class General extends Component$this->checkFqdns();$this->application->save();- if (! $this->customLabels && $this->application->destination->server->proxyType() !== 'NONE') {+ if (! $this->customLabels && $this->application->destination->server->proxyType() !== 'NONE' && ! $this->application->settings->is_container_label_readonly_enabled) {$this->customLabels = str(implode('|coolify|', generateLabelsApplication($this->application)))->replace('|coolify|', "\n");$this->application->custom_labels = base64_encode($this->customLabels);$this->application->save();diff --git a/app/Models/Service.php b/app/Models/Service.phpindex 2fc0778e6f..8336b90c83 100644--- a/app/Models/Service.php+++ b/app/Models/Service.php@@ -24,6 +24,7 @@ use Symfony\Component\Yaml\Yaml;'destination_id' => ['type' => 'integer', 'description' => 'The unique identifier of the destination where the service is running.'],'connect_to_docker_network' => ['type' => 'boolean', 'description' => 'The flag to connect the service to the predefined Docker network.'],'is_container_label_escape_enabled' => ['type' => 'boolean', 'description' => 'The flag to enable the container label escape.'],+ 'is_container_label_readonly_enabled' => ['type' => 'boolean', 'description' => 'The flag to enable the container label readonly.'],'config_hash' => ['type' => 'string', 'description' => 'The hash of the service configuration.'],'service_type' => ['type' => 'string', 'description' => 'The type of the service.'],'created_at' => ['type' => 'string', 'description' => 'The date and time when the service was created.'],diff --git a/database/migrations/2024_07_17_123828_add_is_container_labels_readonly.php b/database/migrations/2024_07_17_123828_add_is_container_labels_readonly.phpnew file mode 100644index 0000000000..eb36946a48--- /dev/null+++ b/database/migrations/2024_07_17_123828_add_is_container_labels_readonly.php@@ -0,0 +1,28 @@+<?php++use Illuminate\Database\Migrations\Migration;+use Illuminate\Database\Schema\Blueprint;+use Illuminate\Support\Facades\Schema;++return new class extends Migration+{+ /**+ * Run the migrations.+ */+ public function up(): void+ {+ Schema::table('application_settings', function (Blueprint $table) {+ $table->boolean('is_container_label_readonly_enabled')->default(false);+ });+ }++ /**+ * Reverse the migrations.+ */+ public function down(): void+ {+ Schema::table('application_settings', function (Blueprint $table) {+ $table->dropColumn('is_container_label_readonly_enabled');+ });+ }+};diff --git a/resources/views/livewire/project/application/general.blade.php b/resources/views/livewire/project/application/general.blade.phpindex 42742a863f..86c23a1d51 100644--- a/resources/views/livewire/project/application/general.blade.php+++ b/resources/views/livewire/project/application/general.blade.php@@ -239,6 +239,9 @@<x-forms.checkbox label="Escape special characters in labels?"helper="By default, $ (and other chars) is escaped. So if you write $ in the labels, it will be saved as $$.<br><br>If you want to use env variables inside the labels, turn this off."id="application.settings.is_container_label_escape_enabled" instantSave></x-forms.checkbox>+ <x-forms.checkbox label="Readonly Labels"+ helper="If you know what are you doing, you can enable this to edit the labels directly. Coolify won't update labels automatically. <br><br>Be careful, it could break the proxy configuration after you restart the container."+ id="application.settings.is_container_label_readonly_enabled" instantSave></x-forms.checkbox></div>@endif@@ -264,10 +267,13 @@<x-forms.textarea label="Container Labels" rows="15" id="customLabels"monacoEditorLanguage="ini" useMonacoEditor></x-forms.textarea>- <div class="w-72">+ <div class="w-96"><x-forms.checkbox label="Escape special characters in labels?"helper="By default, $ (and other chars) is escaped. So if you write $ in the labels, it will be saved as $$.<br><br>If you want to use env variables inside the labels, turn this off."id="application.settings.is_container_label_escape_enabled" instantSave></x-forms.checkbox>+ <x-forms.checkbox label="Readonly Labels"+ helper="If you know what are you doing, you can enable this to edit the labels directly. Coolify won't update labels automatically. <br><br>Be careful, it could break the proxy configuration after you restart the container."+ id="application.settings.is_container_label_readonly_enabled" instantSave></x-forms.checkbox></div><x-modal-confirmation buttonFullWidth action="resetDefaultLabels"buttonTitle="Reset to Coolify Generated Labels">diff --git a/resources/views/livewire/project/service/edit-compose.blade.php b/resources/views/livewire/project/service/edit-compose.blade.phpindex 2632fc0eab..3b1e1a3bc6 100644--- a/resources/views/livewire/project/service/edit-compose.blade.php+++ b/resources/views/livewire/project/service/edit-compose.blade.php@@ -3,11 +3,7 @@preventname collision. <br>To see the actual volume names, check the Deployable Compose file, or go to Storagemenu.</div>- <div class="pb-2 w-72">- <x-forms.checkbox label="Escape special characters in labels?"- helper="By default, $ (and other chars) is escaped. So if you write $ in the labels, it will be saved as $$.<br><br>If you want to use env variables inside the labels, turn this off."- id="service.is_container_label_escape_enabled" instantSave></x-forms.checkbox>- </div>+<div x-cloak x-show="raw" class="font-mono"><x-forms.textarea allowTab useMonacoEditor monacoEditorLanguage="yaml" rows="20"id="service.docker_compose_raw">@@ -17,6 +13,11 @@<x-forms.textarea rows="20" readonly id="service.docker_compose"></x-forms.textarea></div>+ <div class="pt-2 w-72">+ <x-forms.checkbox label="Escape special characters in labels?"+ helper="By default, $ (and other chars) is escaped. So if you write $ in the labels, it will be saved as $$.<br><br>If you want to use env variables inside the labels, turn this off."+ id="service.is_container_label_escape_enabled" instantSave></x-forms.checkbox>+ </div><div class="flex justify-end w-full gap-2 pt-4"><div class="flex items-end gap-2"><div x-cloak x-show="raw">