From 4a3338e59cd09630c8883fc9e95e9d8520d76ee9 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Mon, 19 Feb 2024 10:44:52 +0100 Subject: [PATCH 1/3] Update version numbers --- config/sentry.php | 2 +- config/version.php | 2 +- versions.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/sentry.php b/config/sentry.php index bc708e23e..c974623b0 100644 --- a/config/sentry.php +++ b/config/sentry.php @@ -7,7 +7,7 @@ return [ // The release version of your application // Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD')) - 'release' => '4.0.0-beta.220', + 'release' => '4.0.0-beta.221', // When left empty or `null` the Laravel environment will be used 'environment' => config('app.env'), diff --git a/config/version.php b/config/version.php index 97edca729..c67555702 100644 --- a/config/version.php +++ b/config/version.php @@ -1,3 +1,3 @@ Date: Mon, 19 Feb 2024 13:22:09 +0100 Subject: [PATCH 2/3] fix: submodule cloning --- app/Models/Application.php | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/app/Models/Application.php b/app/Models/Application.php index a12be33fd..b3838608f 100644 --- a/app/Models/Application.php +++ b/app/Models/Application.php @@ -6,6 +6,7 @@ use App\Enums\ApplicationDeploymentStatus; use Illuminate\Database\Eloquent\Casts\Attribute; use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\SoftDeletes; +use Illuminate\Support\Collection; use Spatie\Activitylog\Models\Activity; use Illuminate\Support\Str; use RuntimeException; @@ -212,7 +213,8 @@ class Application extends BaseModel ); } - public function isExited() { + public function isExited() + { return (bool) str($this->status)->startsWith('exited'); } public function realStatus() @@ -521,17 +523,21 @@ class Application extends BaseModel { return "/artifacts/{$uuid}"; } - function setGitImportSettings(string $deployment_uuid, string $git_clone_command) + function setGitImportSettings(string $deployment_uuid, string $git_clone_command, bool $public = false) { $baseDir = $this->generateBaseDir($deployment_uuid); + if ($this->git_commit_sha !== 'HEAD') { - $git_clone_command = "{$git_clone_command} && cd {$baseDir} && git -c advice.detachedHead=false checkout {$this->git_commit_sha} >/dev/null 2>&1"; + $git_clone_command = "{$git_clone_command} && cd {$baseDir} && GIT_SSH_COMMAND=\"ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null\" git -c advice.detachedHead=false checkout {$this->git_commit_sha} >/dev/null 2>&1"; } if ($this->settings->is_git_submodules_enabled) { - $git_clone_command = "{$git_clone_command} && cd {$baseDir} && git submodule update --init --recursive"; + if ($public) { + $git_clone_command = "{$git_clone_command} && cd {$baseDir} && sed -i \"s#git@\(.*\):#https://\\1/#g\" {$baseDir}/.gitmodules || true"; + } + $git_clone_command = "{$git_clone_command} && cd {$baseDir} && GIT_SSH_COMMAND=\"ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null\" git submodule update --init --recursive"; } if ($this->settings->is_git_lfs_enabled) { - $git_clone_command = "{$git_clone_command} && cd {$baseDir} && git lfs pull"; + $git_clone_command = "{$git_clone_command} && cd {$baseDir} && GIT_SSH_COMMAND=\"ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null\" git lfs pull"; } return $git_clone_command; } @@ -559,7 +565,7 @@ class Application extends BaseModel $fullRepoUrl = "{$this->source->html_url}/{$customRepository}"; $git_clone_command = "{$git_clone_command} {$this->source->html_url}/{$customRepository} {$baseDir}"; if (!$only_checkout) { - $git_clone_command = $this->setGitImportSettings($deployment_uuid, $git_clone_command); + $git_clone_command = $this->setGitImportSettings($deployment_uuid, $git_clone_command, public: true); } if ($exec_in_docker) { $commands->push(executeInDocker($deployment_uuid, $git_clone_command)); @@ -658,7 +664,7 @@ class Application extends BaseModel if ($this->deploymentType() === 'other') { $fullRepoUrl = $customRepository; $git_clone_command = "{$git_clone_command} {$customRepository} {$baseDir}"; - $git_clone_command = $this->setGitImportSettings($deployment_uuid, $git_clone_command); + $git_clone_command = $this->setGitImportSettings($deployment_uuid, $git_clone_command, public: true); if ($pull_request_id !== 0) { if ($git_type === 'gitlab') { From 0b81e77a941d1fce91b86538992f681c66bbd09f Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Mon, 19 Feb 2024 13:28:14 +0100 Subject: [PATCH 3/3] fix: database status --- app/Models/Server.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/app/Models/Server.php b/app/Models/Server.php index 24799fe6e..76ed8c8a9 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -225,20 +225,23 @@ class Server extends BaseModel $services = $this->services(); return $applications->concat($databases)->concat($services->get()); } - public function stopUnmanaged($id) { + public function stopUnmanaged($id) + { return instant_remote_process(["docker stop -t 0 $id"], $this); } - public function restartUnmanaged($id) { + public function restartUnmanaged($id) + { return instant_remote_process(["docker restart $id"], $this); } - public function startUnmanaged($id) { + public function startUnmanaged($id) + { return instant_remote_process(["docker start $id"], $this); } public function loadUnmanagedContainers() { $containers = instant_remote_process(["docker ps -a --format '{{json .}}' "], $this); $containers = format_docker_command_output_to_json($containers); - $containers = $containers->map(function ($container) { + $containers = $containers->map(function ($container) { $labels = data_get($container, 'Labels'); if (!str($labels)->contains("coolify.managed")) { return $container; @@ -269,7 +272,7 @@ class Server extends BaseModel $mariadbs = data_get($standaloneDocker, 'mariadbs', collect([])); return $postgresqls->concat($redis)->concat($mongodbs)->concat($mysqls)->concat($mariadbs); })->filter(function ($item) { - return data_get($item, 'name') === 'coolify-db'; + return data_get($item, 'name') !== 'coolify-db'; })->flatten(); } public function applications()