From 74824b7737bc46e36d8f85957b8b3b3a5a76e748 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 29 May 2024 18:01:10 +0200 Subject: [PATCH] fix: compose load with non-root user --- app/Models/Application.php | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/app/Models/Application.php b/app/Models/Application.php index e6fd3e33d..21c5dfea8 100644 --- a/app/Models/Application.php +++ b/app/Models/Application.php @@ -669,7 +669,9 @@ class Application extends BaseModel $git_clone_command = "{$git_clone_command} $source_html_url_scheme://x-access-token:$github_access_token@$source_html_url_host/{$customRepository} {$baseDir}"; $fullRepoUrl = "$source_html_url_scheme://x-access-token:$github_access_token@$source_html_url_host/{$customRepository}"; } - $git_clone_command = $this->setGitImportSettings($deployment_uuid, $git_clone_command, public: false); + if (!$only_checkout) { + $git_clone_command = $this->setGitImportSettings($deployment_uuid, $git_clone_command, public: false); + } if ($exec_in_docker) { $commands->push(executeInDocker($deployment_uuid, $git_clone_command)); } else { @@ -888,7 +890,8 @@ class Application extends BaseModel // } $commands = collect([ "rm -rf /tmp/{$uuid}", - "mkdir -p /tmp/{$uuid} && cd /tmp/{$uuid}", + "mkdir -p /tmp/{$uuid}", + "cd /tmp/{$uuid}", $cloneCommand, "git sparse-checkout init --cone", "git sparse-checkout set {$fileList->implode(' ')}", @@ -899,29 +902,15 @@ class Application extends BaseModel if (!$composeFileContent) { $this->docker_compose_location = $initialDockerComposeLocation; $this->save(); + $commands = collect([ + "rm -rf /tmp/{$uuid}", + ]); + instant_remote_process($commands, $this->destination->server, false); throw new \RuntimeException("Docker Compose file not found at: $workdir$composeFile

Check if you used the right extension (.yaml or .yml) in the compose file name."); } else { $this->docker_compose_raw = $composeFileContent; $this->save(); } - // if ($composeFile === $prComposeFile) { - // $this->docker_compose_pr_raw = $composeFileContent; - // $this->save(); - // } else { - // $commands = collect([ - // "cd /tmp/{$uuid}", - // "cat .$workdir$prComposeFile", - // ]); - // $composePrFileContent = instant_remote_process($commands, $this->destination->server, false); - // if (!$composePrFileContent) { - // $this->docker_compose_pr_location = $initialDockerComposePrLocation; - // $this->save(); - // throw new \Exception("Could not load compose file from $workdir$prComposeFile"); - // } else { - // $this->docker_compose_pr_raw = $composePrFileContent; - // $this->save(); - // } - // } $commands = collect([ "rm -rf /tmp/{$uuid}",