Skip to content

Commit

Permalink
Merge pull request #2100 from coollabsio/next
Browse files Browse the repository at this point in the history
v4.0.0-beta.272
  • Loading branch information
andrasbacsai committed May 2, 2024
2 parents 4f0d170 + d874c71 commit 56be074
Show file tree
Hide file tree
Showing 18 changed files with 306 additions and 265 deletions.
19 changes: 16 additions & 3 deletions app/Jobs/DatabaseBackupJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,10 +318,15 @@ public function handle(): void
private function backup_standalone_mongodb(string $databaseWithCollections): void
{
try {
ray($this->database->toArray());
$url = $this->database->get_db_url(useInternal: true);
if ($databaseWithCollections === 'all') {
$commands[] = "mkdir -p " . $this->backup_dir;
$commands[] = "docker exec $this->container_name mongodump --authenticationDatabase=admin --uri=$url --gzip --archive > $this->backup_location";
if (str($this->database->image)->startsWith('mongo:4.0')) {
$commands[] = "docker exec $this->container_name mongodump --uri=$url --gzip --archive > $this->backup_location";
} else {
$commands[] = "docker exec $this->container_name mongodump --authenticationDatabase=admin --uri=$url --gzip --archive > $this->backup_location";
}
} else {
if (str($databaseWithCollections)->contains(':')) {
$databaseName = str($databaseWithCollections)->before(':');
Expand All @@ -332,9 +337,17 @@ private function backup_standalone_mongodb(string $databaseWithCollections): voi
}
$commands[] = "mkdir -p " . $this->backup_dir;
if ($collectionsToExclude->count() === 0) {
$commands[] = "docker exec $this->container_name mongodump --authenticationDatabase=admin --uri=$url --db $databaseName --gzip --archive > $this->backup_location";
if (str($this->database->image)->startsWith('mongo:4.0')) {
$commands[] = "docker exec $this->container_name mongodump --uri=$url --gzip --archive > $this->backup_location";
} else {
$commands[] = "docker exec $this->container_name mongodump --authenticationDatabase=admin --uri=$url --db $databaseName --gzip --archive > $this->backup_location";
}
} else {
$commands[] = "docker exec $this->container_name mongodump --authenticationDatabase=admin --uri=$url --db $databaseName --gzip --excludeCollection " . $collectionsToExclude->implode(' --excludeCollection ') . " --archive > $this->backup_location";
if (str($this->database->image)->startsWith('mongo:4.0')) {
$commands[] = "docker exec $this->container_name mongodump --uri=$url --gzip --excludeCollection " . $collectionsToExclude->implode(' --excludeCollection ') . " --archive > $this->backup_location";
} else {
$commands[] = "docker exec $this->container_name mongodump --authenticationDatabase=admin --uri=$url --db $databaseName --gzip --excludeCollection " . $collectionsToExclude->implode(' --excludeCollection ') . " --archive > $this->backup_location";
}
}
}
$this->backup_output = instant_remote_process($commands, $this->server);
Expand Down
3 changes: 2 additions & 1 deletion app/Jobs/SendMessageToDiscordJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ class SendMessageToDiscordJob implements ShouldQueue, ShouldBeEncrypted
* @var int
*/
public $tries = 5;
public $backoff = 10;

/**
* The maximum number of unhandled exceptions to allow before failing.
*/
public int $maxExceptions = 3;
public int $maxExceptions = 5;

public function __construct(
public string $text,
Expand Down
28 changes: 24 additions & 4 deletions app/Livewire/Project/Shared/GetLogs.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,35 @@ public function getLogs($refresh = false)
if ($this->container) {
if ($this->showTimeStamps) {
if ($this->server->isSwarm()) {
$sshCommand = generateSshCommand($this->server, "docker service logs -n {$this->numberOfLines} -t {$this->container}");
$command = "docker service logs -n {$this->numberOfLines} -t {$this->container}";
if ($this->server->isNonRoot()) {
$command = parseCommandsByLineForSudo(collect($command), $this->server);
$command = $command[0];
}
$sshCommand = generateSshCommand($this->server, $command);
} else {
$sshCommand = generateSshCommand($this->server, "docker logs -n {$this->numberOfLines} -t {$this->container}");
$command = "docker logs -n {$this->numberOfLines} -t {$this->container}";
if ($this->server->isNonRoot()) {
$command = parseCommandsByLineForSudo(collect($command), $this->server);
$command = $command[0];
}
$sshCommand = generateSshCommand($this->server, $command);
}
} else {
if ($this->server->isSwarm()) {
$sshCommand = generateSshCommand($this->server, "docker service logs -n {$this->numberOfLines} {$this->container}");
$command = "docker service logs -n {$this->numberOfLines} {$this->container}";
if ($this->server->isNonRoot()) {
$command = parseCommandsByLineForSudo(collect($command), $this->server);
$command = $command[0];
}
$sshCommand = generateSshCommand($this->server, $command);
} else {
$sshCommand = generateSshCommand($this->server, "docker logs -n {$this->numberOfLines} {$this->container}");
$command = "docker logs -n {$this->numberOfLines} {$this->container}";
if ($this->server->isNonRoot()) {
$command = parseCommandsByLineForSudo(collect($command), $this->server);
$command = $command[0];
}
$sshCommand = generateSshCommand($this->server, $command);
}
}
if ($refresh) {
Expand Down
4 changes: 2 additions & 2 deletions app/Livewire/Storage/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ class Create extends Component
public string $endpoint;
public S3Storage $storage;
protected $rules = [
'name' => 'nullable|min:3|max:255',
'name' => 'required|min:3|max:255',
'description' => 'nullable|min:3|max:255',
'region' => 'required|max:255',
'key' => 'required|max:255',
'secret' => 'required|max:255',
'bucket' => 'required|max:255',
'endpoint' => 'nullable|url|max:255',
'endpoint' => 'required|url|max:255',
];
protected $validationAttributes = [
'name' => 'Name',
Expand Down
9 changes: 1 addition & 8 deletions app/Notifications/Application/DeploymentSuccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,8 @@ public function __construct(Application $application, string $deployment_uuid, A

public function via(object $notifiable): array
{
$channels = setNotificationChannels($notifiable, 'deployments');
if (isCloud()) {
$channels = array_filter($channels, function ($channel) {
return $channel !== 'App\Notifications\Channels\EmailChannel';
});
}
return $channels;
return setNotificationChannels($notifiable, 'deployments');
}

public function toMail(): MailMessage
{
$mail = new MailMessage();
Expand Down
2 changes: 2 additions & 0 deletions config/constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@
'basic' => env('LIMIT_SERVER_BASIC', 2),
'pro' => env('LIMIT_SERVER_PRO', 10),
'ultimate' => env('LIMIT_SERVER_ULTIMATE', 25),
'dynamic' => env('LIMIT_SERVER_DYNAMIC', 2),
],
'email' => [
'zero' => true,
'self-hosted' => true,
'basic' => true,
'pro' => true,
'ultimate' => true,
'dynamic' => true,
],
],
];
2 changes: 1 addition & 1 deletion config/sentry.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

// 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.271',
'release' => '4.0.0-beta.272',
// When left empty or `null` the Laravel environment will be used
'environment' => config('app.env'),

Expand Down
2 changes: 1 addition & 1 deletion config/version.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?php

return '4.0.0-beta.271';
return '4.0.0-beta.272';
8 changes: 4 additions & 4 deletions resources/views/livewire/dashboard.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
<h1>Dashboard</h1>
<div class="subtitle">Your self-hosted infrastructure.</div>
@if (request()->query->get('success'))
<div class="mb-10 rounded dark:text-white alert-success">
<div class="items-center justify-center mb-10 font-bold rounded alert alert-success">
<svg xmlns="http://www.w3.org/2000/svg" class="w-6 h-6 stroke-current shrink-0" fill="none"
viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" />
d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
<span>Your subscription has been activated! Welcome onboard! <br>It could take a few seconds before your
subscription is activated.<br> Please be patient.</span>
Your subscription has been activated! Welcome onboard! <br>It could take a few seconds before your
subscription is activated.<br> Please be patient.
</div>
@endif
<h3 class="pb-4">Projects</h3>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,58 +1,53 @@
<div>
<h2>Resource Operations</h2>
<div class="pb-4">You can easily make different kind of operations on this resource.</div>
<h4>Clone</h4>
<div class="pb-8">
<div class="pb-2">
Clone this resource to another project / environment.
</div>
<div class="flex flex-col">
<h3>Clone</h3>
<div class="pb-4">To another project / environment on a different server.</div>
<div class="pb-4">
<div class="flex flex-col flex-wrap gap-2">
@foreach ($servers->sortBy('id') as $server)
<div>
<div class="grid grid-cols-1 gap-2 pb-4 lg:grid-cols-4">
@foreach ($server->destinations() as $destination)
<x-modal-confirmation action="cloneTo({{ data_get($destination, 'id') }})">
<x:slot name="content">
<div class="box">
<div class="flex flex-col">
<div class="box-title">{{ $server->name }}</div>
<div class="box-description">{{ $destination->name }}</div>
</div>
</div>
</x:slot>
<div>You are about to clone this resource.</div>
</x-modal-confirmation>
@endforeach
</div>
</div>
<h5>Server: <span class="font-bold text-white">{{ $server->name }}</span></h5>
@foreach ($server->destinations() as $destination)
<x-modal-confirmation action="cloneTo({{ data_get($destination, 'id') }})">
<x:slot name="content">
<div class="box group">
<div class="flex flex-col">
<div class="box-title">Network</div>
<div class="box-description">{{ $destination->name }}</div>
</div>
</div>
</x:slot>
<div>You are about to clone this resource.</div>
</x-modal-confirmation>
@endforeach
@endforeach
</div>
</div>
<h4>Move</h4>
<h3>Move</h3>
<div class="pb-4">Between projects / environments.</div>
<div>
<div class="pb-8">
<div class="pb-2">
This resource is currently in the <span
class="font-bold dark:text-warning">{{ $resource->environment->project->name }} /
{{ $resource->environment->name }}</span> environment.
</div>
<div class="flex flex-wrap gap-2">
<div class="flex flex-col flex-wrap gap-2">
@forelse ($projects as $project)
<div class="flex flex-wrap gap-2">
@foreach ($project->environments as $environment)
<x-modal-confirmation action="moveTo({{ data_get($environment, 'id') }})">
<x:slot name="content">
<div class="box">
<div class="flex flex-col">
<div class="box-title">{{ $project->name }}</div>
<div class="box-description">environment: {{ $environment->name }}
</div>
</div>
<h5>Project: <span class="font-bold text-white">{{ $project->name }}</span></h5>

@foreach ($project->environments as $environment)
<x-modal-confirmation action="moveTo({{ data_get($environment, 'id') }})">
<x:slot name="content">
<div class="box group">
<div class="flex flex-col">
<div class="box-title">Environment</div>
<div class="box-description">{{ $environment->name }}</div>
</div>
</x:slot>
<div>You are about to move this resource.</div>
</x-modal-confirmation>
@endforeach
</div>
</div>
</x:slot>
<div>You are about to move this resource.</div>
</x-modal-confirmation>
@endforeach
@empty
<div>No projects found to move to</div>
@endforelse
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@
@if ($isFirst)
<x-forms.input id="storage.name" label="Volume Name" required
helper="Warning: Changing the volume name after the initial start could cause problems. Only use it when you know what are you doing." />
<x-forms.input id="storage.host_path" label="Source Path (on host)" helper="Warning: Changing the source path after the initial start could cause problems. Only use it when you know what are you doing." />
<x-forms.input id="storage.host_path" label="Source Path (on host)"
helper="Warning: Changing the source path after the initial start could cause problems. Only use it when you know what are you doing." />
<x-forms.input id="storage.mount_path" label="Destination Path (in container)" required readonly />
<x-forms.button type="submit">
Update
</x-forms.button>
@else
<x-forms.input id="storage.name" required readonly
helper="Warning: Changing the volume name after the initial start could cause problems. Only use it when you know what are you doing." />
Expand Down
4 changes: 2 additions & 2 deletions resources/views/livewire/storage/create.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
<div class="subtitle">S3 Storage used to save backups / files.</div>
<form class="flex flex-col gap-2" wire:submit='submit'>
<div class="flex gap-2">
<x-forms.input label="Name" id="name" />
<x-forms.input required label="Name" id="name" />
<x-forms.input label="Description" id="description" />
</div>
<div class="flex gap-2">
<x-forms.input type="url" label="Endpoint" id="endpoint" />
<x-forms.input required type="url" label="Endpoint" id="endpoint" />
<x-forms.input required label="Bucket" id="bucket" />
<x-forms.input required label="Region" id="region" />
</div>
Expand Down

0 comments on commit 56be074

Please sign in to comment.