Merge branch 'next' into feat--terminal-pty
This commit is contained in:
@@ -98,12 +98,10 @@ function generateScpCommand(Server $server, string $source, string $dest)
|
||||
$muxPersistTime = config('constants.ssh.mux_persist_time');
|
||||
|
||||
$scp_command = "timeout $timeout scp ";
|
||||
// Check if multiplexing is enabled
|
||||
$muxEnabled = config('constants.ssh.mux_enabled', true);
|
||||
$muxEnabled = config('constants.ssh.mux_enabled', true) && config('coolify.is_windows_docker_desktop') == false;
|
||||
// ray('SSH Multiplexing Enabled:', $muxEnabled)->blue();
|
||||
|
||||
if ($muxEnabled) {
|
||||
// Always use multiplexing when enabled
|
||||
$muxSocket = "/var/www/html/storage/app/ssh/mux/{$server->muxFilename()}";
|
||||
$scp_command .= "-o ControlMaster=auto -o ControlPath=$muxSocket -o ControlPersist={$muxPersistTime} ";
|
||||
ensureMultiplexedConnection($server);
|
||||
@@ -163,10 +161,8 @@ function generateSshCommand(Server $server, string $command)
|
||||
|
||||
$ssh_command = "timeout $timeout ssh ";
|
||||
|
||||
// Check if multiplexing is enabled
|
||||
$muxEnabled = config('constants.ssh.mux_enabled', true);
|
||||
$muxEnabled = config('constants.ssh.mux_enabled') && config('coolify.is_windows_docker_desktop') == false;
|
||||
// ray('SSH Multiplexing Enabled:', $muxEnabled)->blue();
|
||||
|
||||
if ($muxEnabled) {
|
||||
// Always use multiplexing when enabled
|
||||
$muxSocket = "/var/www/html/storage/app/ssh/mux/{$server->muxFilename()}";
|
||||
@@ -201,6 +197,10 @@ function generateSshCommand(Server $server, string $command)
|
||||
|
||||
function ensureMultiplexedConnection(Server $server)
|
||||
{
|
||||
if (! (config('constants.ssh.mux_enabled') && config('coolify.is_windows_docker_desktop') == false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
static $ensuredConnections = [];
|
||||
|
||||
if (isset($ensuredConnections[$server->id])) {
|
||||
@@ -212,7 +212,11 @@ function ensureMultiplexedConnection(Server $server)
|
||||
}
|
||||
|
||||
$muxSocket = "/var/www/html/storage/app/ssh/mux/{$server->muxFilename()}";
|
||||
$checkCommand = "ssh -O check -o ControlPath=$muxSocket {$server->user}@{$server->ip} 2>/dev/null";
|
||||
$checkCommand = "ssh -O check -o ControlPath=$muxSocket ";
|
||||
if (data_get($server, 'settings.is_cloudflare_tunnel')) {
|
||||
$checkCommand .= '-o ProxyCommand="/usr/local/bin/cloudflared access ssh --hostname %h" ';
|
||||
}
|
||||
$checkCommand .= " {$server->user}@{$server->ip}";
|
||||
|
||||
$process = Process::run($checkCommand);
|
||||
|
||||
@@ -233,8 +237,12 @@ function ensureMultiplexedConnection(Server $server)
|
||||
$serverInterval = config('constants.ssh.server_interval');
|
||||
$muxPersistTime = config('constants.ssh.mux_persist_time');
|
||||
|
||||
$establishCommand = "ssh -fNM -o ControlMaster=auto -o ControlPath=$muxSocket -o ControlPersist={$muxPersistTime} "
|
||||
."-i {$privateKeyLocation} "
|
||||
$establishCommand = "ssh -fNM -o ControlMaster=auto -o ControlPath=$muxSocket -o ControlPersist={$muxPersistTime} ";
|
||||
|
||||
if (data_get($server, 'settings.is_cloudflare_tunnel')) {
|
||||
$establishCommand .= '-o ProxyCommand="/usr/local/bin/cloudflared access ssh --hostname %h" ';
|
||||
}
|
||||
$establishCommand .= "-i {$privateKeyLocation} "
|
||||
.'-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null '
|
||||
.'-o PasswordAuthentication=no '
|
||||
."-o ConnectTimeout=$connectionTimeout "
|
||||
@@ -260,6 +268,10 @@ function ensureMultiplexedConnection(Server $server)
|
||||
|
||||
function shouldResetMultiplexedConnection(Server $server)
|
||||
{
|
||||
if (! (config('constants.ssh.mux_enabled') && config('coolify.is_windows_docker_desktop') == false)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
static $ensuredConnections = [];
|
||||
|
||||
if (! isset($ensuredConnections[$server->id])) {
|
||||
@@ -275,6 +287,10 @@ function shouldResetMultiplexedConnection(Server $server)
|
||||
|
||||
function resetMultiplexedConnection(Server $server)
|
||||
{
|
||||
if (! (config('constants.ssh.mux_enabled') && config('coolify.is_windows_docker_desktop') == false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
static $ensuredConnections = [];
|
||||
|
||||
if (isset($ensuredConnections[$server->id])) {
|
||||
|
||||
@@ -786,7 +786,7 @@ function replaceLocalSource(Stringable $source, Stringable $replacedWith)
|
||||
if ($source->startsWith('..')) {
|
||||
$source = $source->replaceFirst('..', $replacedWith->value());
|
||||
}
|
||||
if ($source->endsWith('/')) {
|
||||
if ($source->endsWith('/') && $source->value() !== '/') {
|
||||
$source = $source->replaceLast('/', '');
|
||||
}
|
||||
|
||||
@@ -2100,16 +2100,16 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal
|
||||
|
||||
// TODO: move this in a shared function
|
||||
if (! $parsedServiceVariables->has('COOLIFY_APP_NAME')) {
|
||||
$parsedServiceVariables->put('COOLIFY_APP_NAME', $resource->name);
|
||||
$parsedServiceVariables->put('COOLIFY_APP_NAME', "\"{$resource->name}\"");
|
||||
}
|
||||
if (! $parsedServiceVariables->has('COOLIFY_SERVER_IP')) {
|
||||
$parsedServiceVariables->put('COOLIFY_SERVER_IP', $resource->destination->server->ip);
|
||||
$parsedServiceVariables->put('COOLIFY_SERVER_IP', "\"{$resource->destination->server->ip}\"");
|
||||
}
|
||||
if (! $parsedServiceVariables->has('COOLIFY_ENVIRONMENT_NAME')) {
|
||||
$parsedServiceVariables->put('COOLIFY_ENVIRONMENT_NAME', $resource->environment->name);
|
||||
$parsedServiceVariables->put('COOLIFY_ENVIRONMENT_NAME', "\"{$resource->environment->name}\"");
|
||||
}
|
||||
if (! $parsedServiceVariables->has('COOLIFY_PROJECT_NAME')) {
|
||||
$parsedServiceVariables->put('COOLIFY_PROJECT_NAME', $resource->project()->name);
|
||||
$parsedServiceVariables->put('COOLIFY_PROJECT_NAME', "\"{$resource->project()->name}\"");
|
||||
}
|
||||
|
||||
$parsedServiceVariables = $parsedServiceVariables->map(function ($value, $key) use ($envs_from_coolify) {
|
||||
@@ -3229,7 +3229,6 @@ function newParser(Application|Service $resource, int $pull_request_id = 0, ?int
|
||||
if ($isApplication && $isPullRequest) {
|
||||
$source = $source."-pr-$pullRequestId";
|
||||
}
|
||||
|
||||
LocalFileVolume::updateOrCreate(
|
||||
[
|
||||
'mount_path' => $target,
|
||||
@@ -3469,13 +3468,13 @@ function newParser(Application|Service $resource, int $pull_request_id = 0, ?int
|
||||
$branch = "pull/{$pullRequestId}/head";
|
||||
}
|
||||
if ($originalResource->environment_variables->where('key', 'COOLIFY_BRANCH')->isEmpty()) {
|
||||
$coolifyEnvironments->put('COOLIFY_BRANCH', $branch);
|
||||
$coolifyEnvironments->put('COOLIFY_BRANCH', "\"{$branch}\"");
|
||||
}
|
||||
}
|
||||
|
||||
// Add COOLIFY_CONTAINER_NAME to environment
|
||||
if ($resource->environment_variables->where('key', 'COOLIFY_CONTAINER_NAME')->isEmpty()) {
|
||||
$coolifyEnvironments->put('COOLIFY_CONTAINER_NAME', $containerName);
|
||||
$coolifyEnvironments->put('COOLIFY_CONTAINER_NAME', "\"{$containerName}\"");
|
||||
}
|
||||
|
||||
if ($isApplication) {
|
||||
@@ -3548,7 +3547,7 @@ function newParser(Application|Service $resource, int $pull_request_id = 0, ?int
|
||||
if ($isApplication) {
|
||||
$shouldGenerateLabelsExactly = $resource->destination->server->settings->generate_exact_labels;
|
||||
$uuid = $resource->uuid;
|
||||
$network = $resource->destination->network;
|
||||
$network = data_get($resource, 'destination.network');
|
||||
if ($isPullRequest) {
|
||||
$uuid = "{$resource->uuid}-{$pullRequestId}";
|
||||
}
|
||||
@@ -3558,7 +3557,7 @@ function newParser(Application|Service $resource, int $pull_request_id = 0, ?int
|
||||
} else {
|
||||
$shouldGenerateLabelsExactly = $resource->server->settings->generate_exact_labels;
|
||||
$uuid = $resource->uuid;
|
||||
$network = $resource->destination->network;
|
||||
$network = data_get($resource, 'destination.network');
|
||||
}
|
||||
if ($shouldGenerateLabelsExactly) {
|
||||
switch ($server->proxyType()) {
|
||||
@@ -3723,30 +3722,30 @@ function add_coolify_default_environment_variables(StandaloneRedis|StandalonePos
|
||||
}
|
||||
if ($where_to_check != null && $where_to_check->where('key', 'COOLIFY_APP_NAME')->isEmpty()) {
|
||||
if ($isAssociativeArray) {
|
||||
$where_to_add->put('COOLIFY_APP_NAME', $resource->name);
|
||||
$where_to_add->put('COOLIFY_APP_NAME', "\"{$resource->name}\"");
|
||||
} else {
|
||||
$where_to_add->push("COOLIFY_APP_NAME={$resource->name}");
|
||||
$where_to_add->push("COOLIFY_APP_NAME=\"{$resource->name}\"");
|
||||
}
|
||||
}
|
||||
if ($where_to_check != null && $where_to_check->where('key', 'COOLIFY_SERVER_IP')->isEmpty()) {
|
||||
if ($isAssociativeArray) {
|
||||
$where_to_add->put('COOLIFY_SERVER_IP', $ip);
|
||||
$where_to_add->put('COOLIFY_SERVER_IP', "\"{$ip}\"");
|
||||
} else {
|
||||
$where_to_add->push("COOLIFY_SERVER_IP={$ip}");
|
||||
$where_to_add->push("COOLIFY_SERVER_IP=\"{$ip}\"");
|
||||
}
|
||||
}
|
||||
if ($where_to_check != null && $where_to_check->where('key', 'COOLIFY_ENVIRONMENT_NAME')->isEmpty()) {
|
||||
if ($isAssociativeArray) {
|
||||
$where_to_add->put('COOLIFY_ENVIRONMENT_NAME', $resource->environment->name);
|
||||
$where_to_add->put('COOLIFY_ENVIRONMENT_NAME', "\"{$resource->environment->name}\"");
|
||||
} else {
|
||||
$where_to_add->push("COOLIFY_ENVIRONMENT_NAME={$resource->environment->name}");
|
||||
$where_to_add->push("COOLIFY_ENVIRONMENT_NAME=\"{$resource->environment->name}\"");
|
||||
}
|
||||
}
|
||||
if ($where_to_check != null && $where_to_check->where('key', 'COOLIFY_PROJECT_NAME')->isEmpty()) {
|
||||
if ($isAssociativeArray) {
|
||||
$where_to_add->put('COOLIFY_PROJECT_NAME', $resource->project()->name);
|
||||
$where_to_add->put('COOLIFY_PROJECT_NAME', "\"{$resource->project()->name}\"");
|
||||
} else {
|
||||
$where_to_add->push("COOLIFY_PROJECT_NAME={$resource->project()->name}");
|
||||
$where_to_add->push("COOLIFY_PROJECT_NAME=\"{$resource->project()->name}\"");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user