fix: bind volumes for compose bp

This commit is contained in:
Andras Bacsai
2023-12-06 13:45:43 +01:00
parent 54b6472f3b
commit dff7ed5b7b

View File

@@ -1124,7 +1124,7 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal
$serviceVolumes = $serviceVolumes->map(function ($volume) use ($resource, $pull_request_id, $topLevelVolumes) { $serviceVolumes = $serviceVolumes->map(function ($volume) use ($resource, $pull_request_id, $topLevelVolumes) {
if (is_string($volume)) { if (is_string($volume)) {
$volume = str($volume); $volume = str($volume);
if ($volume->contains(':')) { if ($volume->contains(':') && !$volume->startsWith('/')) {
$name = $volume->before(':'); $name = $volume->before(':');
$mount = $volume->after(':'); $mount = $volume->after(':');
$newName = $resource->uuid . "-{$name}-pr-$pull_request_id"; $newName = $resource->uuid . "-{$name}-pr-$pull_request_id";
@@ -1138,13 +1138,13 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal
if ($source) { if ($source) {
$newSource = $resource->uuid . "-{$source}-pr-$pull_request_id"; $newSource = $resource->uuid . "-{$source}-pr-$pull_request_id";
data_set($volume, 'source', $newSource); data_set($volume, 'source', $newSource);
$topLevelVolumes->put($newSource, [ if (!str($source)->startsWith('/')) {
'name' => $newSource, $topLevelVolumes->put($newSource, [
]); 'name' => $newSource,
]);
}
} }
} }
return $volume->value(); return $volume->value();
}); });
data_set($service, 'volumes', $serviceVolumes->toArray()); data_set($service, 'volumes', $serviceVolumes->toArray());
@@ -1154,7 +1154,7 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal
$serviceVolumes = $serviceVolumes->map(function ($volume) use ($resource, $topLevelVolumes) { $serviceVolumes = $serviceVolumes->map(function ($volume) use ($resource, $topLevelVolumes) {
if (is_string($volume)) { if (is_string($volume)) {
$volume = str($volume); $volume = str($volume);
if ($volume->contains(':')) { if ($volume->contains(':') && !$volume->startsWith('/')) {
$name = $volume->before(':'); $name = $volume->before(':');
$mount = $volume->after(':'); $mount = $volume->after(':');
if ($name->startsWith('.') || $name->startsWith('~')) { if ($name->startsWith('.') || $name->startsWith('~')) {
@@ -1175,7 +1175,7 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal
} else if (is_array($volume)) { } else if (is_array($volume)) {
$source = data_get($volume, 'source'); $source = data_get($volume, 'source');
if ($source) { if ($source) {
if (str($source, '.') || str($source, '~')) { if ((str($source)->startsWith('.') || str($source)->startsWith('~')) && !str($source)->startsWith('/')) {
$dir = base_configuration_dir() . '/applications/' . $resource->uuid; $dir = base_configuration_dir() . '/applications/' . $resource->uuid;
if (str($source, '.')) { if (str($source, '.')) {
$source = str('.', $dir, $source); $source = str('.', $dir, $source);