From 5b424f1f0e44a0783406d4652e7a410c8ae309bc Mon Sep 17 00:00:00 2001 From: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com> Date: Mon, 16 Mar 2026 13:33:58 +0100 Subject: [PATCH] fix(preview): exclude bind mounts from preview deployment suffix Bind mount volumes reference files at the repository's original path and should not receive the -pr-N suffix. Only named Docker volumes require the suffix for isolation between preview deployments. Adds PreviewDeploymentBindMountTest to verify the correct behavior. Fixes #7802 --- bootstrap/helpers/parsers.php | 3 -- coolify-examples-1 | 1 + tests/Unit/PreviewDeploymentBindMountTest.php | 41 +++++++++++++++++++ 3 files changed, 42 insertions(+), 3 deletions(-) create mode 160000 coolify-examples-1 create mode 100644 tests/Unit/PreviewDeploymentBindMountTest.php diff --git a/bootstrap/helpers/parsers.php b/bootstrap/helpers/parsers.php index e84df55f9..95f5fa9c0 100644 --- a/bootstrap/helpers/parsers.php +++ b/bootstrap/helpers/parsers.php @@ -789,9 +789,6 @@ function applicationParser(Application $resource, int $pull_request_id = 0, ?int $mainDirectory = str(base_configuration_dir().'/applications/'.$uuid); } $source = replaceLocalSource($source, $mainDirectory); - if ($isPullRequest) { - $source = addPreviewDeploymentSuffix($source, $pull_request_id); - } LocalFileVolume::updateOrCreate( [ 'mount_path' => $target, diff --git a/coolify-examples-1 b/coolify-examples-1 new file mode 160000 index 000000000..a5964d89a --- /dev/null +++ b/coolify-examples-1 @@ -0,0 +1 @@ +Subproject commit a5964d89a9d361dea373ddabaec265916266c4fc diff --git a/tests/Unit/PreviewDeploymentBindMountTest.php b/tests/Unit/PreviewDeploymentBindMountTest.php new file mode 100644 index 000000000..acc560e68 --- /dev/null +++ b/tests/Unit/PreviewDeploymentBindMountTest.php @@ -0,0 +1,41 @@ +value() === 'bind')"); + $volumeBlockStart = strpos($parsersFile, "} elseif (\$type->value() === 'volume')"); + $bindBlock = substr($parsersFile, $bindBlockStart, $volumeBlockStart - $bindBlockStart); + + // Bind mount paths should NOT be suffixed with -pr-N + expect($bindBlock)->not->toContain('addPreviewDeploymentSuffix'); +}); + +it('still applies preview deployment suffix to named volume paths', function () { + // Read the applicationParser volume handling in parsers.php + $parsersFile = file_get_contents(__DIR__.'/../../bootstrap/helpers/parsers.php'); + + // Find the named volume handling block (type === 'volume') + $volumeBlockStart = strpos($parsersFile, "} elseif (\$type->value() === 'volume')"); + $volumeBlock = substr($parsersFile, $volumeBlockStart, 1000); + + // Named volumes SHOULD still get the -pr-N suffix for isolation + expect($volumeBlock)->toContain('addPreviewDeploymentSuffix'); +}); + +it('confirms addPreviewDeploymentSuffix works correctly', function () { + $result = addPreviewDeploymentSuffix('myvolume', 3); + expect($result)->toBe('myvolume-pr-3'); + + $result = addPreviewDeploymentSuffix('myvolume', 0); + expect($result)->toBe('myvolume'); +});