mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-06 13:10:37 -04:00
fix(previews): do not bind preview volumes to the production host device
A preview volume no longer gets driver_opts that name a host device, so it does not mount the same folder or disk as the production volume. tmpfs options are kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
a0fa21b448
commit
7ec46faecb
@@ -494,15 +494,23 @@ function composeRenamedVolumeDeclaration(mixed $declaration, string $name): arra
|
||||
* name-only declaration: Docker created it without the options, and Docker Compose would otherwise
|
||||
* ask to recreate it on every deployment.
|
||||
*
|
||||
* A preview volume does not get `driver_opts` that name a host device (for example a bind mount of a
|
||||
* host folder): the preview would otherwise mount the same folder or disk as the production volume.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
function composeRenamedVolumeDeclarationFor(mixed $declaration, string $name, ?LocalPersistentVolume $volume): array
|
||||
function composeRenamedVolumeDeclarationFor(mixed $declaration, string $name, ?LocalPersistentVolume $volume, bool $isPreview = false): array
|
||||
{
|
||||
if ($volume?->ignores_compose_driver_options) {
|
||||
return ['name' => $name];
|
||||
}
|
||||
|
||||
return composeRenamedVolumeDeclaration($declaration, $name);
|
||||
$renamed = composeRenamedVolumeDeclaration($declaration, $name);
|
||||
if ($isPreview && filled(data_get($renamed, 'driver_opts.device')) && data_get($renamed, 'driver_opts.type') !== 'tmpfs') {
|
||||
unset($renamed['driver_opts']);
|
||||
}
|
||||
|
||||
return $renamed;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1509,7 +1517,7 @@ function applicationParser(Application $resource, int $pull_request_id = 0, ?int
|
||||
'resource_type' => get_class($originalResource),
|
||||
]
|
||||
);
|
||||
$topLevel->get('volumes')->put($name, composeRenamedVolumeDeclarationFor($declaration, $name, $persistentVolume));
|
||||
$topLevel->get('volumes')->put($name, composeRenamedVolumeDeclarationFor($declaration, $name, $persistentVolume, $isPullRequest));
|
||||
}
|
||||
dispatch(new ServerFilesFromServerJob($originalResource));
|
||||
$volumesParsed->put($index, $volume);
|
||||
|
||||
Reference in New Issue
Block a user