wip: coolify.json

This commit is contained in:
Andras Bacsai
2024-10-08 15:11:19 +02:00
parent 052fcd2520
commit 974b4b92c1
9 changed files with 195 additions and 4 deletions

View File

@@ -3981,3 +3981,31 @@ function instanceSettings()
{
return InstanceSettings::get();
}
function loadConfigFromGit(string $repository, string $branch, string $base_directory, int $server_id, int $team_id) {
$server = Server::find($server_id)->where('team_id', $team_id)->first();
if (!$server) {
return;
}
$uuid = new Cuid2();
$cloneCommand = "git clone --no-checkout -b $branch $repository .";
$workdir = rtrim($base_directory, '/');
$fileList = collect([".$workdir/coolify.json"]);
$commands = collect([
"rm -rf /tmp/{$uuid}",
"mkdir -p /tmp/{$uuid}",
"cd /tmp/{$uuid}",
$cloneCommand,
'git sparse-checkout init --cone',
"git sparse-checkout set {$fileList->implode(' ')}",
'git read-tree -mu HEAD',
"cat .$workdir/coolify.json",
'rm -rf /tmp/{$uuid}',
]);
try {
return instant_remote_process($commands, $server);
} catch (\Exception $e) {
// continue
}
}