chore: merge main into release/v4.5 (#12192)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Furox <177975472+Furox-Art@users.noreply.github.com>
Co-authored-by: johandenhollander <johan.den.hollander@finalist.nl>
Co-authored-by: João Cruz <161638790+SrJooJ@users.noreply.github.com>
Co-authored-by: Saim Hashmi <hashmisaim037@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This commit is contained in:
github-actions[bot]
2026-10-18 23:43:20 +02:00
committed by GitHub
co-authored by Andras Bacsai Claude Opus 5.5 Furox johandenhollander João Cruz Saim Hashmi dependabot[bot]
parent 5dddcfd276
commit e3d4411ff2
246 changed files with 32148 additions and 1316 deletions
@@ -4,16 +4,22 @@
* Runs the /data/coolify directory setup of the install script against a temporary data root.
* chown is replaced with a logger because changing the owner to UID 9999 needs root.
*
* @param bool $completeRun false runs only the setup before step 1, as when a check or download fails
* @return list<string> the paths that chown received
*/
function runInstallScriptDirectorySetup(string $scriptPath, string $dataRoot): array
function runInstallScriptDirectorySetup(string $scriptPath, string $dataRoot, bool $completeRun = true): array
{
$script = file_get_contents(dirname(__DIR__, 2).'/'.$scriptPath);
preg_match('/^# Resource directories.*?^set_coolify_directory_permissions$/ms', $script, $matches);
preg_match('/^# Resource directories.*?^mkdir -p \/data\/coolify\/source$/ms', $script, $matches);
expect($matches)->not->toBeEmpty();
$setup = str_replace('/data/coolify', $dataRoot, $matches[0]);
$setup = $matches[0];
if ($completeRun) {
$setup .= "\ncreate_coolify_directories\nset_coolify_directory_permissions";
}
$setup = str_replace('/data/coolify', $dataRoot, $setup);
$chownLog = "{$dataRoot}.chown";
touch($chownLog);
$process = proc_open(
['bash', '-c', "set -e\nchown() { printf '%s\\n' \"\$@\" >> ".escapeshellarg($chownLog)."; }\n{$setup}"],
[1 => ['pipe', 'w'], 2 => ['pipe', 'w']],
@@ -95,11 +101,42 @@ it('keeps existing resource directories and their content unchanged on an upgrad
}
})->with($installScripts);
it('does not change the whole data directory recursively', function (string $scriptPath) {
it('does not change an existing data directory before the checks and downloads succeed', function (string $scriptPath, array $coolifyDirectories) {
$dataRoot = sys_get_temp_dir().'/coolify-install-permissions-'.bin2hex(random_bytes(6));
try {
mkdir($dataRoot, 0750);
chmod($dataRoot, 0750);
foreach ($coolifyDirectories as $directory) {
mkdir("{$dataRoot}/{$directory}/nested", 0755, true);
chmod("{$dataRoot}/{$directory}", 0750);
touch("{$dataRoot}/{$directory}/nested/file");
chmod("{$dataRoot}/{$directory}/nested/file", 0644);
}
$chownedPaths = runInstallScriptDirectorySetup($scriptPath, $dataRoot, completeRun: false);
expect($chownedPaths)->toBe([])
->and(installScriptFileMode($dataRoot))->toBe('0750');
foreach ($coolifyDirectories as $directory) {
expect(installScriptFileMode("{$dataRoot}/{$directory}"))->toBe('0750')
->and(installScriptFileMode("{$dataRoot}/{$directory}/nested"))->toBe('0755')
->and(installScriptFileMode("{$dataRoot}/{$directory}/nested/file"))->toBe('0644');
}
} finally {
exec('rm -rf '.escapeshellarg($dataRoot));
}
})->with($installScripts);
it('changes the data directories only after the checks and downloads', function (string $scriptPath) {
$script = file_get_contents(dirname(__DIR__, 2).'/'.$scriptPath);
$downloadStep = strpos($script, 'step_start "Downloading required files from CDN"');
expect($script)
->not->toContain("chown -R 9999:root /data/coolify\n")
->not->toContain("chmod -R 700 /data/coolify\n")
->and(substr_count($script, "\nset_coolify_directory_permissions\n"))->toBe(2);
->and(substr_count($script, "\ncreate_coolify_directories\n"))->toBe(1)
->and(substr_count($script, "\nset_coolify_directory_permissions\n"))->toBe(1)
->and(strpos($script, "\ncreate_coolify_directories\n"))->toBeGreaterThan($downloadStep)
->and(strpos($script, "\nset_coolify_directory_permissions\n"))->toBeGreaterThan($downloadStep);
})->with(array_map(fn (array $script) => $script[0], $installScripts));