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
This commit is contained in:
parent
74d591e6e9
commit
5b424f1f0e
3 changed files with 42 additions and 3 deletions
|
|
@ -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,
|
||||
|
|
|
|||
1
coolify-examples-1
Submodule
1
coolify-examples-1
Submodule
|
|
@ -0,0 +1 @@
|
|||
Subproject commit a5964d89a9d361dea373ddabaec265916266c4fc
|
||||
41
tests/Unit/PreviewDeploymentBindMountTest.php
Normal file
41
tests/Unit/PreviewDeploymentBindMountTest.php
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Tests for GitHub issue #7802: volume mappings from repo content in Preview Deployments.
|
||||
*
|
||||
* Bind mount volumes (e.g., ./scripts:/scripts:ro) should NOT get a -pr-N suffix
|
||||
* during preview deployments, because the repo files exist at the original path.
|
||||
* Only named Docker volumes need the suffix for isolation between PRs.
|
||||
*/
|
||||
it('does not apply preview deployment suffix to bind mount source paths', function () {
|
||||
// Read the applicationParser volume handling in parsers.php
|
||||
$parsersFile = file_get_contents(__DIR__.'/../../bootstrap/helpers/parsers.php');
|
||||
|
||||
// Find the bind mount handling block (type === 'bind')
|
||||
$bindBlockStart = strpos($parsersFile, "if (\$type->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');
|
||||
});
|
||||
Loading…
Reference in a new issue