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: able to delete configuration from server
Andras Bacsai9032879e2027
diff --git a/app/Jobs/DeleteResourceJob.php b/app/Jobs/DeleteResourceJob.phpindex 22d5718ab6..f2a611863d 100644--- a/app/Jobs/DeleteResourceJob.php+++ b/app/Jobs/DeleteResourceJob.php@@ -28,7 +28,7 @@ class DeleteResourceJob implements ShouldQueue, ShouldBeEncrypted{use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;- public function __construct(public Application|Service|StandalonePostgresql|StandaloneRedis|StandaloneMongodb|StandaloneMysql|StandaloneMariadb|StandaloneKeydb|StandaloneDragonfly|StandaloneClickhouse $resource)+ public function __construct(public Application|Service|StandalonePostgresql|StandaloneRedis|StandaloneMongodb|StandaloneMysql|StandaloneMariadb|StandaloneKeydb|StandaloneDragonfly|StandaloneClickhouse $resource, public bool $deleteConfigurations = false){}@@ -55,6 +55,9 @@ class DeleteResourceJob implements ShouldQueue, ShouldBeEncryptedDeleteService::run($this->resource);break;}+ if ($this->deleteConfigurations) {+ $this->resource?->delete_configurations();+ }} catch (\Throwable $e) {ray($e->getMessage());send_internal_notification('ContainerStoppingJob failed with: ' . $e->getMessage());diff --git a/app/Livewire/Project/Shared/Danger.php b/app/Livewire/Project/Shared/Danger.phpindex f19cf8d539..ed6695b63f 100644--- a/app/Livewire/Project/Shared/Danger.php+++ b/app/Livewire/Project/Shared/Danger.php@@ -11,6 +11,7 @@ class Danger extends Componentpublic $resource;public $projectUuid;public $environmentName;+ public bool $delete_configurations = false;public ?string $modalId = null;public function mount()@@ -25,7 +26,7 @@ class Danger extends Component{try {$this->resource->delete();- DeleteResourceJob::dispatch($this->resource);+ DeleteResourceJob::dispatch($this->resource, $this->delete_configurations);return redirect()->route('project.resource.index', ['project_uuid' => $this->projectUuid,'environment_name' => $this->environmentNamediff --git a/app/Models/Application.php b/app/Models/Application.phpindex 1b60914a79..adb26bb212 100644--- a/app/Models/Application.php+++ b/app/Models/Application.php@@ -57,6 +57,15 @@ class Application extends BaseModel});}+ public function delete_configurations()+ {+ $server = data_get($this, 'destination.server');+ $workdir = $this->workdir();+ if (str($workdir)->endsWith($this->uuid)) {+ ray('Deleting workdir');+ instant_remote_process(["rm -rf " . $this->workdir()], $server, false);+ }+ }public function additional_servers(){return $this->belongsToMany(Server::class, 'additional_destinations')diff --git a/app/Models/Service.php b/app/Models/Service.phpindex b3430ac0a6..cb9d76831f 100644--- a/app/Models/Service.php+++ b/app/Models/Service.php@@ -27,6 +27,14 @@ class Service extends BaseModel{return $this->morphToMany(Tag::class, 'taggable');}+ public function delete_configurations()+ {+ $server = data_get($this, 'server');+ $workdir = $this->workdir();+ if (str($workdir)->endsWith($this->uuid)) {+ instant_remote_process(["rm -rf " . $this->workdir()], $server, false);+ }+ }public function status(){$applications = $this->applications;diff --git a/app/Models/StandaloneClickhouse.php b/app/Models/StandaloneClickhouse.phpindex 486372df1e..6016f5ca92 100644--- a/app/Models/StandaloneClickhouse.php+++ b/app/Models/StandaloneClickhouse.php@@ -44,7 +44,15 @@ class StandaloneClickhouse extends BaseModel}public function workdir(){- return database_configuration_dir() . '/' . $this->uuid;+ return database_configuration_dir() . "/{$this->uuid}";+ }+ public function delete_configurations()+ {+ $server = data_get($this, 'destination.server');+ $workdir = $this->workdir();+ if (str($workdir)->endsWith($this->uuid)) {+ instant_remote_process(["rm -rf " . $this->workdir()], $server, false);+ }}public function realStatus(){diff --git a/app/Models/StandaloneDragonfly.php b/app/Models/StandaloneDragonfly.phpindex 7709f1f07b..d83b604f25 100644--- a/app/Models/StandaloneDragonfly.php+++ b/app/Models/StandaloneDragonfly.php@@ -42,6 +42,18 @@ class StandaloneDragonfly extends BaseModel});}+ public function workdir()+ {+ return database_configuration_dir() . "/{$this->uuid}";+ }+ public function delete_configurations()+ {+ $server = data_get($this, 'destination.server');+ $workdir = $this->workdir();+ if (str($workdir)->endsWith($this->uuid)) {+ instant_remote_process(["rm -rf " . $this->workdir()], $server, false);+ }+ }public function realStatus(){return $this->getRawOriginal('status');diff --git a/app/Models/StandaloneKeydb.php b/app/Models/StandaloneKeydb.phpindex 3194ba7ba4..3bdbcfeff4 100644--- a/app/Models/StandaloneKeydb.php+++ b/app/Models/StandaloneKeydb.php@@ -42,6 +42,19 @@ class StandaloneKeydb extends BaseModel});}+ public function workdir()+ {+ return database_configuration_dir() . "/{$this->uuid}";+ }+ public function delete_configurations()+ {+ $server = data_get($this, 'destination.server');+ $workdir = $this->workdir();+ if (str($workdir)->endsWith($this->uuid)) {+ instant_remote_process(["rm -rf " . $this->workdir()], $server, false);+ }+ }+public function realStatus(){return $this->getRawOriginal('status');diff --git a/app/Models/StandaloneMariadb.php b/app/Models/StandaloneMariadb.phpindex eb465e9891..d5e14b3c50 100644--- a/app/Models/StandaloneMariadb.php+++ b/app/Models/StandaloneMariadb.php@@ -43,6 +43,18 @@ class StandaloneMariadb extends BaseModel$database->tags()->detach();});}+ public function workdir()+ {+ return database_configuration_dir() . "/{$this->uuid}";+ }+ public function delete_configurations()+ {+ $server = data_get($this, 'destination.server');+ $workdir = $this->workdir();+ if (str($workdir)->endsWith($this->uuid)) {+ instant_remote_process(["rm -rf " . $this->workdir()], $server, false);+ }+ }public function realStatus(){return $this->getRawOriginal('status');diff --git a/app/Models/StandaloneMongodb.php b/app/Models/StandaloneMongodb.phpindex a8aab4e422..268af94032 100644--- a/app/Models/StandaloneMongodb.php+++ b/app/Models/StandaloneMongodb.php@@ -46,6 +46,18 @@ class StandaloneMongodb extends BaseModel$database->tags()->detach();});}+ public function workdir()+ {+ return database_configuration_dir() . "/{$this->uuid}";+ }+ public function delete_configurations()+ {+ $server = data_get($this, 'destination.server');+ $workdir = $this->workdir();+ if (str($workdir)->endsWith($this->uuid)) {+ instant_remote_process(["rm -rf " . $this->workdir()], $server, false);+ }+ }public function realStatus(){return $this->getRawOriginal('status');diff --git a/app/Models/StandaloneMysql.php b/app/Models/StandaloneMysql.phpindex 89155d3ec0..6edbbe4b7e 100644--- a/app/Models/StandaloneMysql.php+++ b/app/Models/StandaloneMysql.php@@ -43,6 +43,18 @@ class StandaloneMysql extends BaseModel$database->tags()->detach();});}+ public function workdir()+ {+ return database_configuration_dir() . "/{$this->uuid}";+ }+ public function delete_configurations()+ {+ $server = data_get($this, 'destination.server');+ $workdir = $this->workdir();+ if (str($workdir)->endsWith($this->uuid)) {+ instant_remote_process(["rm -rf " . $this->workdir()], $server, false);+ }+ }public function realStatus(){return $this->getRawOriginal('status');diff --git a/app/Models/StandalonePostgresql.php b/app/Models/StandalonePostgresql.phpindex 0b7589e81d..ddf33f7ed2 100644--- a/app/Models/StandalonePostgresql.php+++ b/app/Models/StandalonePostgresql.php@@ -43,6 +43,18 @@ class StandalonePostgresql extends BaseModel$database->tags()->detach();});}+ public function workdir()+ {+ return database_configuration_dir() . "/{$this->uuid}";+ }+ public function delete_configurations()+ {+ $server = data_get($this, 'destination.server');+ $workdir = $this->workdir();+ if (str($workdir)->endsWith($this->uuid)) {+ instant_remote_process(["rm -rf " . $this->workdir()], $server, false);+ }+ }public function realStatus(){return $this->getRawOriginal('status');diff --git a/app/Models/StandaloneRedis.php b/app/Models/StandaloneRedis.phpindex 2b623f28d3..2ab189fa42 100644--- a/app/Models/StandaloneRedis.php+++ b/app/Models/StandaloneRedis.php@@ -38,6 +38,18 @@ class StandaloneRedis extends BaseModel$database->tags()->detach();});}+ public function workdir()+ {+ return database_configuration_dir() . "/{$this->uuid}";+ }+ public function delete_configurations()+ {+ $server = data_get($this, 'destination.server');+ $workdir = $this->workdir();+ if (str($workdir)->endsWith($this->uuid)) {+ instant_remote_process(["rm -rf " . $this->workdir()], $server, false);+ }+ }public function realStatus(){return $this->getRawOriginal('status');diff --git a/resources/views/livewire/project/database/heading.blade.php b/resources/views/livewire/project/database/heading.blade.phpindex f4eadd6bf1..2829d4a8da 100644--- a/resources/views/livewire/project/database/heading.blade.php+++ b/resources/views/livewire/project/database/heading.blade.php@@ -64,7 +64,7 @@$wire.$call('start');});$wire.$on('stopEvent', () => {- $wire.$dispatch('warning', 'Stopping database.');+ $wire.$dispatch('info', 'Stopping database.');$wire.$call('stop');});</script>diff --git a/resources/views/livewire/project/service/navbar.blade.php b/resources/views/livewire/project/service/navbar.blade.phpindex 8b727ae08b..709fa20321 100644--- a/resources/views/livewire/project/service/navbar.blade.php+++ b/resources/views/livewire/project/service/navbar.blade.php@@ -114,7 +114,7 @@@script<script>$wire.$on('stopEvent', () => {- $wire.$dispatch('warning', 'Stopping service.');+ $wire.$dispatch('info', 'Stopping service.');$wire.$call('stop');});$wire.$on('startEvent', () => {@@ -122,12 +122,12 @@$wire.$call('start');});$wire.$on('restartEvent', () => {- $wire.$dispatch('warning', 'Pulling new images.');+ $wire.$dispatch('info', 'Pulling new images.');$wire.$call('restart');});$wire.on('imagePulled', () => {window.dispatchEvent(new CustomEvent('startservice'));- $wire.$dispatch('warning', 'Restarting service.');+ $wire.$dispatch('info', 'Restarting service.');});</script>@endscriptdiff --git a/resources/views/livewire/project/shared/danger.blade.php b/resources/views/livewire/project/shared/danger.blade.phpindex 5c21f381dd..30d370ee6c 100644--- a/resources/views/livewire/project/shared/danger.blade.php+++ b/resources/views/livewire/project/shared/danger.blade.php@@ -6,6 +6,9 @@back!</div><x-modal-confirmation isErrorButton buttonTitle="Delete">- This resource will be deleted. It is not reversible. <br>Please think again.+ <div class="px-2">This resource will be deleted. It is not reversible. <strong class="text-error">Please think+ again.</strong><br><br></div>+ <x-forms.checkbox class="px-0" id="delete_configurations"+ label="Also delete configuration files from the server (/data/coolify/...)?"></x-forms.checkbox></x-modal-confirmation></div>diff --git a/resources/views/livewire/server/proxy/deploy.blade.php b/resources/views/livewire/server/proxy/deploy.blade.phpindex 88ce67cecb..6fcdfd9ad3 100644--- a/resources/views/livewire/server/proxy/deploy.blade.php+++ b/resources/views/livewire/server/proxy/deploy.blade.php@@ -62,7 +62,7 @@@script<script>$wire.$on('restartEvent', () => {- $wire.$dispatch('warning', 'Restarting proxy.');+ $wire.$dispatch('info', 'Restarting proxy.');$wire.$call('restart');});$wire.$on('proxyChecked', () => {@@ -71,7 +71,7 @@});$wire.$on('stopEvent', () => {- $wire.$dispatch('warning', 'Stopping proxy.');+ $wire.$dispatch('info', 'Stopping proxy.');$wire.$call('stop');});</script>