An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
<?php
use Symfony\Component\Process\Process;
it('removes only previous Coolify keys from authorized_keys', function (string $path) {
$script = file_get_contents(dirname(__DIR__, 2).'/'.$path);
preg_match('/^\s*(sed -i .*~\/\.ssh\/authorized_keys)$/m', $script, $matches);
expect($matches)->toHaveKey(1);
$home = sys_get_temp_dir().'/coolify-install-keys-'.bin2hex(random_bytes(4));
mkdir($home.'/.ssh', 0700, true);
file_put_contents($home.'/.ssh/authorized_keys', implode("\n", [
'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOperatorKey coolify-disposable',
'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOperatorKey operator-lab',
'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOperatorKey me@coolify-laptop',
'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOperatorKey coolify-ops key',
'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOperatorKey admin@[email protected]',
'no-pty ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOptions [email protected]',
'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOldCoolifyKey coolify',
// Installers before September 2024 generated their key with the comment "root@coolify".
'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOlderCoolifyKey root@coolify',
'',
]));
$process = new Process(['bash', '-c', $matches[1]], null, ['HOME' => $home]);
$process->mustRun();
expect(file_get_contents($home.'/.ssh/authorized_keys'))->toBe(implode("\n", [
'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOperatorKey coolify-disposable',
'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOperatorKey operator-lab',
'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOperatorKey me@coolify-laptop',
'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOperatorKey coolify-ops key',
'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOperatorKey admin@[email protected]',
'no-pty ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOptions [email protected]',
'',
]));
exec('rm -rf '.escapeshellarg($home));
})->with([
'stable install script' => ['scripts/install.sh'],
'nightly install script' => ['other/nightly/install.sh'],
]);