This commit is contained in:
Andras Bacsai
2023-05-25 12:00:09 +02:00
parent 5a1a33242c
commit f766600fd8
41 changed files with 151 additions and 79 deletions

View File

@@ -7,6 +7,9 @@ if (!function_exists('getProxyConfiguration')) {
function getProxyConfiguration(Server $server)
{
$proxy_path = config('coolify.proxy_config_path');
if (config('app.env') === 'local') {
$proxy_path = $proxy_path . '/testing-host-1/';
}
$networks = collect($server->standaloneDockers)->map(function ($docker) {
return $docker['network'];
})->unique();

View File

@@ -46,19 +46,20 @@ function remote_process(
function save_private_key_for_server(Server $server)
{
$temp_file = "id.root@{$server->ip}";
Storage::disk('ssh-keys')->put($temp_file, $server->privateKey->private_key);
return '/var/www/html/storage/app/ssh-keys/' . $temp_file;
LocalStorage::ssh_keys()->put($temp_file, $server->privateKey->private_key);
return '/var/www/html/storage/app/private/ssh/keys/' . $temp_file;
}
function generate_ssh_command(string $private_key_location, string $server_ip, string $user, string $port, string $command, bool $isMux = true)
{
Storage::disk('local')->makeDirectory('.ssh');
LocalStorage::ssh_keys();
LocalStorage::ssh_mux();
$delimiter = 'EOF-COOLIFY-SSH';
$ssh_command = "ssh ";
if ($isMux && config('coolify.mux_enabled')) {
$ssh_command .= '-o ControlMaster=auto -o ControlPersist=1m -o ControlPath=/var/www/html/storage/app/.ssh/ssh_mux_%h_%p_%r ';
$ssh_command .= '-o ControlMaster=auto -o ControlPersist=1m -o ControlPath=/var/www/html/storage/app/private/ssh/mux/%h_%p_%r ';
}
$ssh_command .= "-i {$private_key_location} "
. '-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null '
@@ -85,6 +86,7 @@ function instant_remote_process(array $command, Server $server, $throwError = tr
$output = trim($process->output());
$exitCode = $process->exitCode();
if ($exitCode !== 0) {
Log::info($process->errorOutput());
if (!$throwError) {
return null;
}

View File

@@ -0,0 +1,38 @@
<?php
use Illuminate\Support\Facades\Facade;
use Illuminate\Support\Facades\Storage;
class LocalStorage extends Facade
{
public static function deployments()
{
$storage = Storage::build([
'driver' => 'local',
'root' => storage_path("app/private/deployments"),
'visibility' => 'private',
]);
$storage->makeDirectory('.');
return $storage;
}
public static function ssh_keys()
{
$storage = Storage::build([
'driver' => 'local',
'root' => storage_path("app/private/ssh/keys"),
'visibility' => 'private'
]);
$storage->makeDirectory('.');
return $storage;
}
public static function ssh_mux()
{
$storage = Storage::build([
'driver' => 'local',
'root' => storage_path("app/private/ssh/mux"),
'visibility' => 'private',
]);
$storage->makeDirectory('.');
return $storage;
}
}