Merge branch 'next' into fix-unreachable-notificiations

This commit is contained in:
🏔️ Peak
2024-12-16 14:08:58 +01:00
committed by GitHub
15 changed files with 108 additions and 80 deletions

View File

@@ -32,8 +32,6 @@ class DatabaseBackupJob implements ShouldBeEncrypted, ShouldQueue
public Server $server;
public ScheduledDatabaseBackup $backup;
public StandalonePostgresql|StandaloneMongodb|StandaloneMysql|StandaloneMariadb|ServiceDatabase $database;
public ?string $container_name = null;
@@ -58,10 +56,9 @@ class DatabaseBackupJob implements ShouldBeEncrypted, ShouldQueue
public ?S3Storage $s3 = null;
public function __construct($backup)
public function __construct(public ScheduledDatabaseBackup $backup)
{
$this->onQueue('high');
$this->backup = $backup;
}
public function handle(): void

View File

@@ -21,16 +21,28 @@ class Index extends Component
public function mount()
{
if (! isCloud()) {
if (! isCloud() && ! isDev()) {
return redirect()->route('dashboard');
}
if (Auth::id() !== 0) {
if (Auth::id() !== 0 && ! session('impersonating')) {
return redirect()->route('dashboard');
}
$this->getSubscribers();
}
public function back()
{
if (session('impersonating')) {
session()->forget('impersonating');
$user = User::find(0);
$team_to_switch_to = $user->teams->first();
Auth::login($user);
refreshSession($team_to_switch_to);
return redirect(request()->header('Referer'));
}
}
public function submitSearch()
{
if ($this->search !== '') {
@@ -52,9 +64,10 @@ class Index extends Component
if (Auth::id() !== 0) {
return redirect()->route('dashboard');
}
session(['impersonating' => true]);
$user = User::find($user_id);
$team_to_switch_to = $user->teams->first();
Cache::forget("team:{$user->id}");
// Cache::forget("team:{$user->id}");
Auth::login($user);
refreshSession($team_to_switch_to);

View File

@@ -327,7 +327,7 @@ class General extends Component
}
}
public function set_redirect()
public function setRedirect()
{
try {
$has_www = collect($this->application->fqdns)->filter(fn ($fqdn) => str($fqdn)->contains('www.'))->count();
@@ -360,10 +360,10 @@ class General extends Component
if ($warning) {
$this->dispatch('warning', __('warning.sslipdomain'));
}
$this->resetDefaultLabels();
// $this->resetDefaultLabels();
if ($this->application->isDirty('redirect')) {
$this->set_redirect();
$this->setRedirect();
}
$this->checkFqdns();

View File

@@ -9,11 +9,9 @@ class BackupNow extends Component
{
public $backup;
public function backup_now()
public function backupNow()
{
dispatch(new DatabaseBackupJob(
backup: $this->backup
));
DatabaseBackupJob::dispatch($this->backup);
$this->dispatch('success', 'Backup queued. It will be available in a few minutes.');
}
}

View File

@@ -42,9 +42,11 @@ class ResourceOperations extends Component
$uuid = (string) new Cuid2;
$server = $new_destination->server;
if ($this->resource->getMorphClass() === \App\Models\Application::class) {
$name = 'clone-of-'.str($this->resource->name)->limit(20).'-'.$uuid;
$new_resource = $this->resource->replicate()->fill([
'uuid' => $uuid,
'name' => $this->resource->name.'-clone-'.$uuid,
'name' => $name,
'fqdn' => generateFqdn($server, $uuid),
'status' => 'exited',
'destination_id' => $new_destination->id,
@@ -64,8 +66,12 @@ class ResourceOperations extends Component
}
$persistentVolumes = $this->resource->persistentStorages()->get();
foreach ($persistentVolumes as $volume) {
$volumeName = str($volume->name)->replace($this->resource->uuid, $new_resource->uuid)->value();
if ($volumeName === $volume->name) {
$volumeName = $new_resource->uuid.'-'.str($volume->name)->afterLast('-');
}
$newPersistentVolume = $volume->replicate()->fill([
'name' => $new_resource->uuid.'-'.str($volume->name)->afterLast('-'),
'name' => $volumeName,
'resource_id' => $new_resource->id,
]);
$newPersistentVolume->save();

View File

@@ -69,6 +69,7 @@ function allowedPathsForUnsubscribedAccounts()
'logout',
'force-password-reset',
'livewire/update',
'admin',
];
}
function allowedPathsForBoardingAccounts()

View File

@@ -2,7 +2,7 @@
return [
'coolify' => [
'version' => '4.0.0-beta.379',
'version' => '4.0.0-beta.380',
'self_hosted' => env('SELF_HOSTED', true),
'autoupdate' => env('AUTOUPDATE'),
'base_config_path' => env('BASE_CONFIG_PATH', '/data/coolify'),

View File

@@ -4,6 +4,7 @@ namespace Database\Seeders;
use App\Models\OauthSetting;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Log;
class OauthSettingSeeder extends Seeder
{
@@ -12,6 +13,7 @@ class OauthSettingSeeder extends Seeder
*/
public function run(): void
{
try {
$providers = collect([
'azure',
'bitbucket',
@@ -27,27 +29,27 @@ class OauthSettingSeeder extends Seeder
// Before authentik was a provider, providers started with 0 id
$isOauthAuthentik = OauthSetting::where('provider', 'authentik')->exists();
if ($isOauthSeeded) {
if (! $isOauthAuthentik) {
if (! $isOauthSeeded || $isOauthAuthentik) {
foreach ($providers as $provider) {
OauthSetting::updateOrCreate([
'provider' => $provider,
]);
}
return;
}
$allProviders = OauthSetting::all();
$notFoundProviders = $providers->diff($allProviders->pluck('provider'));
$allProviders->each(function ($provider) {
$provider->delete();
});
$allProviders->each(function ($provider) use ($providers) {
$providerName = $provider->provider;
$foundProvider = $providers->first(function ($provider) use ($providerName) {
return $provider === $providerName;
});
if ($foundProvider) {
$newProvder = new OauthSetting;
$newProvder = $provider;
unset($newProvder->id);
$newProvder->save();
}
$allProviders->each(function ($provider) {
$provider = new OauthSetting;
$provider->provider = $provider->provider;
unset($provider->id);
$provider->save();
});
foreach ($notFoundProviders as $provider) {
@@ -55,19 +57,9 @@ class OauthSettingSeeder extends Seeder
'provider' => $provider,
]);
}
} else {
foreach ($providers as $provider) {
OauthSetting::updateOrCreate([
'provider' => $provider,
]);
}
}
} else {
foreach ($providers as $provider) {
OauthSetting::updateOrCreate([
'provider' => $provider,
]);
}
} catch (\Exception $e) {
Log::error($e->getMessage());
}
}
}

View File

@@ -99,6 +99,9 @@ RUN mkdir -p /usr/local/bin && \
COPY docker/production/etc/php/conf.d/zzz-custom-php.ini /usr/local/etc/php/conf.d/zzz-custom-php.ini
ENV PHP_OPCACHE_ENABLE=1
# Configure entrypoint
COPY --chmod=755 docker/production/entrypoint.d/ /etc/entrypoint.d
# Copy application files from previous stages
COPY --from=base --chown=www-data:www-data /var/www/html/vendor ./vendor
COPY --from=static-assets --chown=www-data:www-data /app/public/build ./public/build

View File

@@ -0,0 +1,8 @@
# Debug mode
if [ "$APP_DEBUG" = "true" ]; then
echo "Debug mode is enabled"
echo "Installing development dependencies..."
composer install --dev --no-scripts
echo "Clearing optimized classes..."
php artisan optimize:clear
fi

View File

@@ -340,7 +340,8 @@
</li>
@endif
@if (isCloud() && isInstanceAdmin())
@if (isCloud() || isDev())
@if (isInstanceAdmin() || session('impersonating'))
<li>
<a title="Admin" class="menu-item" href="/admin">
<svg class="text-pink-600 icon" viewBox="0 0 256 256"
@@ -352,6 +353,7 @@
</a>
</li>
@endif
@endif
<div class="flex-1"></div>
@if (isInstanceAdmin() && !isCloud())
@persist('upgrade')

View File

@@ -1,7 +1,12 @@
<div>
<h1>Admin Dashboard</h1>
<h3 class="pt-4">Who am I now?</h3>
<div class="pb-4">{{ auth()->user()->name }}</div>
<div class="flex gap-2 pt-4">
<h3>Who am I now?</h3>
@if (session('impersonating'))
<x-forms.button wire:click="back">Go back to root</x-forms.button>
@endif
</div>
<div class="pb-4">{{ auth()->user()->name }} ({{ auth()->user()->email }})</div>
<form wire:submit="submitSearch" class="flex flex-col gap-2 lg:flex-row">
<x-forms.input wire:model="search" placeholder="Search for a user" />
<x-forms.button type="submit">Search</x-forms.button>

View File

@@ -84,7 +84,7 @@
<option value="non-www">Redirect to non-www.</option>
</x-forms.select>
<x-modal-confirmation title="Confirm Redirection Setting?" buttonTitle="Set Direction"
submitAction="set_redirect" :actions="['All traffic will be redirected to the selected direction.']" confirmationText="{{ $application->fqdn . '/' }}"
submitAction="setRedirect" :actions="['All traffic will be redirected to the selected direction.']" confirmationText="{{ $application->fqdn . '/' }}"
confirmationLabel="Please confirm the execution of the action by entering the Application URL below"
shortConfirmationLabel="Application URL" :confirmWithPassword="false" step2ButtonText="Set Direction">
<x-slot:customButton>
@@ -161,8 +161,7 @@
</div>
<div class="pt-1 text-xs">Nixpacks will detect the required configuration
automatically.
<a class="underline"
href="https://coolify.io/docs/applications">Framework
<a class="underline" href="https://coolify.io/docs/applications">Framework
Specific Docs</a>
</div>
@endif

View File

@@ -57,6 +57,10 @@ services:
- GITHUB_APP_NAME=${GITHUB_APP_NAME}
- GITHUB_APP_ID=${GITHUB_APP_ID}
- GITHUB_APP_PRIVATE_KEY=${GITHUB_APP_PRIVATE_KEY}
- DISCORD_CLIENT_ID=${DISCORD_CLIENT_ID}
- DISCORD_CLIENT_SECRET=${DISCORD_CLIENT_SECRET}
- DISCORD_SERVER_ID=${DISCORD_SERVER_ID}
- DISCORD_SERVER_ROLES=${DISCORD_SERVER_ROLES}
- PGSSLMODE=${PGSSLMODE:-disable}
- FORCE_HTTPS=${FORCE_HTTPS:-true}
healthcheck:

View File

@@ -1,10 +1,10 @@
{
"coolify": {
"v4": {
"version": "4.0.0-beta.379"
"version": "4.0.0-beta.380"
},
"nightly": {
"version": "4.0.0-beta.380"
"version": "4.0.0-beta.381"
},
"helper": {
"version": "1.0.4"