diff --git a/app/Console/Commands/ResourcesDelete.php b/app/Console/Commands/ResourcesDelete.php new file mode 100644 index 000000000..d230aa927 --- /dev/null +++ b/app/Console/Commands/ResourcesDelete.php @@ -0,0 +1,100 @@ +deleteApplication(); + } elseif ($resource === 'Database') { + $this->deleteDatabase(); + } elseif ($resource === 'Service') { + $this->deleteService(); + } + } + private function deleteApplication() + { + $applications = Application::all(); + if ($applications->count() === 0) { + $this->error('There are no applications to delete.'); + return; + } + $application = select( + 'What application do you want to delete?', + $applications->pluck('name')->toArray(), + ); + $application = $applications->where('name', $application)->first(); + $confirmed = confirm("Are you sure you want to delete {$application->name}?"); + if (!$confirmed) { + return; + } + $application->delete(); + } + private function deleteDatabase() + { + $databases = StandalonePostgresql::all(); + if ($databases->count() === 0) { + $this->error('There are no databases to delete.'); + return; + } + $database = select( + 'What database do you want to delete?', + $databases->pluck('name')->toArray(), + ); + $database = $databases->where('name', $database)->first(); + $confirmed = confirm("Are you sure you want to delete {$database->name}?"); + if (!$confirmed) { + return; + } + $database->delete(); + } + private function deleteService() + { + $services = Service::all(); + if ($services->count() === 0) { + $this->error('There are no services to delete.'); + return; + } + $service = select( + 'What service do you want to delete?', + $services->pluck('name')->toArray(), + ); + $service = $services->where('name', $service)->first(); + $confirmed = confirm("Are you sure you want to delete {$service->name}?"); + if (!$confirmed) { + return; + } + $service->delete(); + } +} diff --git a/app/Console/Commands/ResetRootPassword.php b/app/Console/Commands/UsersResetRoot.php similarity index 92% rename from app/Console/Commands/ResetRootPassword.php rename to app/Console/Commands/UsersResetRoot.php index 61e0eb309..d72ef07d9 100644 --- a/app/Console/Commands/ResetRootPassword.php +++ b/app/Console/Commands/UsersResetRoot.php @@ -8,14 +8,14 @@ use Illuminate\Support\Facades\Hash; use function Laravel\Prompts\password; -class ResetRootPassword extends Command +class UsersResetRoot extends Command { /** * The name and signature of the console command. * * @var string */ - protected $signature = 'app:reset-root-password'; + protected $signature = 'users:reset-root'; /** * The console command description. diff --git a/app/Http/Livewire/Project/Shared/Storages/All.php b/app/Http/Livewire/Project/Shared/Storages/All.php index 30fa9e9e9..8ac22d881 100644 --- a/app/Http/Livewire/Project/Shared/Storages/All.php +++ b/app/Http/Livewire/Project/Shared/Storages/All.php @@ -7,6 +7,7 @@ use Livewire\Component; class All extends Component { + public bool $isHeaderVisible = true; public $resource; protected $listeners = ['refreshStorages', 'submit']; diff --git a/app/Http/Livewire/Project/Shared/Storages/Show.php b/app/Http/Livewire/Project/Shared/Storages/Show.php index 84593aef3..15d16095c 100644 --- a/app/Http/Livewire/Project/Shared/Storages/Show.php +++ b/app/Http/Livewire/Project/Shared/Storages/Show.php @@ -11,6 +11,7 @@ class Show extends Component public LocalPersistentVolume $storage; public bool $isReadOnly = false; public ?string $modalId = null; + public bool $isFirst = true; protected $rules = [ 'storage.name' => 'required|string', diff --git a/app/Models/Application.php b/app/Models/Application.php index 224b332cc..fc437769a 100644 --- a/app/Models/Application.php +++ b/app/Models/Application.php @@ -18,10 +18,16 @@ class Application extends BaseModel ]); }); static::deleting(function ($application) { + // Stop Container + instant_remote_process( + ["docker rm -f {$application->uuid}"], + $application->destination->server, + false + ); $application->settings()->delete(); $storages = $application->persistentStorages()->get(); foreach ($storages as $storage) { - instant_remote_process(["docker volume rm -f $storage->name"], $application->destination->server); + instant_remote_process(["docker volume rm -f $storage->name"], $application->destination->server, false); } $application->persistentStorages()->delete(); $application->environment_variables()->delete(); @@ -233,7 +239,7 @@ class Application extends BaseModel } public function isHealthcheckDisabled(): bool { - if (data_get($this, 'dockerfile') || data_get($this, 'build_pack') === 'dockerfile' || data_get($this,'health_check_enabled') === false) { + if (data_get($this, 'dockerfile') || data_get($this, 'build_pack') === 'dockerfile' || data_get($this, 'health_check_enabled') === false) { ray('dockerfile'); return true; } diff --git a/app/Models/Service.php b/app/Models/Service.php index c23ff075a..49d8b9f33 100644 --- a/app/Models/Service.php +++ b/app/Models/Service.php @@ -8,7 +8,6 @@ use Illuminate\Support\Collection; use Illuminate\Support\Facades\Cache; use Symfony\Component\Yaml\Yaml; use Illuminate\Support\Str; -use Spatie\Url\Url; class Service extends BaseModel { @@ -20,6 +19,7 @@ class Service extends BaseModel static::deleted(function ($service) { $storagesToDelete = collect([]); foreach ($service->applications()->get() as $application) { + instant_remote_process(["docker rm -f {$application->name}-{$service->uuid}"], $service->server, false); $storages = $application->persistentStorages()->get(); foreach ($storages as $storage) { $storagesToDelete->push($storage); @@ -27,6 +27,7 @@ class Service extends BaseModel $application->persistentStorages()->delete(); } foreach ($service->databases()->get() as $database) { + instant_remote_process(["docker rm -f {$database->name}-{$service->uuid}"], $service->server, false); $storages = $database->persistentStorages()->get(); foreach ($storages as $storage) { $storagesToDelete->push($storage); @@ -318,11 +319,7 @@ class Service extends BaseModel ); } else if ($type->value() === 'volume') { $slug = Str::slug($source, '-'); - if ($isNew) { - $name = "{$savedService->service->uuid}-{$slug}"; - } else { - $name = "{$savedService->service->uuid}_{$slug}"; - } + $name = "{$savedService->service->uuid}_{$slug}"; if (is_string($volume)) { $source = Str::of($volume)->before(':'); $target = Str::of($volume)->after(':')->beforeLast(':'); diff --git a/app/Models/StandalonePostgresql.php b/app/Models/StandalonePostgresql.php index 21ec17e40..17b5b8056 100644 --- a/app/Models/StandalonePostgresql.php +++ b/app/Models/StandalonePostgresql.php @@ -29,9 +29,20 @@ class StandalonePostgresql extends BaseModel ]); }); static::deleted(function ($database) { + // Stop Container + instant_remote_process( + ["docker rm -f {$database->uuid}"], + $database->destination->server, + false + ); + // Stop TCP Proxy + if ($database->is_public) { + instant_remote_process(["docker rm -f {$database->uuid}-proxy"], $database->destination->server, false); + } $database->scheduledBackups()->delete(); $database->persistentStorages()->delete(); $database->environment_variables()->delete(); + // Remove Volume instant_remote_process(['docker volume rm postgres-data-' . $database->uuid], $database->destination->server, false); }); } diff --git a/config/sentry.php b/config/sentry.php index 5bd48364a..fbddc758e 100644 --- a/config/sentry.php +++ b/config/sentry.php @@ -7,7 +7,7 @@ return [ // The release version of your application // Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD')) - 'release' => '4.0.0-beta.59', + 'release' => '4.0.0-beta.60', // When left empty or `null` the Laravel environment will be used 'environment' => config('app.env'), diff --git a/config/version.php b/config/version.php index 75c583caf..b61b5c9de 100644 --- a/config/version.php +++ b/config/version.php @@ -1,3 +1,3 @@