fix(compose): use explicit compose file paths and remove volumes by name (#12199)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Andras Bacsai
2026-10-19 00:00:48 +02:00
committed by GitHub
co-authored by Claude Opus 5.5
parent 9355728d03
commit 0eeb630ccd
6 changed files with 87 additions and 25 deletions
+12 -15
View File
@@ -546,24 +546,21 @@ class Application extends BaseModel
}
}
/**
* Removes the volumes by the names that Coolify stored.
*/
public function deleteVolumes()
{
$persistentStorages = $this->persistentStorages()->get() ?? collect();
if ($this->build_pack === 'dockercompose') {
$server = data_get($this, 'destination.server');
// --project-directory instead of cd: a non-root SSH user cannot enter the directory on the Coolify host.
instant_remote_process(["docker compose --project-directory {$this->dirOnServer()} down -v"], $server, false);
} else {
if ($persistentStorages->count() === 0) {
return;
}
$server = data_get($this, 'destination.server');
foreach ($persistentStorages as $storage) {
if ($storage->isSharedWithAnotherResource()) {
continue;
}
instant_remote_process(['docker volume rm -f '.escapeshellarg($storage->name)], $server, false);
$persistentStorages = $this->persistentStorages()->get();
if ($persistentStorages->isEmpty()) {
return;
}
$server = data_get($this, 'destination.server');
foreach ($persistentStorages as $storage) {
if ($storage->isSharedWithAnotherResource()) {
continue;
}
instant_remote_process(['docker volume rm -f '.escapeshellarg($storage->name)], $server, false);
}
}