From d36bc84b5d7d2c3a283d9f079c88e1e80c1f8368 Mon Sep 17 00:00:00 2001 From: Maurits de Ruiter Date: Mon, 23 Feb 2026 20:08:31 +0100 Subject: [PATCH] bind correct directories to preview deployment docker compose containers --- app/Jobs/ApplicationDeploymentJob.php | 9 ++++++++- bootstrap/helpers/parsers.php | 4 ++-- bootstrap/helpers/shared.php | 21 ++++++++++++--------- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php index 700a2d60c..acb67dc59 100644 --- a/app/Jobs/ApplicationDeploymentJob.php +++ b/app/Jobs/ApplicationDeploymentJob.php @@ -224,7 +224,11 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue $this->basedir = $this->application->generateBaseDir($this->deployment_uuid); $this->workdir = "{$this->basedir}".rtrim($this->application->base_directory, '/'); - $this->configuration_dir = application_configuration_dir()."/{$this->application->uuid}"; + if ($this->pull_request_id !== 0) { + $this->configuration_dir = application_configuration_dir()."/".addPreviewDeploymentSuffix($this->application->uuid, $this->pull_request_id); + } else { + $this->configuration_dir = application_configuration_dir()."/{$this->application->uuid}"; + } $this->is_debug_enabled = $this->application->settings->is_debug_enabled; $this->container_name = generateApplicationContainerName($this->application, $this->pull_request_id); @@ -755,6 +759,9 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue // Start compose file $server_workdir = $this->application->workdir(); + if ($this->pull_request_id !== 0) { + $server_workdir = application_configuration_dir()."/".addPreviewDeploymentSuffix($this->application->uuid, $this->pull_request_id); + } if ($this->application->settings->is_raw_compose_deployment_enabled) { if ($this->docker_compose_custom_start_command) { // Auto-inject -f (compose file) and --env-file flags using helper function diff --git a/bootstrap/helpers/parsers.php b/bootstrap/helpers/parsers.php index 53060d28f..d0eb2ad8f 100644 --- a/bootstrap/helpers/parsers.php +++ b/bootstrap/helpers/parsers.php @@ -788,10 +788,10 @@ function applicationParser(Application $resource, int $pull_request_id = 0, ?int } else { $mainDirectory = str(base_configuration_dir().'/applications/'.$uuid); } - $source = replaceLocalSource($source, $mainDirectory); if ($isPullRequest) { - $source = addPreviewDeploymentSuffix($source, $pull_request_id); + $mainDirectory = str(addPreviewDeploymentSuffix($mainDirectory, $pull_request_id)); } + $source = replaceLocalSource($source, $mainDirectory); LocalFileVolume::updateOrCreate( [ 'mount_path' => $target, diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.php index 4372ff955..9e0fd3e56 100644 --- a/bootstrap/helpers/shared.php +++ b/bootstrap/helpers/shared.php @@ -2165,15 +2165,15 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal $mount = $volume->after(':'); if ($name->startsWith('.') || $name->startsWith('~')) { $dir = base_configuration_dir().'/applications/'.$resource->uuid; + if ($pull_request_id !== 0) { + $dir = addPreviewDeploymentSuffix($dir, $pull_request_id); + } if ($name->startsWith('.')) { $name = $name->replaceFirst('.', $dir); } if ($name->startsWith('~')) { $name = $name->replaceFirst('~', $dir); } - if ($pull_request_id !== 0) { - $name = addPreviewDeploymentSuffix($name, $pull_request_id); - } $volume = str("$name:$mount"); } else { if ($pull_request_id !== 0) { @@ -2228,15 +2228,15 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal if ($source && $target) { if ((str($source)->startsWith('.') || str($source)->startsWith('~'))) { $dir = base_configuration_dir().'/applications/'.$resource->uuid; + if ($pull_request_id !== 0) { + $dir = addPreviewDeploymentSuffix($dir, $pull_request_id); + } if (str($source, '.')) { $source = str($source)->replaceFirst('.', $dir); } if (str($source, '~')) { $source = str($source)->replaceFirst('~', $dir); } - if ($pull_request_id !== 0) { - $source = addPreviewDeploymentSuffix($source, $pull_request_id); - } if ($read_only) { data_set($volume, 'source', $source.':'.$target.':ro'); } else { @@ -2289,15 +2289,15 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal $mount = $volume->after(':'); if ($name->startsWith('.') || $name->startsWith('~')) { $dir = base_configuration_dir().'/applications/'.$resource->uuid; + if ($pull_request_id !== 0) { + $dir = addPreviewDeploymentSuffix($dir, $pull_request_id); + } if ($name->startsWith('.')) { $name = $name->replaceFirst('.', $dir); } if ($name->startsWith('~')) { $name = $name->replaceFirst('~', $dir); } - if ($pull_request_id !== 0) { - $name = addPreviewDeploymentSuffix($name, $pull_request_id); - } $volume = str("$name:$mount"); } else { if ($pull_request_id !== 0) { @@ -2357,6 +2357,9 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal $uuid = $resource->uuid; if ((str($source)->startsWith('.') || str($source)->startsWith('~') || str($source)->startsWith('/'))) { $dir = base_configuration_dir().'/applications/'.$resource->uuid; + if ($pull_request_id !== 0) { + $dir = addPreviewDeploymentSuffix($dir, $pull_request_id); + } if (str($source, '.')) { $source = str($source)->replaceFirst('.', $dir); }