Fix: DB image cleanup

This commit is contained in:
ayntk-ai
2024-09-04 14:59:44 +02:00
parent bec974dca4
commit c16e914be4
3 changed files with 18 additions and 3 deletions

View File

@@ -18,7 +18,7 @@ class StopDatabase
{
use AsAction;
public function handle(StandaloneRedis|StandalonePostgresql|StandaloneMongodb|StandaloneMysql|StandaloneMariadb|StandaloneKeydb|StandaloneDragonfly|StandaloneClickhouse $database, bool $isDeleteOperation = false)
public function handle(StandaloneRedis|StandalonePostgresql|StandaloneMongodb|StandaloneMysql|StandaloneMariadb|StandaloneKeydb|StandaloneDragonfly|StandaloneClickhouse $database, bool $isDeleteOperation = false, bool $dockerCleanup = true)
{
$server = $database->destination->server;
if (!$server->isFunctional()) {
@@ -28,7 +28,9 @@ class StopDatabase
$this->stopContainer($database, $database->uuid, 300);
if (!$isDeleteOperation) {
$this->deleteConnectedNetworks($database->uuid, $server); //Probably not needed as DBs do not have a network normally
CleanupDocker::run($server, true);
if ($dockerCleanup) {
CleanupDocker::run($server, true);
}
}
if ($database->is_public) {

View File

@@ -14,6 +14,8 @@ class Heading extends Component
public array $parameters;
public $docker_cleanup = true;
public function getListeners()
{
$userId = auth()->user()->id;
@@ -54,7 +56,7 @@ class Heading extends Component
public function stop()
{
StopDatabase::run($this->database);
StopDatabase::run($this->database, false, $this->docker_cleanup);
$this->database->status = 'exited';
$this->database->save();
$this->check_status();
@@ -71,4 +73,13 @@ class Heading extends Component
$activity = StartDatabase::run($this->database);
$this->dispatch('activityMonitor', $activity->id);
}
public function render()
{
return view('livewire.project.database.heading', [
'checkboxes' => [
['id' => 'docker_cleanup', 'label' => 'Docker cleanup will be run on the server which removes builder cache and unused images (the next deployment will take longer as the images have to be pulled again)'],
]
]);
}
}