Skip to content

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.

Fix: DB image cleanup

ayntk-aic16e914be4fc
diff --git a/app/Actions/Database/StopDatabase.php b/app/Actions/Database/StopDatabase.php
index 29ce794cf3..f90851c933 100644
--- a/app/Actions/Database/StopDatabase.php
+++ b/app/Actions/Database/StopDatabase.php
@@ -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) {
diff --git a/app/Livewire/Project/Database/Heading.php b/app/Livewire/Project/Database/Heading.php
index 6435f6781d..4eca89cb63 100644
--- a/app/Livewire/Project/Database/Heading.php
+++ b/app/Livewire/Project/Database/Heading.php
@@ -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)'],
+ ]
+ ]);
+ }
}
diff --git a/resources/views/livewire/project/database/heading.blade.php b/resources/views/livewire/project/database/heading.blade.php
index 07d52034f2..b8156a0bfc 100644
--- a/resources/views/livewire/project/database/heading.blade.php
+++ b/resources/views/livewire/project/database/heading.blade.php
@@ -54,9 +54,11 @@
title="Confirm Database Stopping?"
buttonTitle="Stop"
submitAction="stop"
+ :checkboxes="$checkboxes"
:actions="['This database will be stopped.', 'If the database is currently in use data could be lost.', 'All non-persistent data of this database (containers, networks, unused images) will be deleted (don\'t worry, no data is lost and you can start the database again).']"
:confirmWithText="false"
:confirmWithPassword="false"
+ step1ButtonText="Continue Stopping Database"
step2ButtonText="Stop Database"
:dispatchEvent="true"
dispatchEventType="stopEvent"