diff --git a/app/Http/Controllers/Api/ApplicationsController.php b/app/Http/Controllers/Api/ApplicationsController.php
index d8175ffe9..bb8c44050 100644
--- a/app/Http/Controllers/Api/ApplicationsController.php
+++ b/app/Http/Controllers/Api/ApplicationsController.php
@@ -732,8 +732,10 @@ private function create_application(Request $request, $type)
$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 @@ private function create_application(Request $request, $type)
$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 @@ private function create_application(Request $request, $type)
$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 @@ private function create_application(Request $request, $type)
$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 @@ private function create_application(Request $request, $type)
$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 @@ public function update_by_uuid(Request $request)
$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.php
index ac48945f5..ba9eb005e 100644
--- a/app/Jobs/ApplicationDeploymentJob.php
+++ b/app/Jobs/ApplicationDeploymentJob.php
@@ -1523,7 +1523,9 @@ private function generate_compose_file()
$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.php
index 91828d42c..ac603f331 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 @@ public function mount()
$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 @@ public function getWildcardDomain()
public 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 @@ public function submit($showToaster = true)
$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.php
index 2fc0778e6..8336b90c8 100644
--- a/app/Models/Service.php
+++ b/app/Models/Service.php
@@ -24,6 +24,7 @@
'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.php
new file mode 100644
index 000000000..eb36946a4
--- /dev/null
+++ b/database/migrations/2024_07_17_123828_add_is_container_labels_readonly.php
@@ -0,0 +1,28 @@
+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.php
index 42742a863..86c23a1d5 100644
--- a/resources/views/livewire/project/application/general.blade.php
+++ b/resources/views/livewire/project/application/general.blade.php
@@ -239,6 +239,9 @@ class="underline" href="https://coolify.io/docs/knowledge-base/docker/registry"