wip: backup existing database
This commit is contained in:
parent
f6f4cdde24
commit
1338e68b8c
@ -22,34 +22,52 @@ class Select extends Component
|
|||||||
public Collection|array $swarmDockers = [];
|
public Collection|array $swarmDockers = [];
|
||||||
public array $parameters;
|
public array $parameters;
|
||||||
|
|
||||||
|
public ?string $existingPostgresqlUrl = null;
|
||||||
|
|
||||||
protected $queryString = [
|
protected $queryString = [
|
||||||
'server',
|
'server',
|
||||||
];
|
];
|
||||||
public function mount()
|
public function mount()
|
||||||
{
|
{
|
||||||
$this->parameters = get_route_parameters();
|
$this->parameters = get_route_parameters();
|
||||||
|
if (isDev()) {
|
||||||
|
$this->existingPostgresqlUrl = 'postgres://coolify:password@coolify-db:5432';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function set_type(string $type)
|
// public function addExistingPostgresql()
|
||||||
|
// {
|
||||||
|
// try {
|
||||||
|
// instantCommand("psql {$this->existingPostgresqlUrl} -c 'SELECT 1'");
|
||||||
|
// $this->emit('success', 'Successfully connected to the database.');
|
||||||
|
// } catch (\Exception $e) {
|
||||||
|
// return general_error_handler($e, $this);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
public function setType(string $type)
|
||||||
{
|
{
|
||||||
$this->type = $type;
|
$this->type = $type;
|
||||||
|
if ($type === "existing-postgresql") {
|
||||||
|
$this->current_step = $type;
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (count($this->servers) === 1) {
|
if (count($this->servers) === 1) {
|
||||||
$server = $this->servers->first();
|
$server = $this->servers->first();
|
||||||
$this->set_server($server);
|
$this->setServer($server);
|
||||||
if (count($server->destinations()) === 1) {
|
if (count($server->destinations()) === 1) {
|
||||||
$this->set_destination($server->destinations()->first()->uuid);
|
$this->setDestination($server->destinations()->first()->uuid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!is_null($this->server)) {
|
if (!is_null($this->server)) {
|
||||||
$foundServer = $this->servers->where('id', $this->server)->first();
|
$foundServer = $this->servers->where('id', $this->server)->first();
|
||||||
if ($foundServer) {
|
if ($foundServer) {
|
||||||
return $this->set_server($foundServer);
|
return $this->setServer($foundServer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->current_step = 'servers';
|
$this->current_step = 'servers';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function set_server(Server $server)
|
public function setServer(Server $server)
|
||||||
{
|
{
|
||||||
$this->server_id = $server->id;
|
$this->server_id = $server->id;
|
||||||
$this->standaloneDockers = $server->standaloneDockers;
|
$this->standaloneDockers = $server->standaloneDockers;
|
||||||
@ -57,7 +75,7 @@ public function set_server(Server $server)
|
|||||||
$this->current_step = 'destinations';
|
$this->current_step = 'destinations';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function set_destination(string $destination_uuid)
|
public function setDestination(string $destination_uuid)
|
||||||
{
|
{
|
||||||
$this->destination_uuid = $destination_uuid;
|
$this->destination_uuid = $destination_uuid;
|
||||||
redirect()->route('project.resources.new', [
|
redirect()->route('project.resources.new', [
|
||||||
|
@ -93,7 +93,18 @@ function generate_ssh_command(string $private_key_location, string $server_ip, s
|
|||||||
|
|
||||||
return $ssh_command;
|
return $ssh_command;
|
||||||
}
|
}
|
||||||
|
function instantCommand(string $command, $throwError = true) {
|
||||||
|
$process = Process::run($command);
|
||||||
|
$output = trim($process->output());
|
||||||
|
$exitCode = $process->exitCode();
|
||||||
|
if ($exitCode !== 0) {
|
||||||
|
if (!$throwError) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
throw new \RuntimeException($process->errorOutput(), $exitCode);
|
||||||
|
}
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
function instant_remote_process(array $command, Server $server, $throwError = true, $repeat = 1)
|
function instant_remote_process(array $command, Server $server, $throwError = true, $repeat = 1)
|
||||||
{
|
{
|
||||||
$command_string = implode("\n", $command);
|
$command_string = implode("\n", $command);
|
||||||
|
@ -26,7 +26,8 @@ class="absolute inset-y-0 left-0 flex items-center pl-2 cursor-pointer hover:tex
|
|||||||
wire:model.defer={{ $id }} wire:dirty.class.remove='text-white'
|
wire:model.defer={{ $id }} wire:dirty.class.remove='text-white'
|
||||||
wire:dirty.class="input-warning" wire:loading.attr="disabled" type="{{ $type }}"
|
wire:dirty.class="input-warning" wire:loading.attr="disabled" type="{{ $type }}"
|
||||||
@readonly($readonly) @disabled($disabled) id="{{ $id }}" name="{{ $name }}"
|
@readonly($readonly) @disabled($disabled) id="{{ $id }}" name="{{ $name }}"
|
||||||
placeholder="{{ $attributes->get('placeholder') }}">
|
placeholder="{{ $attributes->get('placeholder') }}"
|
||||||
|
aria-placeholder="{{ $attributes->get('placeholder') }}">
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@else
|
@else
|
||||||
|
@ -10,8 +10,7 @@
|
|||||||
</ul>
|
</ul>
|
||||||
<h2>Applications</h2>
|
<h2>Applications</h2>
|
||||||
<div class="grid justify-start grid-cols-1 gap-2 text-left xl:grid-cols-3">
|
<div class="grid justify-start grid-cols-1 gap-2 text-left xl:grid-cols-3">
|
||||||
<div class="box group"
|
<div class="box group" wire:click="setType('public')">
|
||||||
wire:click="set_type('public')">
|
|
||||||
<div class="flex flex-col mx-6">
|
<div class="flex flex-col mx-6">
|
||||||
<div class="group-hover:text-white">
|
<div class="group-hover:text-white">
|
||||||
Public Repository
|
Public Repository
|
||||||
@ -21,8 +20,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="box group"
|
<div class="box group" wire:click="setType('private-gh-app')">
|
||||||
wire:click="set_type('private-gh-app')">
|
|
||||||
<div class="flex flex-col mx-6">
|
<div class="flex flex-col mx-6">
|
||||||
<div class="group-hover:text-white">
|
<div class="group-hover:text-white">
|
||||||
Private Repository
|
Private Repository
|
||||||
@ -32,8 +30,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="box group"
|
<div class="box group" wire:click="setType('private-deploy-key')">
|
||||||
wire:click="set_type('private-deploy-key')">
|
|
||||||
<div class="flex flex-col mx-6">
|
<div class="flex flex-col mx-6">
|
||||||
<div class="group-hover:text-white">
|
<div class="group-hover:text-white">
|
||||||
Private Repository (with deploy key)
|
Private Repository (with deploy key)
|
||||||
@ -45,8 +42,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid justify-start grid-cols-1 gap-2 text-left xl:grid-cols-3">
|
<div class="grid justify-start grid-cols-1 gap-2 text-left xl:grid-cols-3">
|
||||||
<div class="box group"
|
<div class="box group" wire:click="setType('dockerfile')">
|
||||||
wire:click="set_type('dockerfile')">
|
|
||||||
<div class="flex flex-col mx-6">
|
<div class="flex flex-col mx-6">
|
||||||
<div class="group-hover:text-white">
|
<div class="group-hover:text-white">
|
||||||
Based on a Dockerfile
|
Based on a Dockerfile
|
||||||
@ -58,18 +54,27 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<h2 class="py-4">Databases</h2>
|
<h2 class="py-4">Databases</h2>
|
||||||
<div class="flex flex-col justify-start gap-2 text-left xl:flex-row">
|
<div class="grid justify-start grid-cols-1 gap-2 text-left xl:grid-cols-3">
|
||||||
<div class="box group"
|
<div class="box group" wire:click="setType('postgresql')">
|
||||||
wire:click="set_type('postgresql')">
|
|
||||||
<div class="flex flex-col mx-6">
|
<div class="flex flex-col mx-6">
|
||||||
<div class="group-hover:text-white">
|
<div class="group-hover:text-white">
|
||||||
PostgreSQL
|
New PostgreSQL
|
||||||
</div>
|
</div>
|
||||||
<div class="text-xs group-hover:text-white">
|
<div class="text-xs group-hover:text-white">
|
||||||
The most loved relational database in the world.
|
The most loved relational database in the world.
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{{-- <div class="box group" wire:click="setType('existing-postgresql')">
|
||||||
|
<div class="flex flex-col mx-6">
|
||||||
|
<div class="group-hover:text-white">
|
||||||
|
Backup Existing PostgreSQL
|
||||||
|
</div>
|
||||||
|
<div class="text-xs group-hover:text-white">
|
||||||
|
Schedule a backup of an existing PostgreSQL database.
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div> --}}
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
@if ($current_step === 'servers')
|
@if ($current_step === 'servers')
|
||||||
@ -80,8 +85,7 @@
|
|||||||
</ul>
|
</ul>
|
||||||
<div class="flex flex-col justify-center gap-2 text-left xl:flex-row">
|
<div class="flex flex-col justify-center gap-2 text-left xl:flex-row">
|
||||||
@forelse($servers as $server)
|
@forelse($servers as $server)
|
||||||
<div class="box group"
|
<div class="box group" wire:click="setServer({{ $server }})">
|
||||||
wire:click="set_server({{ $server }})">
|
|
||||||
<div class="flex flex-col mx-6">
|
<div class="flex flex-col mx-6">
|
||||||
<div class="group-hover:text-white">
|
<div class="group-hover:text-white">
|
||||||
{{ $server->name }}
|
{{ $server->name }}
|
||||||
@ -92,9 +96,9 @@
|
|||||||
</div>
|
</div>
|
||||||
@empty
|
@empty
|
||||||
<div>
|
<div>
|
||||||
<div>No validated & reachable servers found. <a class="text-white underline" href="/servers">
|
<div>No validated & reachable servers found. <a class="text-white underline" href="/servers">
|
||||||
Go to servers page
|
Go to servers page
|
||||||
</a></div>
|
</a></div>
|
||||||
|
|
||||||
<x-use-magic-bar link="/server/new" />
|
<x-use-magic-bar link="/server/new" />
|
||||||
</div>
|
</div>
|
||||||
@ -109,11 +113,10 @@
|
|||||||
</ul>
|
</ul>
|
||||||
<div class="flex flex-col justify-center gap-2 text-left xl:flex-row">
|
<div class="flex flex-col justify-center gap-2 text-left xl:flex-row">
|
||||||
@foreach ($standaloneDockers as $standaloneDocker)
|
@foreach ($standaloneDockers as $standaloneDocker)
|
||||||
<div class="box group"
|
<div class="box group" wire:click="setDestination('{{ $standaloneDocker->uuid }}')">
|
||||||
wire:click="set_destination('{{ $standaloneDocker->uuid }}')">
|
|
||||||
<div class="flex flex-col mx-6">
|
<div class="flex flex-col mx-6">
|
||||||
<div class="font-bold group-hover:text-white">
|
<div class="font-bold group-hover:text-white">
|
||||||
Standalone Docker <span class="text-xs">({{ $standaloneDocker->name }})</span>
|
Standalone Docker <span class="text-xs">({{ $standaloneDocker->name }})</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="text-xs group-hover:text-white">
|
<div class="text-xs group-hover:text-white">
|
||||||
network: {{ $standaloneDocker->network }}</div>
|
network: {{ $standaloneDocker->network }}</div>
|
||||||
@ -121,16 +124,21 @@
|
|||||||
</div>
|
</div>
|
||||||
@endforeach
|
@endforeach
|
||||||
@foreach ($swarmDockers as $swarmDocker)
|
@foreach ($swarmDockers as $swarmDocker)
|
||||||
<div class="box group"
|
<div class="box group" wire:click="setDestination('{{ $swarmDocker->uuid }}')">
|
||||||
wire:click="set_destination('{{ $swarmDocker->uuid }}')">
|
<div class="flex flex-col mx-6">
|
||||||
<div class="flex flex-col mx-6">
|
<div class="font-bold group-hover:text-white">
|
||||||
<div class="font-bold group-hover:text-white">
|
Swarm Docker <span class="text-xs">({{ $swarmDocker->name }})</span>
|
||||||
Swarm Docker <span class="text-xs">({{ $swarmDocker->name }})</span>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
@endforeach
|
||||||
@endforeach
|
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
|
@if ($current_step === 'existing-postgresql')
|
||||||
|
<form wire:submit.prevent='addExistingPostgresql' class="flex items-end gap-2">
|
||||||
|
<x-forms.input placeholder="postgres://username:password@database:5432" label="Database URL" id="existingPostgresqlUrl" />
|
||||||
|
<x-forms.button type="submit">Add Database</x-forms.button>
|
||||||
|
</form>
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user