diff --git a/app/Jobs/DatabaseBackupJob.php b/app/Jobs/DatabaseBackupJob.php index 06aec5e49..6730dceb7 100644 --- a/app/Jobs/DatabaseBackupJob.php +++ b/app/Jobs/DatabaseBackupJob.php @@ -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 diff --git a/app/Livewire/Admin/Index.php b/app/Livewire/Admin/Index.php index 359db6329..b5f6d2929 100644 --- a/app/Livewire/Admin/Index.php +++ b/app/Livewire/Admin/Index.php @@ -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); diff --git a/app/Livewire/Project/Application/General.php b/app/Livewire/Project/Application/General.php index ff29b74e9..d1cc3476c 100644 --- a/app/Livewire/Project/Application/General.php +++ b/app/Livewire/Project/Application/General.php @@ -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(); diff --git a/app/Livewire/Project/Database/BackupNow.php b/app/Livewire/Project/Database/BackupNow.php index 9c9c175e2..3cd360562 100644 --- a/app/Livewire/Project/Database/BackupNow.php +++ b/app/Livewire/Project/Database/BackupNow.php @@ -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.'); } } diff --git a/app/Livewire/Project/Shared/ResourceOperations.php b/app/Livewire/Project/Shared/ResourceOperations.php index e67df6aa9..de7bb3c05 100644 --- a/app/Livewire/Project/Shared/ResourceOperations.php +++ b/app/Livewire/Project/Shared/ResourceOperations.php @@ -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(); diff --git a/bootstrap/helpers/subscriptions.php b/bootstrap/helpers/subscriptions.php index ab9ee9b9d..510516a2f 100644 --- a/bootstrap/helpers/subscriptions.php +++ b/bootstrap/helpers/subscriptions.php @@ -69,6 +69,7 @@ function allowedPathsForUnsubscribedAccounts() 'logout', 'force-password-reset', 'livewire/update', + 'admin', ]; } function allowedPathsForBoardingAccounts() diff --git a/config/constants.php b/config/constants.php index a8a70235b..99859ffb8 100644 --- a/config/constants.php +++ b/config/constants.php @@ -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'), diff --git a/database/seeders/OauthSettingSeeder.php b/database/seeders/OauthSettingSeeder.php index bf902175f..df7619fec 100644 --- a/database/seeders/OauthSettingSeeder.php +++ b/database/seeders/OauthSettingSeeder.php @@ -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,62 +13,53 @@ class OauthSettingSeeder extends Seeder */ public function run(): void { - $providers = collect([ - 'azure', - 'bitbucket', - 'github', - 'gitlab', - 'google', - 'authentik', - ]); + try { + $providers = collect([ + 'azure', + 'bitbucket', + 'github', + 'gitlab', + '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 - // Before authentik was a provider, providers started with 0 id + // 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 - $isOauthAuthentik = OauthSetting::where('provider', 'authentik')->exists(); - if ($isOauthSeeded) { - 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 { + $isOauthAuthentik = OauthSetting::where('provider', 'authentik')->exists(); + if (! $isOauthSeeded || $isOauthAuthentik) { foreach ($providers as $provider) { OauthSetting::updateOrCreate([ 'provider' => $provider, ]); } + + return; } - } else { - foreach ($providers as $provider) { - OauthSetting::updateOrCreate([ + + $allProviders = OauthSetting::all(); + $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, ]); } + + } catch (\Exception $e) { + Log::error($e->getMessage()); } } } diff --git a/docker/production/Dockerfile b/docker/production/Dockerfile index 09281a666..aaef29f9d 100644 --- a/docker/production/Dockerfile +++ b/docker/production/Dockerfile @@ -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 diff --git a/docker/production/entrypoint.d/99-debug-mode.sh b/docker/production/entrypoint.d/99-debug-mode.sh new file mode 100644 index 000000000..e0a181373 --- /dev/null +++ b/docker/production/entrypoint.d/99-debug-mode.sh @@ -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 diff --git a/resources/views/components/navbar.blade.php b/resources/views/components/navbar.blade.php index 7d343c645..9a75200b1 100644 --- a/resources/views/components/navbar.blade.php +++ b/resources/views/components/navbar.blade.php @@ -340,17 +340,19 @@ @endif - @if (isCloud() && isInstanceAdmin()) -
  • - - - - - Admin - -
  • + @if (isCloud() || isDev()) + @if (isInstanceAdmin() || session('impersonating')) +
  • + + + + + Admin + +
  • + @endif @endif
    @if (isInstanceAdmin() && !isCloud()) diff --git a/resources/views/livewire/admin/index.blade.php b/resources/views/livewire/admin/index.blade.php index 06914e1e4..7bf3c7c0c 100644 --- a/resources/views/livewire/admin/index.blade.php +++ b/resources/views/livewire/admin/index.blade.php @@ -1,7 +1,12 @@

    Admin Dashboard

    -

    Who am I now?

    -
    {{ auth()->user()->name }}
    +
    +

    Who am I now?

    + @if (session('impersonating')) + Go back to root + @endif +
    +
    {{ auth()->user()->name }} ({{ auth()->user()->email }})
    Search diff --git a/resources/views/livewire/project/application/general.blade.php b/resources/views/livewire/project/application/general.blade.php index 4812fd4ba..bdcde8deb 100644 --- a/resources/views/livewire/project/application/general.blade.php +++ b/resources/views/livewire/project/application/general.blade.php @@ -84,7 +84,7 @@ @@ -161,8 +161,7 @@
    Nixpacks will detect the required configuration automatically. - Framework + Framework Specific Docs
    @endif diff --git a/templates/compose/getoutline.yaml b/templates/compose/getoutline.yaml index ae8d26682..8c15d8499 100644 --- a/templates/compose/getoutline.yaml +++ b/templates/compose/getoutline.yaml @@ -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: diff --git a/versions.json b/versions.json index c5f41a4db..d00272987 100644 --- a/versions.json +++ b/versions.json @@ -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"