Merge pull request #1766 from coollabsio/next

v4.0.0-beta.221
This commit is contained in:
Andras Bacsai 2024-02-19 13:29:58 +01:00 committed by GitHub
commit b983b23e7e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 24 additions and 15 deletions

View File

@ -6,6 +6,7 @@
use Illuminate\Database\Eloquent\Casts\Attribute; use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Collection;
use Spatie\Activitylog\Models\Activity; use Spatie\Activitylog\Models\Activity;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use RuntimeException; use RuntimeException;
@ -212,7 +213,8 @@ public function portsMappingsArray(): Attribute
); );
} }
public function isExited() { public function isExited()
{
return (bool) str($this->status)->startsWith('exited'); return (bool) str($this->status)->startsWith('exited');
} }
public function realStatus() public function realStatus()
@ -521,17 +523,21 @@ function generateBaseDir(string $uuid)
{ {
return "/artifacts/{$uuid}"; 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); $baseDir = $this->generateBaseDir($deployment_uuid);
if ($this->git_commit_sha !== 'HEAD') { 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) { 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) { 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; return $git_clone_command;
} }
@ -559,7 +565,7 @@ function generateGitImportCommands(string $deployment_uuid, int $pull_request_id
$fullRepoUrl = "{$this->source->html_url}/{$customRepository}"; $fullRepoUrl = "{$this->source->html_url}/{$customRepository}";
$git_clone_command = "{$git_clone_command} {$this->source->html_url}/{$customRepository} {$baseDir}"; $git_clone_command = "{$git_clone_command} {$this->source->html_url}/{$customRepository} {$baseDir}";
if (!$only_checkout) { 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) { if ($exec_in_docker) {
$commands->push(executeInDocker($deployment_uuid, $git_clone_command)); $commands->push(executeInDocker($deployment_uuid, $git_clone_command));
@ -658,7 +664,7 @@ function generateGitImportCommands(string $deployment_uuid, int $pull_request_id
if ($this->deploymentType() === 'other') { if ($this->deploymentType() === 'other') {
$fullRepoUrl = $customRepository; $fullRepoUrl = $customRepository;
$git_clone_command = "{$git_clone_command} {$customRepository} {$baseDir}"; $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 ($pull_request_id !== 0) {
if ($git_type === 'gitlab') { if ($git_type === 'gitlab') {

View File

@ -225,20 +225,23 @@ public function definedResources()
$services = $this->services(); $services = $this->services();
return $applications->concat($databases)->concat($services->get()); 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); 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); return instant_remote_process(["docker restart $id"], $this);
} }
public function startUnmanaged($id) { public function startUnmanaged($id)
{
return instant_remote_process(["docker start $id"], $this); return instant_remote_process(["docker start $id"], $this);
} }
public function loadUnmanagedContainers() public function loadUnmanagedContainers()
{ {
$containers = instant_remote_process(["docker ps -a --format '{{json .}}' "], $this); $containers = instant_remote_process(["docker ps -a --format '{{json .}}' "], $this);
$containers = format_docker_command_output_to_json($containers); $containers = format_docker_command_output_to_json($containers);
$containers = $containers->map(function ($container) { $containers = $containers->map(function ($container) {
$labels = data_get($container, 'Labels'); $labels = data_get($container, 'Labels');
if (!str($labels)->contains("coolify.managed")) { if (!str($labels)->contains("coolify.managed")) {
return $container; return $container;
@ -269,7 +272,7 @@ public function databases()
$mariadbs = data_get($standaloneDocker, 'mariadbs', collect([])); $mariadbs = data_get($standaloneDocker, 'mariadbs', collect([]));
return $postgresqls->concat($redis)->concat($mongodbs)->concat($mysqls)->concat($mariadbs); return $postgresqls->concat($redis)->concat($mongodbs)->concat($mysqls)->concat($mariadbs);
})->filter(function ($item) { })->filter(function ($item) {
return data_get($item, 'name') === 'coolify-db'; return data_get($item, 'name') !== 'coolify-db';
})->flatten(); })->flatten();
} }
public function applications() public function applications()

View File

@ -7,7 +7,7 @@
// The release version of your application // The release version of your application
// Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD')) // 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 // When left empty or `null` the Laravel environment will be used
'environment' => config('app.env'), 'environment' => config('app.env'),

View File

@ -1,3 +1,3 @@
<?php <?php
return '4.0.0-beta.220'; return '4.0.0-beta.221';

View File

@ -4,7 +4,7 @@
"version": "3.12.36" "version": "3.12.36"
}, },
"v4": { "v4": {
"version": "4.0.0-beta.220" "version": "4.0.0-beta.221"
} }
} }
} }