commit
a50e1e2f0c
@ -6,11 +6,13 @@ use App\Enums\ProxyStatus;
|
|||||||
use App\Enums\ProxyTypes;
|
use App\Enums\ProxyTypes;
|
||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
use Lorisleiva\Actions\Concerns\AsAction;
|
||||||
use Spatie\Activitylog\Models\Activity;
|
use Spatie\Activitylog\Models\Activity;
|
||||||
|
|
||||||
class StartProxy
|
class StartProxy
|
||||||
{
|
{
|
||||||
public function __invoke(Server $server, bool $async = true): Activity|string
|
use AsAction;
|
||||||
|
public function handle(Server $server, bool $async = true): Activity|string
|
||||||
{
|
{
|
||||||
$proxyType = data_get($server,'proxy.type');
|
$proxyType = data_get($server,'proxy.type');
|
||||||
if ($proxyType === 'none') {
|
if ($proxyType === 'none') {
|
||||||
|
@ -39,6 +39,10 @@ class Index extends Component
|
|||||||
public ?Project $createdProject = null;
|
public ?Project $createdProject = null;
|
||||||
|
|
||||||
public bool $dockerInstallationStarted = false;
|
public bool $dockerInstallationStarted = false;
|
||||||
|
|
||||||
|
public string $localhostPublicKey;
|
||||||
|
public bool $localhostReachable = true;
|
||||||
|
|
||||||
public function mount()
|
public function mount()
|
||||||
{
|
{
|
||||||
$this->privateKeyName = generate_random_name();
|
$this->privateKeyName = generate_random_name();
|
||||||
@ -94,6 +98,7 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA==
|
|||||||
if (!$this->createdServer) {
|
if (!$this->createdServer) {
|
||||||
return $this->emit('error', 'Localhost server is not found. Something went wrong during installation. Please try to reinstall or contact support.');
|
return $this->emit('error', 'Localhost server is not found. Something went wrong during installation. Please try to reinstall or contact support.');
|
||||||
}
|
}
|
||||||
|
$this->localhostPublicKey = $this->createdServer->privateKey->publicKey();
|
||||||
return $this->validateServer('localhost');
|
return $this->validateServer('localhost');
|
||||||
} elseif ($this->selectedServerType === 'remote') {
|
} elseif ($this->selectedServerType === 'remote') {
|
||||||
$this->privateKeys = PrivateKey::ownedByCurrentTeam(['name'])->where('id', '!=', 0)->get();
|
$this->privateKeys = PrivateKey::ownedByCurrentTeam(['name'])->where('id', '!=', 0)->get();
|
||||||
@ -188,7 +193,7 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA==
|
|||||||
$this->createdServer->save();
|
$this->createdServer->save();
|
||||||
$this->validateServer();
|
$this->validateServer();
|
||||||
}
|
}
|
||||||
public function validateServer(?string $type = null)
|
public function validateServer()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$customErrorMessage = "Server is not reachable:";
|
$customErrorMessage = "Server is not reachable:";
|
||||||
@ -199,7 +204,12 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA==
|
|||||||
$this->createdServer->settings->update([
|
$this->createdServer->settings->update([
|
||||||
'is_reachable' => true,
|
'is_reachable' => true,
|
||||||
]);
|
]);
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
$this->localhostReachable = false;
|
||||||
|
return handleError(error: $e, customErrorMessage: $customErrorMessage, livewire: $this);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
$dockerVersion = instant_remote_process(["docker version|head -2|grep -i version| awk '{print $2}'"], $this->createdServer, true);
|
$dockerVersion = instant_remote_process(["docker version|head -2|grep -i version| awk '{print $2}'"], $this->createdServer, true);
|
||||||
$dockerVersion = checkMinimumDockerEngineVersion($dockerVersion);
|
$dockerVersion = checkMinimumDockerEngineVersion($dockerVersion);
|
||||||
if (is_null($dockerVersion)) {
|
if (is_null($dockerVersion)) {
|
||||||
|
@ -68,10 +68,11 @@ class Heading extends Component
|
|||||||
["docker rm -f {$containerName}"],
|
["docker rm -f {$containerName}"],
|
||||||
$this->application->destination->server
|
$this->application->destination->server
|
||||||
);
|
);
|
||||||
$this->application->status = 'stopped';
|
$this->application->status = 'exited';
|
||||||
$this->application->save();
|
$this->application->save();
|
||||||
// $this->application->environment->project->team->notify(new StatusChanged($this->application));
|
// $this->application->environment->project->team->notify(new StatusChanged($this->application));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$this->application->refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ class Heading extends Component
|
|||||||
stopPostgresProxy($this->database);
|
stopPostgresProxy($this->database);
|
||||||
$this->database->is_public = false;
|
$this->database->is_public = false;
|
||||||
}
|
}
|
||||||
$this->database->status = 'stopped';
|
$this->database->status = 'exited';
|
||||||
$this->database->save();
|
$this->database->save();
|
||||||
$this->check_status();
|
$this->check_status();
|
||||||
// $this->database->environment->project->team->notify(new StatusChanged($this->database));
|
// $this->database->environment->project->team->notify(new StatusChanged($this->database));
|
||||||
|
@ -27,7 +27,7 @@ class Deploy extends Component
|
|||||||
SaveConfiguration::run($this->server);
|
SaveConfiguration::run($this->server);
|
||||||
}
|
}
|
||||||
|
|
||||||
$activity = resolve(StartProxy::class)($this->server);
|
$activity = StartProxy::run($this->server);
|
||||||
$this->emit('newMonitorActivity', $activity->id);
|
$this->emit('newMonitorActivity', $activity->id);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
return handleError($e);
|
return handleError($e);
|
||||||
|
@ -89,7 +89,7 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
|
|||||||
$this->is_debug_enabled = $this->application->settings->is_debug_enabled;
|
$this->is_debug_enabled = $this->application->settings->is_debug_enabled;
|
||||||
|
|
||||||
$this->container_name = generateApplicationContainerName($this->application->uuid, $this->pull_request_id);
|
$this->container_name = generateApplicationContainerName($this->application->uuid, $this->pull_request_id);
|
||||||
addPrivateKeyToSshAgent($this->server);
|
savePrivateKeyToFs($this->server);
|
||||||
$this->saved_outputs = collect();
|
$this->saved_outputs = collect();
|
||||||
|
|
||||||
// Set preview fqdn
|
// Set preview fqdn
|
||||||
|
@ -82,7 +82,7 @@ class ContainerStatusJob implements ShouldQueue, ShouldBeEncrypted
|
|||||||
})->first();
|
})->first();
|
||||||
if (!$foundProxyContainer) {
|
if (!$foundProxyContainer) {
|
||||||
if ($this->server->isProxyShouldRun()) {
|
if ($this->server->isProxyShouldRun()) {
|
||||||
resolve(StartProxy::class)($this->server, false);
|
StartProxy::run($this->server, false);
|
||||||
$this->server->team->notify(new ContainerRestarted('coolify-proxy', $this->server));
|
$this->server->team->notify(new ContainerRestarted('coolify-proxy', $this->server));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -53,7 +53,7 @@ function remote_process(
|
|||||||
// }
|
// }
|
||||||
// // processWithEnv()->run("echo '{$server->privateKey->private_key}' | ssh-add -d -");
|
// // processWithEnv()->run("echo '{$server->privateKey->private_key}' | ssh-add -d -");
|
||||||
// }
|
// }
|
||||||
function addPrivateKeyToSshAgent(Server $server)
|
function savePrivateKeyToFs(Server $server)
|
||||||
{
|
{
|
||||||
if (data_get($server, 'privateKey.private_key') === null) {
|
if (data_get($server, 'privateKey.private_key') === null) {
|
||||||
throw new \Exception("Server {$server->name} does not have a private key");
|
throw new \Exception("Server {$server->name} does not have a private key");
|
||||||
@ -70,7 +70,7 @@ function generateSshCommand(Server $server, string $command, bool $isMux = true)
|
|||||||
{
|
{
|
||||||
$user = $server->user;
|
$user = $server->user;
|
||||||
$port = $server->port;
|
$port = $server->port;
|
||||||
$privateKeyLocation = addPrivateKeyToSshAgent($server);
|
$privateKeyLocation = savePrivateKeyToFs($server);
|
||||||
$timeout = config('constants.ssh.command_timeout');
|
$timeout = config('constants.ssh.command_timeout');
|
||||||
$connectionTimeout = config('constants.ssh.connection_timeout');
|
$connectionTimeout = config('constants.ssh.connection_timeout');
|
||||||
$serverInterval = config('constants.ssh.server_interval');
|
$serverInterval = config('constants.ssh.server_interval');
|
||||||
|
@ -7,7 +7,7 @@ return [
|
|||||||
|
|
||||||
// The release version of your application
|
// The release version of your application
|
||||||
// Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD'))
|
// Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD'))
|
||||||
'release' => '4.0.0-beta.41',
|
'release' => '4.0.0-beta.42',
|
||||||
// When left empty or `null` the Laravel environment will be used
|
// When left empty or `null` the Laravel environment will be used
|
||||||
'environment' => config('app.env'),
|
'environment' => config('app.env'),
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ return [
|
|||||||
*
|
*
|
||||||
* Minimum: 3000 (in milliseconds)
|
* Minimum: 3000 (in milliseconds)
|
||||||
*/
|
*/
|
||||||
'duration' => 1500,
|
'duration' => 3000,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The horizontal position of each toast.
|
* The horizontal position of each toast.
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
return '4.0.0-beta.41';
|
return '4.0.0-beta.42';
|
||||||
|
@ -46,9 +46,21 @@
|
|||||||
<x-forms.button class="justify-center box" wire:target="setServerType('localhost')"
|
<x-forms.button class="justify-center box" wire:target="setServerType('localhost')"
|
||||||
wire:click="setServerType('localhost')">Localhost
|
wire:click="setServerType('localhost')">Localhost
|
||||||
</x-forms.button>
|
</x-forms.button>
|
||||||
|
|
||||||
<x-forms.button class="justify-center box" wire:target="setServerType('remote')"
|
<x-forms.button class="justify-center box" wire:target="setServerType('remote')"
|
||||||
wire:click="setServerType('remote')">Remote Server
|
wire:click="setServerType('remote')">Remote Server
|
||||||
</x-forms.button>
|
</x-forms.button>
|
||||||
|
@if (!$localhostReachable)
|
||||||
|
Localhost is not reachable with the following public key.
|
||||||
|
<br /> <br />
|
||||||
|
Please make sure you have the correct public key in your ~/.ssh/authorized_keys file for user
|
||||||
|
'root' or skip the boarding process and add a new private key manually to Coolify and to the
|
||||||
|
server.
|
||||||
|
<x-forms.input readonly id="localhostPublicKey"></x-forms.input>
|
||||||
|
<x-forms.button class="box" wire:target="setServerType('localhost')"
|
||||||
|
wire:click="setServerType('localhost')">Check again
|
||||||
|
</x-forms.button>
|
||||||
|
@endif
|
||||||
</x-slot:actions>
|
</x-slot:actions>
|
||||||
<x-slot:explanation>
|
<x-slot:explanation>
|
||||||
<p>Servers are the main building blocks, as they will host your applications, databases,
|
<p>Servers are the main building blocks, as they will host your applications, databases,
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
"version": "3.12.36"
|
"version": "3.12.36"
|
||||||
},
|
},
|
||||||
"v4": {
|
"v4": {
|
||||||
"version": "4.0.0-beta.41"
|
"version": "4.0.0-beta.42"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user