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
fix(server): exclude persistent resources from container prune
Andras Bacsai0620496c5fc5
diff --git a/app/Actions/Server/CleanupDocker.php b/app/Actions/Server/CleanupDocker.phpindex 0d9ca0153e..98cce088b2 100644--- a/app/Actions/Server/CleanupDocker.php+++ b/app/Actions/Server/CleanupDocker.php@@ -48,7 +48,7 @@ class CleanupDocker);$commands = [- 'docker container prune -f --filter "label=coolify.managed=true" --filter "label!=coolify.proxy=true"',+ 'docker container prune -f --filter "label=coolify.managed=true" --filter "label!=coolify.proxy=true" --filter "label!=coolify.type=database" --filter "label!=coolify.type=application" --filter "label!=coolify.type=service"',$imagePruneCmd,'docker builder prune -af',"docker images --filter before=$helperImageWithVersion --filter reference=$helperImage | grep $helperImage | awk '{print $3}' | xargs -r docker rmi -f",diff --git a/tests/Unit/Actions/Server/CleanupDockerTest.php b/tests/Unit/Actions/Server/CleanupDockerTest.phpindex fc8b8ab9b3..1a6a0d3d62 100644--- a/tests/Unit/Actions/Server/CleanupDockerTest.php+++ b/tests/Unit/Actions/Server/CleanupDockerTest.php@@ -437,6 +437,16 @@ it('deletes all build images when retention is disabled', function () {expect($buildImagesToDelete->pluck('tag')->toArray())->toContain('commit1-build');});+it('container prune excludes persistent resource types', function () {+ $sourceFile = file_get_contents(__DIR__.'/../../../../app/Actions/Server/CleanupDocker.php');++ expect($sourceFile)->toContain('label!=coolify.type=database');+ expect($sourceFile)->toContain('label!=coolify.type=application');+ expect($sourceFile)->toContain('label!=coolify.type=service');+ expect($sourceFile)->toContain('label!=coolify.proxy=true');+ expect($sourceFile)->toContain('label=coolify.managed=true');+});+it('preserves build image for currently running tag', function () {$images = collect([['repository' => 'app-uuid', 'tag' => 'commit1', 'created_at' => '2024-01-01 10:00:00', 'image_ref' => 'app-uuid:commit1'],