Merge pull request #3406 from coollabsio/next

v4.0.0-beta.335
This commit is contained in:
Andras Bacsai
2024-09-12 12:43:32 +02:00
committed by GitHub
14 changed files with 54 additions and 29 deletions

View File

@@ -6,7 +6,7 @@ APP_KEY=
APP_URL=http://localhost
APP_PORT=8000
APP_DEBUG=true
MUX_ENABLED=false
SSH_MUX_ENABLED=false
# PostgreSQL Database Configuration
DB_DATABASE=coolify

View File

@@ -282,7 +282,7 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA==
public function validateServer()
{
try {
config()->set('coolify.mux_enabled', false);
config()->set('constants.ssh.mux_enabled', false);
// EC2 does not have `uptime` command, lol
instant_remote_process(['ls /'], $this->createdServer, true);

View File

@@ -24,7 +24,11 @@ class Form extends Component
public $timezones;
protected $listeners = ['serverInstalled', 'revalidate' => '$refresh'];
protected $listeners = [
'serverInstalled',
'refreshServerShow' => 'serverInstalled',
'revalidate' => '$refresh',
];
protected $rules = [
'server.name' => 'required',

View File

@@ -2,10 +2,10 @@
namespace App\Livewire\Server\New;
use App\Enums\ProxyStatus;
use App\Enums\ProxyTypes;
use App\Models\Server;
use App\Models\Team;
use Illuminate\Support\Collection;
use Livewire\Component;
class ByIp extends Component
@@ -40,7 +40,7 @@ class ByIp extends Component
public bool $is_build_server = false;
public $swarm_managers = [];
public Collection $swarm_managers;
protected $rules = [
'name' => 'required|string',
@@ -102,11 +102,6 @@ class ByIp extends Component
'port' => $this->port,
'team_id' => currentTeam()->id,
'private_key_id' => $this->private_key_id,
'proxy' => [
// set default proxy type to traefik v2
'type' => ProxyTypes::TRAEFIK->value,
'status' => ProxyStatus::EXITED->value,
],
];
if ($this->is_swarm_worker) {
$payload['swarm_cluster'] = $this->selected_swarm_cluster;
@@ -115,6 +110,9 @@ class ByIp extends Component
data_forget($payload, 'proxy');
}
$server = Server::create($payload);
$server->proxy->set('status', 'exited');
$server->proxy->set('type', ProxyTypes::TRAEFIK->value);
$server->save();
if ($this->is_build_server) {
$this->is_swarm_manager = false;
$this->is_swarm_worker = false;

View File

@@ -14,7 +14,7 @@ class Show extends Component
public $parameters = [];
protected $listeners = ['refreshServerShow' => '$refresh'];
protected $listeners = ['refreshServerShow'];
public function mount()
{
@@ -29,6 +29,12 @@ class Show extends Component
}
}
public function refreshServerShow()
{
$this->server->refresh();
$this->dispatch('$refresh');
}
public function submit()
{
$this->dispatch('serverRefresh', false);

View File

@@ -967,7 +967,7 @@ $schema://$host {
public function validateConnection()
{
config()->set('coolify.mux_enabled', false);
config()->set('constants.ssh.mux_enabled', false);
$server = Server::find($this->id);
if (! $server) {

View File

@@ -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])) {

View File

@@ -6,7 +6,8 @@ return [
'contact' => 'https://coolify.io/docs/contact',
],
'ssh' => [
'mux_enabled' => env('SSH_MUX_ENABLED', true),
// Using MUX
'mux_enabled' => env('MUX_ENABLED', env('SSH_MUX_ENABLED', true), true),
'mux_persist_time' => env('SSH_MUX_PERSIST_TIME', '1h'),
'connection_timeout' => 10,
'server_interval' => 20,

View File

@@ -7,7 +7,6 @@ return [
'self_hosted' => env('SELF_HOSTED', true),
'waitlist' => env('WAITLIST', false),
'license_url' => 'https://licenses.coollabs.io',
'mux_enabled' => env('MUX_ENABLED', true),
'dev_webhook' => env('SERVEO_URL'),
'is_windows_docker_desktop' => env('IS_WINDOWS_DOCKER_DESKTOP', false),
'base_config_path' => env('BASE_CONFIG_PATH', '/data/coolify'),

View File

@@ -7,7 +7,7 @@ return [
// The release version of your application
// Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD'))
'release' => '4.0.0-beta.334',
'release' => '4.0.0-beta.335',
// When left empty or `null` the Laravel environment will be used
'environment' => config('app.env'),

View File

@@ -1,3 +1,3 @@
<?php
return '4.0.0-beta.334';
return '4.0.0-beta.335';

View File

@@ -48,6 +48,7 @@ services:
- PUSHER_APP_SECRET
- AUTOUPDATE
- SELF_HOSTED
- SSH_MUX_ENABLED
- SSH_MUX_PERSIST_TIME
- FEEDBACK_DISCORD_WEBHOOK
- WAITLIST

View File

@@ -45,7 +45,7 @@ services:
- PUSHER_APP_SECRET
- AUTOUPDATE=true
- SELF_HOSTED=true
- MUX_ENABLED=false
- SSH_MUX_ENABLED=false
- IS_WINDOWS_DOCKER_DESKTOP=true
ports:
- "${APP_PORT:-8000}:80"

View File

@@ -1,13 +1,13 @@
{
"coolify": {
"v4": {
"version": "4.0.0-beta.334"
"version": "4.0.0-beta.335"
},
"nightly": {
"version": "4.0.0-beta.335"
"version": "4.0.0-beta.336"
},
"helper": {
"version": "1.0.1"
}
}
}
}