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

View File

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

View File

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

View File

@@ -9,11 +9,9 @@ class BackupNow extends Component
{ {
public $backup; public $backup;
public function backup_now() public function backupNow()
{ {
dispatch(new DatabaseBackupJob( DatabaseBackupJob::dispatch($this->backup);
backup: $this->backup
));
$this->dispatch('success', 'Backup queued. It will be available in a few minutes.'); $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; $uuid = (string) new Cuid2;
$server = $new_destination->server; $server = $new_destination->server;
if ($this->resource->getMorphClass() === \App\Models\Application::class) { if ($this->resource->getMorphClass() === \App\Models\Application::class) {
$name = 'clone-of-'.str($this->resource->name)->limit(20).'-'.$uuid;
$new_resource = $this->resource->replicate()->fill([ $new_resource = $this->resource->replicate()->fill([
'uuid' => $uuid, 'uuid' => $uuid,
'name' => $this->resource->name.'-clone-'.$uuid, 'name' => $name,
'fqdn' => generateFqdn($server, $uuid), 'fqdn' => generateFqdn($server, $uuid),
'status' => 'exited', 'status' => 'exited',
'destination_id' => $new_destination->id, 'destination_id' => $new_destination->id,
@@ -64,8 +66,12 @@ class ResourceOperations extends Component
} }
$persistentVolumes = $this->resource->persistentStorages()->get(); $persistentVolumes = $this->resource->persistentStorages()->get();
foreach ($persistentVolumes as $volume) { 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([ $newPersistentVolume = $volume->replicate()->fill([
'name' => $new_resource->uuid.'-'.str($volume->name)->afterLast('-'), 'name' => $volumeName,
'resource_id' => $new_resource->id, 'resource_id' => $new_resource->id,
]); ]);
$newPersistentVolume->save(); $newPersistentVolume->save();

View File

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

View File

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

View File

@@ -4,6 +4,7 @@ namespace Database\Seeders;
use App\Models\OauthSetting; use App\Models\OauthSetting;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Log;
class OauthSettingSeeder extends Seeder class OauthSettingSeeder extends Seeder
{ {
@@ -12,62 +13,53 @@ class OauthSettingSeeder extends Seeder
*/ */
public function run(): void public function run(): void
{ {
$providers = collect([ try {
'azure', $providers = collect([
'bitbucket', 'azure',
'github', 'bitbucket',
'gitlab', 'github',
'google', 'gitlab',
'authentik', 'google',
]); 'authentik',
]);
$isOauthSeeded = OauthSetting::count() > 0; $isOauthSeeded = OauthSetting::count() > 0;
// We changed how providers are defined in the database, so we authentik does not exists, we need to recreate all of the auth providers // We changed how providers are defined in the database, so we authentik does not exists, we need to recreate all of the auth providers
// Before authentik was a provider, providers started with 0 id // Before authentik was a provider, providers started with 0 id
$isOauthAuthentik = OauthSetting::where('provider', 'authentik')->exists(); $isOauthAuthentik = OauthSetting::where('provider', 'authentik')->exists();
if ($isOauthSeeded) { if (! $isOauthSeeded || $isOauthAuthentik) {
if (! $isOauthAuthentik) {
$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();
}
});
foreach ($notFoundProviders as $provider) {
OauthSetting::create([
'provider' => $provider,
]);
}
} else {
foreach ($providers as $provider) { foreach ($providers as $provider) {
OauthSetting::updateOrCreate([ OauthSetting::updateOrCreate([
'provider' => $provider, 'provider' => $provider,
]); ]);
} }
return;
} }
} else {
foreach ($providers as $provider) { $allProviders = OauthSetting::all();
OauthSetting::updateOrCreate([ $notFoundProviders = $providers->diff($allProviders->pluck('provider'));
$allProviders->each(function ($provider) {
$provider->delete();
});
$allProviders->each(function ($provider) {
$provider = new OauthSetting;
$provider->provider = $provider->provider;
unset($provider->id);
$provider->save();
});
foreach ($notFoundProviders as $provider) {
OauthSetting::create([
'provider' => $provider, '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 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 ENV PHP_OPCACHE_ENABLE=1
# Configure entrypoint
COPY --chmod=755 docker/production/entrypoint.d/ /etc/entrypoint.d
# Copy application files from previous stages # Copy application files from previous stages
COPY --from=base --chown=www-data:www-data /var/www/html/vendor ./vendor 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 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,17 +340,19 @@
</li> </li>
@endif @endif
@if (isCloud() && isInstanceAdmin()) @if (isCloud() || isDev())
<li> @if (isInstanceAdmin() || session('impersonating'))
<a title="Admin" class="menu-item" href="/admin"> <li>
<svg class="text-pink-600 icon" viewBox="0 0 256 256" <a title="Admin" class="menu-item" href="/admin">
xmlns="http://www.w3.org/2000/svg"> <svg class="text-pink-600 icon" viewBox="0 0 256 256"
<path fill="currentColor" xmlns="http://www.w3.org/2000/svg">
d="M177.62 159.6a52 52 0 0 1-34 34a12.2 12.2 0 0 1-3.6.55a12 12 0 0 1-3.6-23.45a28 28 0 0 0 18.32-18.32a12 12 0 0 1 22.9 7.2ZM220 144a92 92 0 0 1-184 0c0-28.81 11.27-58.18 33.48-87.28a12 12 0 0 1 17.9-1.33l19.69 19.11L127 19.89a12 12 0 0 1 18.94-5.12C168.2 33.25 220 82.85 220 144m-24 0c0-41.71-30.61-78.39-52.52-99.29l-20.21 55.4a12 12 0 0 1-19.63 4.5L80.71 82.36C67 103.38 60 124.06 60 144a68 68 0 0 0 136 0" /> <path fill="currentColor"
</svg> d="M177.62 159.6a52 52 0 0 1-34 34a12.2 12.2 0 0 1-3.6.55a12 12 0 0 1-3.6-23.45a28 28 0 0 0 18.32-18.32a12 12 0 0 1 22.9 7.2ZM220 144a92 92 0 0 1-184 0c0-28.81 11.27-58.18 33.48-87.28a12 12 0 0 1 17.9-1.33l19.69 19.11L127 19.89a12 12 0 0 1 18.94-5.12C168.2 33.25 220 82.85 220 144m-24 0c0-41.71-30.61-78.39-52.52-99.29l-20.21 55.4a12 12 0 0 1-19.63 4.5L80.71 82.36C67 103.38 60 124.06 60 144a68 68 0 0 0 136 0" />
Admin </svg>
</a> Admin
</li> </a>
</li>
@endif
@endif @endif
<div class="flex-1"></div> <div class="flex-1"></div>
@if (isInstanceAdmin() && !isCloud()) @if (isInstanceAdmin() && !isCloud())

View File

@@ -1,7 +1,12 @@
<div> <div>
<h1>Admin Dashboard</h1> <h1>Admin Dashboard</h1>
<h3 class="pt-4">Who am I now?</h3> <div class="flex gap-2 pt-4">
<div class="pb-4">{{ auth()->user()->name }}</div> <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"> <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.input wire:model="search" placeholder="Search for a user" />
<x-forms.button type="submit">Search</x-forms.button> <x-forms.button type="submit">Search</x-forms.button>

View File

@@ -84,7 +84,7 @@
<option value="non-www">Redirect to non-www.</option> <option value="non-www">Redirect to non-www.</option>
</x-forms.select> </x-forms.select>
<x-modal-confirmation title="Confirm Redirection Setting?" buttonTitle="Set Direction" <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" confirmationLabel="Please confirm the execution of the action by entering the Application URL below"
shortConfirmationLabel="Application URL" :confirmWithPassword="false" step2ButtonText="Set Direction"> shortConfirmationLabel="Application URL" :confirmWithPassword="false" step2ButtonText="Set Direction">
<x-slot:customButton> <x-slot:customButton>
@@ -161,8 +161,7 @@
</div> </div>
<div class="pt-1 text-xs">Nixpacks will detect the required configuration <div class="pt-1 text-xs">Nixpacks will detect the required configuration
automatically. automatically.
<a class="underline" <a class="underline" href="https://coolify.io/docs/applications">Framework
href="https://coolify.io/docs/applications">Framework
Specific Docs</a> Specific Docs</a>
</div> </div>
@endif @endif

View File

@@ -57,6 +57,10 @@ services:
- GITHUB_APP_NAME=${GITHUB_APP_NAME} - GITHUB_APP_NAME=${GITHUB_APP_NAME}
- GITHUB_APP_ID=${GITHUB_APP_ID} - GITHUB_APP_ID=${GITHUB_APP_ID}
- GITHUB_APP_PRIVATE_KEY=${GITHUB_APP_PRIVATE_KEY} - 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} - PGSSLMODE=${PGSSLMODE:-disable}
- FORCE_HTTPS=${FORCE_HTTPS:-true} - FORCE_HTTPS=${FORCE_HTTPS:-true}
healthcheck: healthcheck:

View File

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