diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 8bbab0081..4aa0fc339 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -8,6 +8,7 @@ use App\Jobs\DatabaseBackupJob; use App\Jobs\DockerCleanupJob; use App\Jobs\InstanceAutoUpdateJob; use App\Jobs\ContainerStatusJob; +use App\Jobs\PullHelperImageJob; use App\Models\InstanceSettings; use App\Models\ScheduledDatabaseBackup; use App\Models\Server; @@ -19,20 +20,35 @@ class Kernel extends ConsoleKernel protected function schedule(Schedule $schedule): void { if (isDev()) { + // Instance Jobs $schedule->command('horizon:snapshot')->everyMinute(); $schedule->job(new CleanupInstanceStuffsJob)->everyMinute()->onOneServer(); + + // Server Jobs $this->check_scheduled_backups($schedule); $this->check_resources($schedule); $this->cleanup_servers($schedule); $this->check_scheduled_backups($schedule); + $this->pull_helper_image($schedule); } else { + // Instance Jobs $schedule->command('horizon:snapshot')->everyFiveMinutes(); $schedule->job(new CleanupInstanceStuffsJob)->everyTwoMinutes()->onOneServer(); $schedule->job(new CheckResaleLicenseJob)->hourly()->onOneServer(); + + // Server Jobs $this->instance_auto_update($schedule); $this->check_scheduled_backups($schedule); $this->check_resources($schedule); $this->cleanup_servers($schedule); + $this->pull_helper_image($schedule); + } + } + private function pull_helper_image($schedule) + { + $servers = Server::all()->where('settings.is_usable', true)->where('settings.is_reachable', true); + foreach ($servers as $server) { + $schedule->job(new PullHelperImageJob($server))->everyTenMinutes()->onOneServer(); } } private function cleanup_servers($schedule) diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index a2978e2ee..7c1d186ff 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -39,6 +39,10 @@ class Controller extends BaseController } else { $team = $user->teams()->first(); } + if (is_null(data_get($user, 'email_verified_at'))){ + $user->email_verified_at = now(); + $user->save(); + } Auth::login($user); session(['currentTeam' => $team]); return redirect()->route('dashboard'); diff --git a/app/Http/Middleware/DecideWhatToDoWithUser.php b/app/Http/Middleware/DecideWhatToDoWithUser.php index 3fb9dfea7..19a09125a 100644 --- a/app/Http/Middleware/DecideWhatToDoWithUser.php +++ b/app/Http/Middleware/DecideWhatToDoWithUser.php @@ -12,7 +12,7 @@ class DecideWhatToDoWithUser public function handle(Request $request, Closure $next): Response { if (!auth()->user() || !isCloud() || isInstanceAdmin()) { - if (!isCloud() && showBoarding() && !in_array($request->path(), allowedPathsForBoardingAccounts())) { + if (!isCloud() && showBoarding() && !in_array($request->path(), allowedPathsForBoardingAccounts())) { return redirect('boarding'); } return $next($request); diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php index 6017f1f1d..59d2a1e30 100644 --- a/app/Jobs/ApplicationDeploymentJob.php +++ b/app/Jobs/ApplicationDeploymentJob.php @@ -484,17 +484,16 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted private function prepare_builder_image() { - $pull = "--pull=always"; $helperImage = config('coolify.helper_image'); if ($this->dockerConfigFileExists === 'OK') { - $runCommand = "docker run {$pull} -d --network {$this->destination->network} -v /:/host --name {$this->deployment_uuid} --rm -v {$this->serverUserHomeDir}/.docker/config.json:/root/.docker/config.json:ro -v /var/run/docker.sock:/var/run/docker.sock {$helperImage}"; + $runCommand = "docker run -d --network {$this->destination->network} -v /:/host --name {$this->deployment_uuid} --rm -v {$this->serverUserHomeDir}/.docker/config.json:/root/.docker/config.json:ro -v /var/run/docker.sock:/var/run/docker.sock {$helperImage}"; } else { - $runCommand = "docker run {$pull} -d --network {$this->destination->network} -v /:/host --name {$this->deployment_uuid} --rm -v /var/run/docker.sock:/var/run/docker.sock {$helperImage}"; + $runCommand = "docker run -d --network {$this->destination->network} -v /:/host --name {$this->deployment_uuid} --rm -v /var/run/docker.sock:/var/run/docker.sock {$helperImage}"; } $this->execute_remote_command( [ - "echo -n 'Pulling helper image from $helperImage.'", + "echo -n 'Preparing container with helper image: $helperImage.'", ], [ $runCommand, @@ -519,7 +518,7 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted $this->generate_git_import_commands(); $this->execute_remote_command( [ - executeInDocker($this->deployment_uuid, "git ls-remote {$this->fullRepoUrl} {$this->branch}"), + executeInDocker($this->deployment_uuid, "GIT_SSH_COMMAND=\"ssh -o ConnectTimeout=30 -p {$this->customPort} -o Port={$this->customPort} -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null\" git ls-remote {$this->fullRepoUrl} {$this->branch}"), "hidden" => true, "save" => "git_commit_sha" ], @@ -676,10 +675,12 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted $volume_names = $this->generate_local_persistent_volumes_only_volume_names(); $environment_variables = $this->generate_environment_variables($ports); - $labels = generateLabelsApplication($this->application, $this->preview); if (data_get($this->application, 'custom_labels')) { - $labels = str($this->application->custom_labels)->explode(',')->toArray(); + $labels = collect(str($this->application->custom_labels)->explode(',')->toArray()); + } else { + $labels = collect(generateLabelsApplication($this->application, $this->preview)); } + $labels = $labels->merge(defaultLabels($this->application->id, $this->application->uuid, $this->pull_request_id))->toArray(); $docker_compose = [ 'version' => '3.8', 'services' => [ diff --git a/app/Jobs/PullHelperImageJob.php b/app/Jobs/PullHelperImageJob.php new file mode 100644 index 000000000..f06e9524d --- /dev/null +++ b/app/Jobs/PullHelperImageJob.php @@ -0,0 +1,45 @@ +server->uuid))->dontRelease()]; + } + + public function uniqueId(): string + { + return $this->server->uuid; + } + public function __construct(public Server $server) + { + } + public function handle(): void + { + try { + $helperImage = config('coolify.helper_image'); + ray("Pulling {$helperImage}"); + instant_remote_process(["docker pull -q {$helperImage}"], $this->server, false); + ray('PullHelperImageJob done'); + } catch (\Throwable $e) { + send_internal_notification('PullHelperImageJob failed with: ' . $e->getMessage()); + ray($e->getMessage()); + throw $e; + } + } +} diff --git a/bootstrap/helpers/docker.php b/bootstrap/helpers/docker.php index 179abecb9..a61bb177c 100644 --- a/bootstrap/helpers/docker.php +++ b/bootstrap/helpers/docker.php @@ -212,13 +212,11 @@ function generateLabelsApplication(Application $application, ?ApplicationPreview $onlyPort = $ports[0]; } $pull_request_id = data_get($preview, 'pull_request_id', 0); - // $container_name = generateApplicationContainerName($application, $pull_request_id); $appId = $application->id; if ($pull_request_id !== 0 && $pull_request_id !== null) { $appId = $appId . '-pr-' . $pull_request_id; } $labels = collect([]); - $labels = $labels->merge(defaultLabels($appId, $application->uuid, $pull_request_id)); if ($application->fqdn) { if ($pull_request_id !== 0) { $domains = Str::of(data_get($preview, 'fqdn'))->explode(','); diff --git a/bootstrap/helpers/subscriptions.php b/bootstrap/helpers/subscriptions.php index 130654db5..6707f8937 100644 --- a/bootstrap/helpers/subscriptions.php +++ b/bootstrap/helpers/subscriptions.php @@ -148,6 +148,8 @@ function allowedPathsForInvalidAccounts() { return [ 'logout', 'verify', + 'force-password-reset', + 'livewire/message/force-password-reset', 'livewire/message/verify-email', 'livewire/message/help' ]; diff --git a/config/sentry.php b/config/sentry.php index 9041a7606..826794a5a 100644 --- a/config/sentry.php +++ b/config/sentry.php @@ -7,7 +7,7 @@ return [ // 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.104', + 'release' => '4.0.0-beta.105', // When left empty or `null` the Laravel environment will be used 'environment' => config('app.env'), diff --git a/config/version.php b/config/version.php index 62ca33fbb..5bcfd4f1b 100644 --- a/config/version.php +++ b/config/version.php @@ -1,3 +1,3 @@