An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
wip: boarding
Andras Bacsaib39ca51d4152
diff --git a/.ssh/known_hosts b/.ssh/known_hostsnew file mode 100644index 0000000000..a59e3d0b43--- /dev/null+++ b/.ssh/known_hosts@@ -0,0 +1 @@+|1|TRkudHmvsBVekjyAfpo3EWrkQSs=|XdMLpIt2l32hhdSyWnDwMMlVBSI= ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIK/Ln1b72Lc5JtHRDiZd4lYyW7F5aVuJH42HdHXuYudTdiff --git a/app/Actions/Server/UpdateCoolify.php b/app/Actions/Server/UpdateCoolify.phpindex 60d0f9a73c..08740a8ed1 100644--- a/app/Actions/Server/UpdateCoolify.php+++ b/app/Actions/Server/UpdateCoolify.php@@ -17,9 +17,6 @@ class UpdateCoolify$settings = InstanceSettings::get();ray('Running InstanceAutoUpdateJob');$localhost_name = 'localhost';- if (is_dev()) {- $localhost_name = 'testing-local-docker-container';- }$this->server = Server::where('name', $localhost_name)->firstOrFail();$this->latest_version = get_latest_version_of_coolify();$this->current_version = config('version');diff --git a/app/Http/Controllers/ApplicationController.php b/app/Http/Controllers/ApplicationController.phpindex 9b87492e4c..aa2787de76 100644--- a/app/Http/Controllers/ApplicationController.php+++ b/app/Http/Controllers/ApplicationController.php@@ -12,7 +12,7 @@ class ApplicationController extends Controllerpublic function configuration(){- $project = auth()->user()->currentTeam()->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();+ $project = currentTeam()->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();if (!$project) {return redirect()->route('dashboard');}@@ -29,7 +29,7 @@ class ApplicationController extends Controllerpublic function deployments(){- $project = auth()->user()->currentTeam()->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();+ $project = currentTeam()->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();if (!$project) {return redirect()->route('dashboard');}@@ -49,7 +49,7 @@ class ApplicationController extends Controller{$deploymentUuid = request()->route('deployment_uuid');- $project = auth()->user()->currentTeam()->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();+ $project = currentTeam()->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();if (!$project) {return redirect()->route('dashboard');}diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.phpindex 84da5de2e4..d78e67505b 100644--- a/app/Http/Controllers/Controller.php+++ b/app/Http/Controllers/Controller.php@@ -58,7 +58,6 @@ class Controller extends BaseController$resources += $project->applications->count();$resources += $project->postgresqls->count();}-return view('dashboard', ['servers' => $servers->count(),'projects' => $projects->count(),@@ -66,10 +65,17 @@ class Controller extends BaseController's3s' => $s3s,]);}+ public function boarding() {+ if (currentTeam()->boarding || is_dev()) {+ return view('boarding');+ } else {+ return redirect()->route('dashboard');+ }+ }public function settings(){- if (is_instance_admin()) {+ if (isInstanceAdmin()) {$settings = InstanceSettings::get();$database = StandalonePostgresql::whereName('coolify-db')->first();if ($database) {@@ -89,7 +95,7 @@ class Controller extends BaseController{$invitations = [];if (auth()->user()->isAdminFromSession()) {- $invitations = TeamInvitation::whereTeamId(auth()->user()->currentTeam()->id)->get();+ $invitations = TeamInvitation::whereTeamId(currentTeam()->id)->get();}return view('team.show', ['invitations' => $invitations,@@ -116,7 +122,7 @@ class Controller extends BaseController{$invitations = [];if (auth()->user()->isAdminFromSession()) {- $invitations = TeamInvitation::whereTeamId(auth()->user()->currentTeam()->id)->get();+ $invitations = TeamInvitation::whereTeamId(currentTeam()->id)->get();}return view('team.members', ['invitations' => $invitations,diff --git a/app/Http/Controllers/DatabaseController.php b/app/Http/Controllers/DatabaseController.phpindex bb6baf5ecb..958d6d5abe 100644--- a/app/Http/Controllers/DatabaseController.php+++ b/app/Http/Controllers/DatabaseController.php@@ -11,7 +11,7 @@ class DatabaseController extends Controllerpublic function configuration(){- $project = auth()->user()->currentTeam()->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();+ $project = currentTeam()->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();if (!$project) {return redirect()->route('dashboard');}@@ -29,7 +29,7 @@ class DatabaseController extends Controllerpublic function executions(){$backup_uuid = request()->route('backup_uuid');- $project = auth()->user()->currentTeam()->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();+ $project = currentTeam()->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();if (!$project) {return redirect()->route('dashboard');}@@ -50,13 +50,13 @@ class DatabaseController extends Controller'database' => $database,'backup' => $backup,'executions' => $executions,- 's3s' => auth()->user()->currentTeam()->s3s,+ 's3s' => currentTeam()->s3s,]);}public function backups(){- $project = auth()->user()->currentTeam()->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();+ $project = currentTeam()->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();if (!$project) {return redirect()->route('dashboard');}@@ -70,7 +70,7 @@ class DatabaseController extends Controller}return view('project.database.backups.all', ['database' => $database,- 's3s' => auth()->user()->currentTeam()->s3s,+ 's3s' => currentTeam()->s3s,]);}}diff --git a/app/Http/Controllers/MagicController.php b/app/Http/Controllers/MagicController.phpindex 515bc14d1f..d7635fda07 100644--- a/app/Http/Controllers/MagicController.php+++ b/app/Http/Controllers/MagicController.php@@ -41,7 +41,7 @@ class MagicController extends Controller{$project = Project::firstOrCreate(['name' => request()->query('name') ?? generate_random_name()],- ['team_id' => auth()->user()->currentTeam()->id]+ ['team_id' => currentTeam()->id]);return response()->json(['project_uuid' => $project->uuid@@ -68,7 +68,7 @@ class MagicController extends Controller],);auth()->user()->teams()->attach($team, ['role' => 'admin']);- session(['currentTeam' => $team]);+ refreshSession();return redirect(request()->header('Referer'));}}diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.phpindex 2ad941e922..476d54437b 100644--- a/app/Http/Controllers/ProjectController.php+++ b/app/Http/Controllers/ProjectController.php@@ -18,7 +18,7 @@ class ProjectController extends Controllerpublic function edit(){$projectUuid = request()->route('project_uuid');- $teamId = auth()->user()->currentTeam()->id;+ $teamId = currentTeam()->id;$project = Project::where('team_id', $teamId)->where('uuid', $projectUuid)->first();if (!$project) {return redirect()->route('dashboard');@@ -29,7 +29,7 @@ class ProjectController extends Controllerpublic function show(){$projectUuid = request()->route('project_uuid');- $teamId = auth()->user()->currentTeam()->id;+ $teamId = currentTeam()->id;$project = Project::where('team_id', $teamId)->where('uuid', $projectUuid)->first();if (!$project) {@@ -44,7 +44,7 @@ class ProjectController extends Controller$type = request()->query('type');$destination_uuid = request()->query('destination');- $project = auth()->user()->currentTeam()->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();+ $project = currentTeam()->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();if (!$project) {return redirect()->route('dashboard');}@@ -67,7 +67,7 @@ class ProjectController extends Controllerpublic function resources(){- $project = auth()->user()->currentTeam()->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();+ $project = currentTeam()->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();if (!$project) {return redirect()->route('dashboard');}diff --git a/app/Http/Controllers/ServerController.php b/app/Http/Controllers/ServerController.phpindex 2c2a343636..54b8c7a8c1 100644--- a/app/Http/Controllers/ServerController.php+++ b/app/Http/Controllers/ServerController.php@@ -12,14 +12,14 @@ class ServerController extends Controllerpublic function new_server(){- if (!is_cloud() || is_instance_admin()) {+ if (!is_cloud() || isInstanceAdmin()) {return view('server.create', ['limit_reached' => false,'private_keys' => PrivateKey::ownedByCurrentTeam()->get(),]);}- $servers = auth()->user()->currentTeam()->servers->count();- $subscription = auth()->user()->currentTeam()?->subscription->type();+ $servers = currentTeam()->servers->count();+ $subscription = currentTeam()?->subscription->type();$your_limit = config('constants.limits.server')[strtolower($subscription)];$limit_reached = $servers >= $your_limit;diff --git a/app/Http/Kernel.php b/app/Http/Kernel.phpindex 57b5edfec8..eb93b6d356 100644--- a/app/Http/Kernel.php+++ b/app/Http/Kernel.php@@ -39,6 +39,7 @@ class Kernel extends HttpKernel\Illuminate\Routing\Middleware\SubstituteBindings::class,\App\Http\Middleware\CheckForcePasswordReset::class,\App\Http\Middleware\SubscriptionValid::class,+ \App\Http\Middleware\IsBoardingFlow::class,],diff --git a/app/Http/Livewire/Boarding.php b/app/Http/Livewire/Boarding.phpnew file mode 100644index 0000000000..47dd072ba3--- /dev/null+++ b/app/Http/Livewire/Boarding.php@@ -0,0 +1,147 @@+<?php++namespace App\Http\Livewire;++use App\Models\PrivateKey;+use App\Models\Project;+use App\Models\Server;+use Livewire\Component;++class Boarding extends Component+{++ public string $currentState = 'create-private-key';+ // public ?string $serverType = null;++ public ?string $privateKeyType = null;+ public ?string $privateKey = null;+ public ?string $privateKeyName = null;+ public ?string $privateKeyDescription = null;+ public ?PrivateKey $createdPrivateKey = null;++ public ?string $remoteServerName = null;+ public ?string $remoteServerDescription = null;+ public ?string $remoteServerHost = null;+ public ?int $remoteServerPort = 22;+ public ?string $remoteServerUser = 'root';+ public ?Server $createdServer = null;++ public function mount()+ {+ $this->privateKeyName = generate_random_name();+ $this->remoteServerName = generate_random_name();+ if (is_dev()) {+ $this->privateKey = '-----BEGIN OPENSSH PRIVATE KEY-----+b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW+QyNTUxOQAAACBbhpqHhqv6aI67Mj9abM3DVbmcfYhZAhC7ca4d9UCevAAAAJi/QySHv0Mk+hwAAAAtzc2gtZWQyNTUxOQAAACBbhpqHhqv6aI67Mj9abM3DVbmcfYhZAhC7ca4d9UCevA+AAAECBQw4jg1WRT2IGHMncCiZhURCts2s24HoDS0thHnnRKVuGmoeGq/pojrsyP1pszcNV+uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA==+-----END OPENSSH PRIVATE KEY-----';+ $this->privateKeyDescription = 'Created by Coolify';+ $this->remoteServerDescription = 'Created by Coolify';+ $this->remoteServerHost = 'coolify-testing-host';+ }+ }+ public function restartBoarding()+ {+ if ($this->createdServer) {+ $this->createdServer->delete();+ }+ if ($this->createdPrivateKey) {+ $this->createdPrivateKey->delete();+ }+ return redirect()->route('boarding');+ }+ public function skipBoarding()+ {+ currentTeam()->update([+ 'show_boarding' => false+ ]);+ refreshSession();+ return redirect()->route('dashboard');+ }+ public function setServer(string $type)+ {+ if ($type === 'localhost') {+ $this->currentState = 'create-project';+ } elseif ($type === 'remote') {+ $this->currentState = 'private-key';+ }+ }+ public function setPrivateKey(string $type)+ {+ $this->privateKeyType = $type;+ $this->currentState = 'create-private-key';+ }+ public function savePrivateKey()+ {+ $this->validate([+ 'privateKeyName' => 'required',+ 'privateKey' => 'required',+ ]);+ $this->currentState = 'create-server';+ }+ public function saveServer()+ {+ $this->validate([+ 'remoteServerName' => 'required',+ 'remoteServerHost' => 'required',+ 'remoteServerPort' => 'required',+ 'remoteServerUser' => 'required',+ ]);+ if ($this->privateKeyType === 'create') {+ $this->createNewPrivateKey();+ }+ $this->privateKey = formatPrivateKey($this->privateKey);+ $this->createdPrivateKey = PrivateKey::create([+ 'name' => $this->privateKeyName,+ 'description' => $this->privateKeyDescription,+ 'private_key' => $this->privateKey,+ 'team_id' => currentTeam()->id+ ]);+ $this->createdServer = Server::create([+ 'name' => $this->remoteServerName,+ 'ip' => $this->remoteServerHost,+ 'port' => $this->remoteServerPort,+ 'user' => $this->remoteServerUser,+ 'description' => $this->remoteServerDescription,+ 'private_key_id' => $this->createdPrivateKey->id,+ 'team_id' => currentTeam()->id+ ]);+ try {+ ['uptime' => $uptime, 'dockerVersion' => $dockerVersion] = validateServer($this->createdServer);+ if (!$uptime) {+ $this->createdServer->delete();+ $this->createdPrivateKey->delete();+ throw new \Exception('Server is not reachable.');+ } else {+ $this->createdServer->settings->update([+ 'is_reachable' => true,+ ]);+ $this->emit('success', 'Server is reachable.');+ }+ if ($dockerVersion) {+ $this->emit('error', 'Docker is not installed on the server.');+ $this->currentState = 'install-docker';+ return;+ }+ ray($uptime, $dockerVersion);+ } catch (\Exception $e) {+ return general_error_handler(customErrorMessage: "Server is not reachable. Reason: {$e->getMessage()}", that: $this);+ }+ }+ private function createNewPrivateKey()+ {+ $this->privateKeyName = generate_random_name();+ $this->privateKeyDescription = 'Created by Coolify';+ $this->privateKey = generateSSHKey();+ }+ public function createNewProject()+ {+ Project::create([+ 'name' => generate_random_name(),+ 'team_id' => currentTeam()->id+ ]);+ }+}diff --git a/app/Http/Livewire/Destination/New/StandaloneDocker.php b/app/Http/Livewire/Destination/New/StandaloneDocker.phpindex fa884ec373..f67180b693 100644--- a/app/Http/Livewire/Destination/New/StandaloneDocker.php+++ b/app/Http/Livewire/Destination/New/StandaloneDocker.php@@ -67,7 +67,7 @@ class StandaloneDocker extends Component'name' => $this->name,'network' => $this->network,'server_id' => $this->server_id,- 'team_id' => auth()->user()->currentTeam()->id+ 'team_id' => currentTeam()->id]);}$this->createNetworkAndAttachToProxy();diff --git a/app/Http/Livewire/Notifications/DiscordSettings.php b/app/Http/Livewire/Notifications/DiscordSettings.phpindex 03cac47536..f9de6d6625 100644--- a/app/Http/Livewire/Notifications/DiscordSettings.php+++ b/app/Http/Livewire/Notifications/DiscordSettings.php@@ -41,10 +41,9 @@ class DiscordSettings extends Componentpublic function saveModel(){- ray($this->model);$this->model->save();if (is_a($this->model, Team::class)) {- session(['currentTeam' => $this->model]);+ refreshSession();}$this->emit('success', 'Settings saved.');}diff --git a/app/Http/Livewire/Notifications/EmailSettings.php b/app/Http/Livewire/Notifications/EmailSettings.phpindex eceb4e88b3..a2887f9895 100644--- a/app/Http/Livewire/Notifications/EmailSettings.php+++ b/app/Http/Livewire/Notifications/EmailSettings.php@@ -59,7 +59,7 @@ class EmailSettings extends Component{$settings = InstanceSettings::get();if ($settings->smtp_enabled) {- $team = auth()->user()->currentTeam();+ $team = currentTeam();$team->update(['smtp_enabled' => $settings->smtp_enabled,'smtp_from_address' => $settings->smtp_from_address,@@ -74,7 +74,7 @@ class EmailSettings extends Component]);$this->decrypt();if (is_a($team, Team::class)) {- session(['currentTeam' => $team]);+ refreshSession();}$this->model = $team;$this->emit('success', 'Settings saved.');@@ -119,7 +119,7 @@ class EmailSettings extends Component$this->model->save();$this->decrypt();if (is_a($this->model, Team::class)) {- session(['currentTeam' => $this->model]);+ refreshSession();}$this->emit('success', 'Settings saved.');}diff --git a/app/Http/Livewire/PrivateKey/Change.php b/app/Http/Livewire/PrivateKey/Change.phpindex 91d42bd7a5..bd9332ca25 100644--- a/app/Http/Livewire/PrivateKey/Change.php+++ b/app/Http/Livewire/PrivateKey/Change.php@@ -26,7 +26,7 @@ class Change extends Componenttry {if ($this->private_key->isEmpty()) {$this->private_key->delete();- auth()->user()->currentTeam()->privateKeys = PrivateKey::where('team_id', auth()->user()->currentTeam()->id)->get();+ currentTeam()->privateKeys = PrivateKey::where('team_id', currentTeam()->id)->get();return redirect()->route('private-key.all');}$this->emit('error', 'This private key is in use and cannot be deleted. Please delete all servers, applications, and GitHub/GitLab apps that use this private key before deleting it.');@@ -38,10 +38,7 @@ class Change extends Componentpublic function changePrivateKey(){try {- $this->private_key->private_key = trim($this->private_key->private_key);- if (!str_ends_with($this->private_key->private_key, "\n")) {- $this->private_key->private_key .= "\n";- }+ $this->private_key->private_key = formatPrivateKey($this->private_key->private_key);$this->private_key->save();refresh_server_connection($this->private_key);} catch (\Exception $e) {diff --git a/app/Http/Livewire/PrivateKey/Create.php b/app/Http/Livewire/PrivateKey/Create.phpindex 82218f4a56..d8d3cc41a4 100644--- a/app/Http/Livewire/PrivateKey/Create.php+++ b/app/Http/Livewire/PrivateKey/Create.php@@ -32,7 +32,7 @@ class Create extends Component'name' => $this->name,'description' => $this->description,'private_key' => $this->value,- 'team_id' => auth()->user()->currentTeam()->id+ 'team_id' => currentTeam()->id]);if ($this->from === 'server') {return redirect()->route('server.create');diff --git a/app/Http/Livewire/Project/AddEmpty.php b/app/Http/Livewire/Project/AddEmpty.phpindex 1024bc66fa..fc20f9850f 100644--- a/app/Http/Livewire/Project/AddEmpty.php+++ b/app/Http/Livewire/Project/AddEmpty.php@@ -25,7 +25,7 @@ class AddEmpty extends Component$project = Project::create(['name' => $this->name,'description' => $this->description,- 'team_id' => auth()->user()->currentTeam()->id,+ 'team_id' => currentTeam()->id,]);return redirect()->route('project.show', $project->uuid);} catch (\Exception $e) {diff --git a/app/Http/Livewire/Project/Application/Source.php b/app/Http/Livewire/Project/Application/Source.phpindex 5affe9e45b..801d533aa4 100644--- a/app/Http/Livewire/Project/Application/Source.php+++ b/app/Http/Livewire/Project/Application/Source.php@@ -29,7 +29,7 @@ class Source extends Componentprivate function get_private_keys(){- $this->private_keys = PrivateKey::whereTeamId(auth()->user()->currentTeam()->id)->get()->reject(function ($key) {+ $this->private_keys = PrivateKey::whereTeamId(currentTeam()->id)->get()->reject(function ($key) {return $key->id == $this->application->private_key_id;});}diff --git a/app/Http/Livewire/Project/Database/CreateScheduledBackup.php b/app/Http/Livewire/Project/Database/CreateScheduledBackup.phpindex e3ea977359..9297f65f6b 100644--- a/app/Http/Livewire/Project/Database/CreateScheduledBackup.php+++ b/app/Http/Livewire/Project/Database/CreateScheduledBackup.php@@ -39,7 +39,7 @@ class CreateScheduledBackup extends Component's3_storage_id' => $this->s3_storage_id,'database_id' => $this->database->id,'database_type' => $this->database->getMorphClass(),- 'team_id' => auth()->user()->currentTeam()->id,+ 'team_id' => currentTeam()->id,]);$this->emit('refreshScheduledBackups');} catch (\Exception $e) {diff --git a/app/Http/Livewire/Project/New/EmptyProject.php b/app/Http/Livewire/Project/New/EmptyProject.phpindex e77ab983e2..9dba4338b5 100644--- a/app/Http/Livewire/Project/New/EmptyProject.php+++ b/app/Http/Livewire/Project/New/EmptyProject.php@@ -11,7 +11,7 @@ class EmptyProject extends Component{$project = Project::create(['name' => generate_random_name(),- 'team_id' => auth()->user()->currentTeam()->id,+ 'team_id' => currentTeam()->id,]);return redirect()->route('project.show', ['project_uuid' => $project->uuid, 'environment_name' => 'production']);}diff --git a/app/Http/Livewire/Project/New/GithubPrivateRepositoryDeployKey.php b/app/Http/Livewire/Project/New/GithubPrivateRepositoryDeployKey.phpindex a1f275f329..a2ccd5298a 100644--- a/app/Http/Livewire/Project/New/GithubPrivateRepositoryDeployKey.php+++ b/app/Http/Livewire/Project/New/GithubPrivateRepositoryDeployKey.php@@ -55,7 +55,7 @@ class GithubPrivateRepositoryDeployKey extends Component}$this->parameters = get_route_parameters();$this->query = request()->query();- $this->private_keys = PrivateKey::where('team_id', auth()->user()->currentTeam()->id)->where('id', '!=', 0)->get();+ $this->private_keys = PrivateKey::where('team_id', currentTeam()->id)->where('id', '!=', 0)->get();}public function instantSave()diff --git a/app/Http/Livewire/Server/Form.php b/app/Http/Livewire/Server/Form.phpindex 4dcebc101b..290c06dd7d 100644--- a/app/Http/Livewire/Server/Form.php+++ b/app/Http/Livewire/Server/Form.php@@ -42,7 +42,7 @@ class Form extends Componentpublic function installDocker(){- $activity = resolve(InstallDocker::class)($this->server, auth()->user()->currentTeam());+ $activity = resolve(InstallDocker::class)($this->server, currentTeam());$this->emit('newMonitorActivity', $activity->id);}diff --git a/app/Http/Livewire/Server/New/ByIp.php b/app/Http/Livewire/Server/New/ByIp.phpindex c4f340413c..e6813a55f5 100644--- a/app/Http/Livewire/Server/New/ByIp.php+++ b/app/Http/Livewire/Server/New/ByIp.php@@ -65,7 +65,7 @@ class ByIp extends Component'ip' => $this->ip,'user' => $this->user,'port' => $this->port,- 'team_id' => auth()->user()->currentTeam()->id,+ 'team_id' => currentTeam()->id,'private_key_id' => $this->private_key_id,]);$server->settings->is_part_of_swarm = $this->is_part_of_swarm;diff --git a/app/Http/Livewire/Settings/Backup.php b/app/Http/Livewire/Settings/Backup.phpindex fcb105fd46..263db027d3 100644--- a/app/Http/Livewire/Settings/Backup.php+++ b/app/Http/Livewire/Settings/Backup.php@@ -65,7 +65,7 @@ class Backup extends Component'frequency' => '0 0 * * *','database_id' => $this->database->id,'database_type' => 'App\Models\StandalonePostgresql',- 'team_id' => auth()->user()->currentTeam()->id,+ 'team_id' => currentTeam()->id,]);$this->database->refresh();$this->backup->refresh();diff --git a/app/Http/Livewire/Source/Github/Create.php b/app/Http/Livewire/Source/Github/Create.phpindex 862964c45c..4d6f8b26b6 100644--- a/app/Http/Livewire/Source/Github/Create.php+++ b/app/Http/Livewire/Source/Github/Create.php@@ -40,7 +40,7 @@ class Create extends Component'custom_user' => $this->custom_user,'custom_port' => $this->custom_port,'is_system_wide' => $this->is_system_wide,- 'team_id' => auth()->user()->currentTeam()->id,+ 'team_id' => currentTeam()->id,]);redirect()->route('source.github.show', ['github_app_uuid' => $github_app->uuid]);} catch (\Exception $e) {diff --git a/app/Http/Livewire/Subscription/Actions.php b/app/Http/Livewire/Subscription/Actions.phpindex 588a0521cd..6c74880b7e 100644--- a/app/Http/Livewire/Subscription/Actions.php+++ b/app/Http/Livewire/Subscription/Actions.php@@ -10,7 +10,7 @@ class Actions extends Componentpublic function cancel(){try {- $subscription_id = auth()->user()->currentTeam()->subscription->lemon_subscription_id;+ $subscription_id = currentTeam()->subscription->lemon_subscription_id;if (!$subscription_id) {throw new \Exception('No subscription found');}@@ -37,7 +37,7 @@ class Actions extends Componentpublic function resume(){try {- $subscription_id = auth()->user()->currentTeam()->subscription->lemon_subscription_id;+ $subscription_id = currentTeam()->subscription->lemon_subscription_id;if (!$subscription_id) {throw new \Exception('No subscription found');}diff --git a/app/Http/Livewire/Team/Create.php b/app/Http/Livewire/Team/Create.phpindex 6c1c715808..bd2c243134 100644--- a/app/Http/Livewire/Team/Create.php+++ b/app/Http/Livewire/Team/Create.php@@ -29,7 +29,7 @@ class Create extends Component'personal_team' => false,]);auth()->user()->teams()->attach($team, ['role' => 'admin']);- session(['currentTeam' => $team]);+ refreshSession();return redirect()->route('team.show');} catch (\Throwable $th) {return general_error_handler($th, $this);diff --git a/app/Http/Livewire/Team/Delete.php b/app/Http/Livewire/Team/Delete.phpindex d14e82ccc6..5e206704b8 100644--- a/app/Http/Livewire/Team/Delete.php+++ b/app/Http/Livewire/Team/Delete.php@@ -9,7 +9,7 @@ class Delete extends Component{public function delete(){- $currentTeam = auth()->user()->currentTeam();+ $currentTeam = currentTeam();$currentTeam->delete();$team = auth()->user()->teams()->first();@@ -24,7 +24,7 @@ class Delete extends Component}});- session(['currentTeam' => $team]);+ refreshSession();return redirect()->route('team.show');}}diff --git a/app/Http/Livewire/Team/Form.php b/app/Http/Livewire/Team/Form.phpindex eedd60c830..caa6d2c9ea 100644--- a/app/Http/Livewire/Team/Form.php+++ b/app/Http/Livewire/Team/Form.php@@ -19,7 +19,7 @@ class Form extends Componentpublic function mount(){- $this->team = auth()->user()->currentTeam();+ $this->team = currentTeam();}public function submit()@@ -27,7 +27,7 @@ class Form extends Component$this->validate();try {$this->team->save();- session(['currentTeam' => $this->team]);+ refreshSession();$this->emit('reloadWindow');} catch (\Throwable $th) {return general_error_handler($th, $this);diff --git a/app/Http/Livewire/Team/Invitations.php b/app/Http/Livewire/Team/Invitations.phpindex ba0b654aa3..ba6c1e91fd 100644--- a/app/Http/Livewire/Team/Invitations.php+++ b/app/Http/Livewire/Team/Invitations.php@@ -18,6 +18,6 @@ class Invitations extends Componentpublic function refreshInvitations(){- $this->invitations = TeamInvitation::whereTeamId(auth()->user()->currentTeam()->id)->get();+ $this->invitations = TeamInvitation::whereTeamId(currentTeam()->id)->get();}}diff --git a/app/Http/Livewire/Team/InviteLink.php b/app/Http/Livewire/Team/InviteLink.phpindex ddbe75182b..aaf22f0e8b 100644--- a/app/Http/Livewire/Team/InviteLink.php+++ b/app/Http/Livewire/Team/InviteLink.php@@ -35,9 +35,9 @@ class InviteLink extends Componentreturn general_error_handler(that: $this, customErrorMessage: "$this->email must be registered first (or activate transactional emails to invite via email).");}- $member_emails = auth()->user()->currentTeam()->members()->get()->pluck('email');+ $member_emails = currentTeam()->members()->get()->pluck('email');if ($member_emails->contains($this->email)) {- return general_error_handler(that: $this, customErrorMessage: "$this->email is already a member of " . auth()->user()->currentTeam()->name . ".");+ return general_error_handler(that: $this, customErrorMessage: "$this->email is already a member of " . currentTeam()->name . ".");}$invitation = TeamInvitation::whereEmail($this->email);@@ -53,7 +53,7 @@ class InviteLink extends Component}TeamInvitation::firstOrCreate([- 'team_id' => auth()->user()->currentTeam()->id,+ 'team_id' => currentTeam()->id,'uuid' => $uuid,'email' => $this->email,'role' => $this->role,diff --git a/app/Http/Livewire/Team/Member.php b/app/Http/Livewire/Team/Member.phpindex 237d388185..df8fcd7af5 100644--- a/app/Http/Livewire/Team/Member.php+++ b/app/Http/Livewire/Team/Member.php@@ -11,19 +11,19 @@ class Member extends Componentpublic function makeAdmin(){- $this->member->teams()->updateExistingPivot(auth()->user()->currentTeam()->id, ['role' => 'admin']);+ $this->member->teams()->updateExistingPivot(currentTeam()->id, ['role' => 'admin']);$this->emit('reloadWindow');}public function makeReadonly(){- $this->member->teams()->updateExistingPivot(auth()->user()->currentTeam()->id, ['role' => 'member']);+ $this->member->teams()->updateExistingPivot(currentTeam()->id, ['role' => 'member']);$this->emit('reloadWindow');}public function remove(){- $this->member->teams()->detach(auth()->user()->currentTeam());+ $this->member->teams()->detach(currentTeam());$this->emit('reloadWindow');}}diff --git a/app/Http/Livewire/Team/Storage/Create.php b/app/Http/Livewire/Team/Storage/Create.phpindex ed7d277fbc..52ce3779d5 100644--- a/app/Http/Livewire/Team/Storage/Create.php+++ b/app/Http/Livewire/Team/Storage/Create.php@@ -62,7 +62,7 @@ class Create extends Component} else {$this->storage->endpoint = $this->endpoint;}- $this->storage->team_id = auth()->user()->currentTeam()->id;+ $this->storage->team_id = currentTeam()->id;$this->storage->testConnection();$this->emit('success', 'Connection is working. Tested with "ListObjectsV2" action.');$this->storage->save();diff --git a/app/Http/Middleware/IsBoardingFlow.php b/app/Http/Middleware/IsBoardingFlow.phpnew file mode 100644index 0000000000..e13e71f311--- /dev/null+++ b/app/Http/Middleware/IsBoardingFlow.php@@ -0,0 +1,28 @@+<?php++namespace App\Http\Middleware;++use Closure;+use Illuminate\Http\Request;+use Symfony\Component\HttpFoundation\Response;++class IsBoardingFlow+{+ /**+ * Handle an incoming request.+ *+ * @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next+ */+ public function handle(Request $request, Closure $next): Response+ {+ $allowed_paths = [+ 'subscription',+ 'boarding',+ 'livewire/message/boarding'+ ];+ if (showBoarding() && !in_array($request->path(), $allowed_paths)) {+ return redirect('boarding');+ }+ return $next($request);+ }+}diff --git a/app/Http/Middleware/SubscriptionValid.php b/app/Http/Middleware/SubscriptionValid.phpindex f84e6eedeb..01bd7a0e57 100644--- a/app/Http/Middleware/SubscriptionValid.php+++ b/app/Http/Middleware/SubscriptionValid.php@@ -17,8 +17,7 @@ class SubscriptionValidreturn $next($request);}}- $is_instance_admin = is_instance_admin();- if ($is_instance_admin) {+ if (isInstanceAdmin()) {return $next($request);}diff --git a/app/Models/EnvironmentVariable.php b/app/Models/EnvironmentVariable.phpindex bb4a5ca474..62a08c87f7 100644--- a/app/Models/EnvironmentVariable.php+++ b/app/Models/EnvironmentVariable.php@@ -41,7 +41,7 @@ class EnvironmentVariable extends Modelprivate function get_environment_variables(string $environment_variable): string|null{- // $team_id = auth()->user()->currentTeam()->id;+ // $team_id = currentTeam()->id;if (str_contains(trim($environment_variable), '{{') && str_contains(trim($environment_variable), '}}')) {$environment_variable = preg_replace('/\s+/', '', $environment_variable);$environment_variable = str_replace('{{', '', $environment_variable);diff --git a/app/Models/GithubApp.php b/app/Models/GithubApp.phpindex 74462e8d72..c4cd3568dd 100644--- a/app/Models/GithubApp.php+++ b/app/Models/GithubApp.php@@ -19,12 +19,12 @@ class GithubApp extends BaseModelstatic public function public(){- return GithubApp::whereTeamId(auth()->user()->currentTeam()->id)->whereisPublic(true)->whereNotNull('app_id')->get();+ return GithubApp::whereTeamId(currentTeam()->id)->whereisPublic(true)->whereNotNull('app_id')->get();}static public function private(){- return GithubApp::whereTeamId(auth()->user()->currentTeam()->id)->whereisPublic(false)->whereNotNull('app_id')->get();+ return GithubApp::whereTeamId(currentTeam()->id)->whereisPublic(false)->whereNotNull('app_id')->get();}protected static function booted(): voiddiff --git a/app/Models/PrivateKey.php b/app/Models/PrivateKey.phpindex 4d59e9ca8a..d4fd0bfa21 100644--- a/app/Models/PrivateKey.php+++ b/app/Models/PrivateKey.php@@ -16,7 +16,7 @@ class PrivateKey extends BaseModelstatic public function ownedByCurrentTeam(array $select = ['*']){$selectArray = collect($select)->concat(['id']);- return PrivateKey::whereTeamId(auth()->user()->currentTeam()->id)->select($selectArray->all());+ return PrivateKey::whereTeamId(currentTeam()->id)->select($selectArray->all());}public function isEmpty()diff --git a/app/Models/Project.php b/app/Models/Project.phpindex a50dde167d..9bcd2a0fe5 100644--- a/app/Models/Project.php+++ b/app/Models/Project.php@@ -4,16 +4,11 @@ namespace App\Models;class Project extends BaseModel{- protected $fillable = [- 'name',- 'description',- 'team_id',- 'project_id'- ];+ protected $guarded = [];static public function ownedByCurrentTeam(){- return Project::whereTeamId(auth()->user()->currentTeam()->id)->orderBy('name');+ return Project::whereTeamId(currentTeam()->id)->orderBy('name');}protected static function booted()diff --git a/app/Models/S3Storage.php b/app/Models/S3Storage.phpindex 5cd2f13183..cbcdb97a9a 100644--- a/app/Models/S3Storage.php+++ b/app/Models/S3Storage.php@@ -17,7 +17,7 @@ class S3Storage extends BaseModelstatic public function ownedByCurrentTeam(array $select = ['*']){$selectArray = collect($select)->concat(['id']);- return S3Storage::whereTeamId(auth()->user()->currentTeam()->id)->select($selectArray->all())->orderBy('name');+ return S3Storage::whereTeamId(currentTeam()->id)->select($selectArray->all())->orderBy('name');}public function awsUrl()diff --git a/app/Models/Server.php b/app/Models/Server.phpindex 1d8ea0f77e..d14d5f974a 100644--- a/app/Models/Server.php+++ b/app/Models/Server.php@@ -33,7 +33,7 @@ class Server extends BaseModelstatic public function ownedByCurrentTeam(array $select = ['*']){- $teamId = auth()->user()->currentTeam()->id;+ $teamId = currentTeam()->id;$selectArray = collect($select)->concat(['id']);return Server::whereTeamId($teamId)->with('settings')->select($selectArray->all())->orderBy('name');}diff --git a/app/Models/User.php b/app/Models/User.phpindex b048ef9e67..8cd5b0a569 100644--- a/app/Models/User.php+++ b/app/Models/User.php@@ -22,6 +22,7 @@ class User extends Authenticatable implements SendsEmailprotected $casts = ['email_verified_at' => 'datetime','force_password_reset' => 'boolean',+ 'show_boarding' => 'boolean',];protected static function boot()@@ -31,6 +32,7 @@ class User extends Authenticatable implements SendsEmail$team = ['name' => $user->name . "'s Team",'personal_team' => true,+ 'show_boarding' => true,];if ($user->id === 0) {$team['id'] = 0;@@ -102,7 +104,7 @@ class User extends Authenticatable implements SendsEmailpublic function otherTeams(){- $team_id = auth()->user()->currentTeam()->id;+ $team_id = currentTeam()->id;return auth()->user()->teams->filter(function ($team) use ($team_id) {return $team->id != $team_id;});@@ -113,13 +115,6 @@ class User extends Authenticatable implements SendsEmailif ($this->teams()->where('team_id', 0)->first()) {return 'admin';}- return $this->teams()->where('team_id', auth()->user()->currentTeam()->id)->first()->pivot->role;- }-- public function resources()- {- $team_id = auth()->user()->currentTeam()->id;- $data = Application::where('team_id', $team_id)->get();- return $data;+ return $this->teams()->where('team_id', currentTeam()->id)->first()->pivot->role;}}diff --git a/bootstrap/helpers/remoteProcess.php b/bootstrap/helpers/remoteProcess.phpindex ecc679b3ff..86e11bcf32 100644--- a/bootstrap/helpers/remoteProcess.php+++ b/bootstrap/helpers/remoteProcess.php@@ -66,8 +66,6 @@ function get_private_key_for_server(Server $server)function save_private_key_for_server(Server $server){if (data_get($server, 'privateKey.private_key') === null) {- $server->settings->is_reachable = false;- $server->settings->save();throw new \Exception("Server {$server->name} does not have a private key");}$temp_file = "id.root@{$server->ip}";@@ -159,8 +157,8 @@ function refresh_server_connection(PrivateKey $private_key)// Delete the old ssh mux file to force a new one to be createdStorage::disk('ssh-mux')->delete($server->muxFilename());// check if user is authenticated- if (auth()?->user()?->currentTeam()->id) {- auth()->user()->currentTeam()->privateKeys = PrivateKey::where('team_id', auth()->user()->currentTeam()->id)->get();+ if (currentTeam()->id) {+ currentTeam()->privateKeys = PrivateKey::where('team_id', currentTeam()->id)->get();}}}diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.phpindex 4b470cb480..d025222457 100644--- a/bootstrap/helpers/shared.php+++ b/bootstrap/helpers/shared.php@@ -14,6 +14,7 @@ use Illuminate\Support\Str;use Nubs\RandomNameGenerator\All;use Poliander\Cron\CronExpression;use Visus\Cuid2\Cuid2;+use phpseclib3\Crypt\RSA;function application_configuration_dir(): string{@@ -35,11 +36,25 @@ function generate_readme_file(string $name, string $updated_at): stringreturn "Resource name: $name\nLatest Deployment Date: $updated_at";}-function is_instance_admin()+function isInstanceAdmin(){- return auth()->user()?->isInstanceAdmin();+ return auth()?->user()?->isInstanceAdmin() ?? false;}+function currentTeam()+{+ return auth()?->user()?->currentTeam() ?? null;+}++function showBoarding(): bool+{+ return currentTeam()->show_boarding ?? false;+}+function refreshSession(): void+{+ $team = currentTeam();+ session(['currentTeam' => $team]);+}function general_error_handler(Throwable | null $err = null, $that = null, $isJson = false, $customErrorMessage = null): mixed{try {@@ -97,7 +112,21 @@ function generate_random_name(): string$cuid = new Cuid2(7);return Str::kebab("{$generator->getName()}-$cuid");}-+function generateSSHKey()+{+ $key = RSA::createKey();+ return [+ 'private' => $key->toString('PKCS1'),+ 'public' => $key->getPublicKey()->toString('OpenSSH',['comment' => 'coolify-generated-ssh-key'])+ ];+}+function formatPrivateKey(string $privateKey) {+ $privateKey = trim($privateKey);+ if (!str_ends_with($privateKey, "\n")) {+ $privateKey .= "\n";+ }+ return $privateKey;+}function generate_application_name(string $git_repository, string $git_branch): string{$cuid = new Cuid2(7);diff --git a/bootstrap/helpers/subscriptions.php b/bootstrap/helpers/subscriptions.phpindex 90d0947ad2..5cb17d588c 100644--- a/bootstrap/helpers/subscriptions.php+++ b/bootstrap/helpers/subscriptions.php@@ -9,7 +9,7 @@ function getSubscriptionLink($type)return null;}$user_id = auth()->user()->id;- $team_id = auth()->user()->currentTeam()->id ?? null;+ $team_id = currentTeam()->id ?? null;$email = auth()->user()->email ?? null;$name = auth()->user()->name ?? null;$url = "https://store.coollabs.io/checkout/buy/$checkout_id?";@@ -30,27 +30,27 @@ function getSubscriptionLink($type)function getPaymentLink(){- return auth()->user()->currentTeam()->subscription->lemon_update_payment_menthod_url;+ return currentTeam()->subscription->lemon_update_payment_menthod_url;}function getRenewDate(){- return Carbon::parse(auth()->user()->currentTeam()->subscription->lemon_renews_at)->format('Y-M-d H:i:s');+ return Carbon::parse(currentTeam()->subscription->lemon_renews_at)->format('Y-M-d H:i:s');}function getEndDate(){- return Carbon::parse(auth()->user()->currentTeam()->subscription->lemon_renews_at)->format('Y-M-d H:i:s');+ return Carbon::parse(currentTeam()->subscription->lemon_renews_at)->format('Y-M-d H:i:s');}function is_subscription_active(){- $team = auth()->user()?->currentTeam();+ $team = currentTeam();if (!$team) {return false;}- if (is_instance_admin()) {+ if (isInstanceAdmin()) {return true;}$subscription = $team?->subscription;@@ -64,11 +64,11 @@ function is_subscription_active()}function is_subscription_in_grace_period(){- $team = auth()->user()?->currentTeam();+ $team = currentTeam();if (!$team) {return false;}- if (is_instance_admin()) {+ if (isInstanceAdmin()) {return true;}$subscription = $team?->subscription;diff --git a/composer.json b/composer.jsonindex c43f5d09c1..fd8a5eb010 100644--- a/composer.json+++ b/composer.json@@ -23,6 +23,7 @@"livewire/livewire": "^v2.12.3","masmerise/livewire-toaster": "^1.2","nubs/random-name-generator": "^2.2",+ "phpseclib/phpseclib": "~3.0","poliander/cron": "^3.0","resend/resend-laravel": "^0.5.0","sentry/sentry-laravel": "^3.4",diff --git a/composer.lock b/composer.lockindex a64169d6ef..cf0183f12d 100644--- a/composer.lock+++ b/composer.lock@@ -4,7 +4,7 @@"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies","This file is @generated automatically"],- "content-hash": "15eb89e93c667bb63f48ef548ed38bed",+ "content-hash": "a4143cdb58c02a0490f9aa03d05b8e9a","packages": [{"name": "aws/aws-crt-php",@@ -3875,6 +3875,56 @@},"time": "2022-06-14T06:56:20+00:00"},+ {+ "name": "paragonie/random_compat",+ "version": "v9.99.100",+ "source": {+ "type": "git",+ "url": "https://github.com/paragonie/random_compat.git",+ "reference": "996434e5492cb4c3edcb9168db6fbb1359ef965a"+ },+ "dist": {+ "type": "zip",+ "url": "https://api.github.com/repos/paragonie/random_compat/zipball/996434e5492cb4c3edcb9168db6fbb1359ef965a",+ "reference": "996434e5492cb4c3edcb9168db6fbb1359ef965a",+ "shasum": ""+ },+ "require": {+ "php": ">= 7"+ },+ "require-dev": {+ "phpunit/phpunit": "4.*|5.*",+ "vimeo/psalm": "^1"+ },+ "suggest": {+ "ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes."+ },+ "type": "library",+ "notification-url": "https://packagist.org/downloads/",+ "license": [+ "MIT"+ ],+ "authors": [+ {+ "name": "Paragon Initiative Enterprises",+ "email": "[email protected]",+ "homepage": "https://paragonie.com"+ }+ ],+ "description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7",+ "keywords": [+ "csprng",+ "polyfill",+ "pseudorandom",+ "random"+ ],+ "support": {+ "email": "[email protected]",+ "issues": "https://github.com/paragonie/random_compat/issues",+ "source": "https://github.com/paragonie/random_compat"+ },+ "time": "2020-10-15T08:29:30+00:00"+ },{"name": "php-http/client-common","version": "2.7.0",@@ -4446,6 +4496,116 @@],"time": "2023-02-25T19:38:58+00:00"},+ {+ "name": "phpseclib/phpseclib",+ "version": "3.0.21",+ "source": {+ "type": "git",+ "url": "https://github.com/phpseclib/phpseclib.git",+ "reference": "4580645d3fc05c189024eb3b834c6c1e4f0f30a1"+ },+ "dist": {+ "type": "zip",+ "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/4580645d3fc05c189024eb3b834c6c1e4f0f30a1",+ "reference": "4580645d3fc05c189024eb3b834c6c1e4f0f30a1",+ "shasum": ""+ },+ "require": {+ "paragonie/constant_time_encoding": "^1|^2",+ "paragonie/random_compat": "^1.4|^2.0|^9.99.99",+ "php": ">=5.6.1"+ },+ "require-dev": {+ "phpunit/phpunit": "*"+ },+ "suggest": {+ "ext-dom": "Install the DOM extension to load XML formatted public keys.",+ "ext-gmp": "Install the GMP (GNU Multiple Precision) extension in order to speed up arbitrary precision integer arithmetic operations.",+ "ext-libsodium": "SSH2/SFTP can make use of some algorithms provided by the libsodium-php extension.",+ "ext-mcrypt": "Install the Mcrypt extension in order to speed up a few other cryptographic operations.",+ "ext-openssl": "Install the OpenSSL extension in order to speed up a wide variety of cryptographic operations."+ },+ "type": "library",+ "autoload": {+ "files": [+ "phpseclib/bootstrap.php"+ ],+ "psr-4": {+ "phpseclib3\\": "phpseclib/"+ }+ },+ "notification-url": "https://packagist.org/downloads/",+ "license": [+ "MIT"+ ],+ "authors": [+ {+ "name": "Jim Wigginton",+ "email": "[email protected]",+ "role": "Lead Developer"+ },+ {+ "name": "Patrick Monnerat",+ "email": "[email protected]",+ "role": "Developer"+ },+ {+ "name": "Andreas Fischer",+ "email": "[email protected]",+ "role": "Developer"+ },+ {+ "name": "Hans-Jürgen Petrich",+ "email": "[email protected]",+ "role": "Developer"+ },+ {+ "name": "Graham Campbell",+ "email": "[email protected]",+ "role": "Developer"+ }+ ],+ "description": "PHP Secure Communications Library - Pure-PHP implementations of RSA, AES, SSH2, SFTP, X.509 etc.",+ "homepage": "http://phpseclib.sourceforge.net",+ "keywords": [+ "BigInteger",+ "aes",+ "asn.1",+ "asn1",+ "blowfish",+ "crypto",+ "cryptography",+ "encryption",+ "rsa",+ "security",+ "sftp",+ "signature",+ "signing",+ "ssh",+ "twofish",+ "x.509",+ "x509"+ ],+ "support": {+ "issues": "https://github.com/phpseclib/phpseclib/issues",+ "source": "https://github.com/phpseclib/phpseclib/tree/3.0.21"+ },+ "funding": [+ {+ "url": "https://github.com/terrafrost",+ "type": "github"+ },+ {+ "url": "https://www.patreon.com/phpseclib",+ "type": "patreon"+ },+ {+ "url": "https://tidelift.com/funding/github/packagist/phpseclib/phpseclib",+ "type": "tidelift"+ }+ ],+ "time": "2023-07-09T15:24:48+00:00"+ },{"name": "phpstan/phpdoc-parser","version": "1.23.1",diff --git a/database/migrations/2023_08_22_071048_add_boarding_to_teams.php b/database/migrations/2023_08_22_071048_add_boarding_to_teams.phpnew file mode 100644index 0000000000..0fe2062e38--- /dev/null+++ b/database/migrations/2023_08_22_071048_add_boarding_to_teams.php@@ -0,0 +1,28 @@+<?php++use Illuminate\Database\Migrations\Migration;+use Illuminate\Database\Schema\Blueprint;+use Illuminate\Support\Facades\Schema;++return new class extends Migration+{+ /**+ * Run the migrations.+ */+ public function up(): void+ {+ Schema::table('teams', function (Blueprint $table) {+ $table->boolean('show_boarding')->default(false);+ });+ }++ /**+ * Reverse the migrations.+ */+ public function down(): void+ {+ Schema::table('teams', function (Blueprint $table) {+ $table->dropColumn('show_boarding');+ });+ }+};diff --git a/database/seeders/ServerSeeder.php b/database/seeders/ServerSeeder.phpindex 77a4516e5e..f201862f08 100644--- a/database/seeders/ServerSeeder.php+++ b/database/seeders/ServerSeeder.php@@ -11,8 +11,8 @@ class ServerSeeder extends Seeder{Server::create(['id' => 0,- 'name' => "testing-local-docker-container",- 'description' => "This is a test docker container",+ 'name' => "localhost",+ 'description' => "This is a test docker container in development mode",'ip' => "coolify-testing-host",'team_id' => 0,'private_key_id' => 0,diff --git a/package.json b/package.jsonindex ed81d6a26a..81e0dd5a89 100644--- a/package.json+++ b/package.json@@ -1,5 +1,6 @@{"private": true,+ "type": "module","scripts": {"dev": "vite","build": "vite build"@@ -20,4 +21,4 @@"daisyui": "3.2.1","tailwindcss-scrollbar": "0.1.0"}-}\ No newline at end of file+}diff --git a/postcss.config.js b/postcss.config.cjssimilarity index 100%rename from postcss.config.jsrename to postcss.config.cjsdiff --git a/resources/css/app.css b/resources/css/app.cssindex b5f58fc743..2e0f079ee9 100644--- a/resources/css/app.css+++ b/resources/css/app.css@@ -53,7 +53,7 @@ a {@apply text-white;}.box {- @apply flex items-center justify-center p-2 transition-colors rounded min-h-12 bg-coolgray-200 hover:bg-coollabs-100 hover:text-white hover:no-underline;+ @apply flex items-center justify-center p-2 transition-colors rounded cursor-pointer min-h-12 bg-coolgray-200 hover:bg-coollabs-100 hover:text-white hover:no-underline;}.lds-heart {diff --git a/resources/js/components/MagicBar.vue b/resources/js/components/MagicBar.vueindex f0203b8854..a0b08c2831 100644--- a/resources/js/components/MagicBar.vue+++ b/resources/js/components/MagicBar.vue@@ -53,12 +53,12 @@<span v-if="search"><span class="capitalize ">{{sequenceState.sequence[sequenceState.currentActionIndex] }}</span> namewill be:- <span class="text-warning">{{ search- }}</span></span>+ <x-highlighted text="{{ search }}" />+ </span><span v-else><span class="capitalize ">{{sequenceState.sequence[sequenceState.currentActionIndex] }}</span> namewill be:- <span class="text-warning">randomly generated (type to change)</span>+ <x-highlighted text="randomly generated (type to change)" /></span></span></li>diff --git a/resources/views/boarding.blade.php b/resources/views/boarding.blade.phpnew file mode 100644index 0000000000..d089e0650e--- /dev/null+++ b/resources/views/boarding.blade.php@@ -0,0 +1,3 @@+<x-layout-simple>+ <livewire:boarding />+</x-layout-simple>diff --git a/resources/views/components/boarding-step.blade.php b/resources/views/components/boarding-step.blade.phpnew file mode 100644index 0000000000..4776f33652--- /dev/null+++ b/resources/views/components/boarding-step.blade.php@@ -0,0 +1,25 @@+<div class="grid grid-cols-1 gap-4 md:grid-cols-3">+ <div class="box-border col-span-2 min-w-[24rem]">+ <h1 class="text-5xl font-bold">{{$title}}</h1>+ <div class="py-6 ">+ @isset($question)+ <p class="text-base">+ {{$question}}+ </p>+ @endisset+ </div>+ @if($actions)+ <div class="flex flex-col gap-4 md:flex-row">+ {{$actions}}+ </div>+ @endif+ </div>+ @if($explanation)+ <div class="col-span-1">+ <h1 class="pb-8 font-bold">Explanation</h1>+ <div class="space-y-4">+ {{$explanation}}+ </div>+ </div>+ @endif+</div>diff --git a/resources/views/components/forms/input.blade.php b/resources/views/components/forms/input.blade.phpindex a123662389..2abc8a91eb 100644--- a/resources/views/components/forms/input.blade.php+++ b/resources/views/components/forms/input.blade.php@@ -2,7 +2,7 @@@if ($label)<label for="small-input" class="flex items-center gap-1 mb-1 text-sm font-medium">{{ $label }}@if ($required)- <span class="text-warning">*</span>+ <x-highlighted text="*" />@endif@if ($helper)<x-helper :helper="$helper" />diff --git a/resources/views/components/forms/select.blade.php b/resources/views/components/forms/select.blade.phpindex ec2e6e5c81..10dc579284 100644--- a/resources/views/components/forms/select.blade.php+++ b/resources/views/components/forms/select.blade.php@@ -2,7 +2,7 @@@if ($label)<label for="small-input" class="flex items-center gap-1 mb-1 text-sm font-medium">{{ $label }}@if ($required)- <span class="text-warning">*</span>+ <x-highlighted text="*" />@endif@if ($helper)<x-helper :helper="$helper" />diff --git a/resources/views/components/forms/textarea.blade.php b/resources/views/components/forms/textarea.blade.phpindex d0deadaf22..f00a0e1d74 100644--- a/resources/views/components/forms/textarea.blade.php+++ b/resources/views/components/forms/textarea.blade.php@@ -1,14 +1,14 @@<div class="form-control">@if ($label)- <label class="label">- <span class="label-text">+ <label class="flex items-center gap-1 mb-1 text-sm font-medium">+ <span>@if ($label){{ $label }}@else{{ $id }}@endif@if ($required)- <span class="text-warning">*</span>+ <x-highlighted text="*" />@endif@if ($helper)<div class="group">diff --git a/resources/views/components/highlighted.blade.php b/resources/views/components/highlighted.blade.phpnew file mode 100644index 0000000000..2ca73724c8--- /dev/null+++ b/resources/views/components/highlighted.blade.php@@ -0,0 +1 @@+<span class="inline-block text-warning">{{$text}}</span>diff --git a/resources/views/components/layout-simple.blade.php b/resources/views/components/layout-simple.blade.phpindex 3cfe9bd8e0..cf1328b32c 100644--- a/resources/views/components/layout-simple.blade.php+++ b/resources/views/components/layout-simple.blade.php@@ -26,7 +26,7 @@<body>@livewireScripts<x-toaster-hub />- <main class="main max-w-screen-2xl">+ <main>{{ $slot }}</main><x-version class="fixed left-2 bottom-1" />diff --git a/resources/views/components/layout-subscription.blade.php b/resources/views/components/layout-subscription.blade.phpindex f5103c8631..d450c22bdf 100644--- a/resources/views/components/layout-subscription.blade.php+++ b/resources/views/components/layout-subscription.blade.php@@ -26,7 +26,7 @@<body>@livewireScripts<x-toaster-hub />- @if (is_instance_admin() || is_subscription_in_grace_period())+ @if (isInstanceAdmin() || is_subscription_in_grace_period())<div class="fixed top-3 left-4" id="vue"><magic-bar></magic-bar></div>diff --git a/resources/views/components/navbar.blade.php b/resources/views/components/navbar.blade.phpindex 428ffdbfe3..6ce5808374 100644--- a/resources/views/components/navbar.blade.php+++ b/resources/views/components/navbar.blade.php@@ -65,7 +65,7 @@</a></li><div class="flex-1"></div>- @if (is_instance_admin())+ @if (isInstanceAdmin())<livewire:upgrade />@endif<li title="Profile">@@ -80,7 +80,7 @@</a></li>- @if (is_instance_admin())+ @if (isInstanceAdmin())<li title="Settings" class="mt-auto"><a class="hover:bg-transparent" @if (!request()->is('settings')) href="/settings" @endif><svg xmlns="http://www.w3.org/2000/svg"diff --git a/resources/views/dashboard.blade.php b/resources/views/dashboard.blade.phpindex 442740f978..6dab46114b 100644--- a/resources/views/dashboard.blade.php+++ b/resources/views/dashboard.blade.php@@ -1,6 +1,6 @@<x-layout><h1>Dashboard</h1>- <div class="subtitle">Something <span class="text-warning">(more)</span> useful will be here.</div>+ <div class="subtitle">Something <x-highlighted text="(more)"/> useful will be here.</div><div class="w-full rounded stats stats-vertical lg:stats-horizontal"><div class="stat"><div class="stat-title">Servers</div>diff --git a/resources/views/livewire/boarding.blade.php b/resources/views/livewire/boarding.blade.phpnew file mode 100644index 0000000000..5d9348eba2--- /dev/null+++ b/resources/views/livewire/boarding.blade.php@@ -0,0 +1,146 @@+<div class="min-h-screen hero">+ <div class="hero-content">+ <div>+ @if ($currentState === 'welcome')+ <h1 class="text-5xl font-bold">Welcome to Coolify</h1>+ <p class="py-6 text-xl text-center">Let me help you to set the basics.</p>+ <div class="flex justify-center ">+ <div class="w-72 box" wire:click="$set('currentState', 'select-server')">Get Started+ </div>+ </div>+ @endif+ @if ($currentState === 'select-server')+ <x-boarding-step title="Server">+ <x-slot:question>+ Do you want to deploy your resources on your <x-highlighted text="Localhost" />+ or on a <x-highlighted text="Remote Server" />?+ </x-slot:question>+ <x-slot:actions>+ <div class="md:w-72 box" wire:click="setServer('localhost')">Localhost+ </div>+ <div class="md:w-72 box" wire:click="setServer('remote')">Remote Server+ </div>+ </x-slot:actions>+ <x-slot:explanation>+ <p>Servers are the main building blocks, as they will host your applications, databases,+ services, called resources. Any CPU intensive process will use the server's CPU where you+ are deploying your resources.</p>+ <p>Localhost is the server where Coolify is running on. It is not recommended to use one server+ for everyting.</p>+ <p>Remote Server is a server reachable through SSH. It can be hosted at home, or from any cloud+ provider.</p>+ </x-slot:explanation>+ </x-boarding-step>+ @endif+ @if ($currentState === 'private-key')+ <x-boarding-step title="Private Key">+ <x-slot:question>+ Do you have your own Private Key?+ </x-slot:question>+ <x-slot:actions>+ <div class="md:w-72 box" wire:click="setPrivateKey('own')">Yes+ </div>+ <div class="md:w-72 box" wire:click="setPrivateKey('create')">No (create one for me)+ </div>+ </x-slot:actions>+ <x-slot:explanation>+ <p>Private Keys are used to connect to a remote server through a secure shell, called SSH.</p>+ <p>You can use your own private key, or you can let Coolify to create one for you.</p>+ <p>In both ways, you need to add the public version of your private key to the remote server's+ <code>~/.ssh/authorized_keys</code> file.+ </p>+ </x-slot:explanation>+ </x-boarding-step>+ @endif+ @if ($currentState === 'create-private-key')+ <x-boarding-step title="Create Private Key">+ <x-slot:question>+ Please let me know your key details.+ </x-slot:question>+ <x-slot:actions>+ <form wire:submit.prevent='savePrivateKey' class="flex flex-col w-full gap-4 pr-10">+ <x-forms.input required placeholder="Choose a name for your Private Key. Could be anything."+ label="Name" id="privateKeyName" />+ <x-forms.input placeholder="Description, so others will know more about this."+ label="Description" id="privateKeyDescription" />+ <x-forms.textarea required placeholder="-----BEGIN OPENSSH PRIVATE KEY-----"+ label="Private Key" id="privateKey" />+ <x-forms.button type="submit">Save</x-forms.button>+ </form>+ </x-slot:actions>+ <x-slot:explanation>+ <p>Private Keys are used to connect to a remote server through a secure shell, called SSH.</p>+ <p>You can use your own private key, or you can let Coolify to create one for you.</p>+ <p>In both ways, you need to add the public version of your private key to the remote server's+ <code>~/.ssh/authorized_keys</code> file.+ </p>+ </x-slot:explanation>+ </x-boarding-step>+ @endif+ @if ($currentState === 'create-server')+ <x-boarding-step title="Create Server">+ <x-slot:question>+ Please let me know your server details.+ </x-slot:question>+ <x-slot:actions>+ <form wire:submit.prevent='saveServer' class="flex flex-col w-full gap-4 pr-10">+ <div class="flex gap-2">+ <x-forms.input required placeholder="Choose a name for your Server. Could be anything."+ label="Name" id="remoteServerName" />+ <x-forms.input placeholder="Description, so others will know more about this."+ label="Description" id="remoteServerDescription" />+ </div>+ <div class="flex gap-2">+ <x-forms.input required placeholder="Hostname or IP address"+ label="Hostname or IP Address" id="remoteServerHost" />+ <x-forms.input required placeholder="Port number of your server. Default is 22."+ label="Port" id="remoteServerPort" />+ <x-forms.input required readonly+ placeholder="Username to connect to your server. Default is root." label="Username"+ id="remoteServerUser" />+ </div>+ <x-forms.button type="submit">Save</x-forms.button>+ </form>+ </x-slot:actions>+ <x-slot:explanation>+ <p>Username should be <x-highlighted text="root" /> for now. We are working on to use+ non-root users.</p>+ </x-slot:explanation>+ </x-boarding-step>+ @endif+ @if ($currentState === 'install-docker')+ <x-boarding-step title="Install Docker">+ <x-slot:question>+ Could not find Docker Engine on your server. Do you want me to install it for you?+ </x-slot:question>+ <x-slot:actions>+ <div class="w-72 box" wire:click="installDocker">Let's do it!</div>+ </x-slot:actions>+ <x-slot:explanation>+ <p>This will install the latest Docker Engine on your server, configure a few things to be able to run optimal.</p>+ </x-slot:explanation>+ </x-boarding-step>+ @endif+ @if ($currentState === 'create-project')+ <x-boarding-step title="Project">+ <x-slot:question>+ I will create an initial project for you. You can change all the details later on.+ </x-slot:question>+ <x-slot:actions>+ <div class="w-72 box" wire:click="createNewProject">Let's do it!</div>+ </x-slot:actions>+ <x-slot:explanation>+ <p>Projects are bound together several resources into one virtual group. There are no+ limitations on the number of projects you could have.</p>+ <p>Each project should have at least one environment. This helps you to create a production &+ staging version of the same application, but grouped separately.</p>+ </x-slot:explanation>+ </x-boarding-step>+ @endif+ <div class="flex justify-center gap-2 pt-4">+ <a wire:click='skipBoarding'>Skip boarding process</a>+ <a wire:click='restartBoarding'>Restart boarding process</a>+ </div>+ </div>+ </div>+</div>diff --git a/resources/views/livewire/destination/show.blade.php b/resources/views/livewire/destination/show.blade.phpindex f39b2a3a89..a0718f0176 100644--- a/resources/views/livewire/destination/show.blade.php+++ b/resources/views/livewire/destination/show.blade.php@@ -25,7 +25,7 @@@foreach ($networks as $network)<ahref="{{ route('destination.new', ['server_id' => $server->id, 'network_name' => data_get($network, 'Name')]) }}">- <x-forms.button>Add<span class="text-warning">{{ data_get($network, 'Name') }}</span>+ <x-forms.button>+<x-highlighted text="{{ data_get($network, 'Name') }}" /></x-forms.button></a>@endforeachdiff --git a/resources/views/livewire/notifications/email-settings.blade.php b/resources/views/livewire/notifications/email-settings.blade.phpindex c67a6098a4..5631f3349b 100644--- a/resources/views/livewire/notifications/email-settings.blade.php+++ b/resources/views/livewire/notifications/email-settings.blade.php@@ -16,7 +16,7 @@<x-forms.button type="submit">Save</x-forms.button>- @if (is_instance_admin())+ @if (isInstanceAdmin())<x-forms.button wire:click='copyFromInstanceSettings'>Copy from Instance Settings</x-forms.button>diff --git a/resources/views/livewire/server/proxy/deploy.blade.php b/resources/views/livewire/server/proxy/deploy.blade.phpindex 36536f0a0c..685cddbdf1 100644--- a/resources/views/livewire/server/proxy/deploy.blade.php+++ b/resources/views/livewire/server/proxy/deploy.blade.php@@ -9,9 +9,8 @@</x-modal><x-modal yesOrNo modalId="startProxy" modalTitle="Start Proxy" action="start_proxy"><x-slot:modalBody>- <p>This will start the proxy on this server and <span class="text-warning">stop any running process that is- using port 80 and- 443</span>.+ <p>This will start the proxy on this server and+ <x-highlighted text="stop any running process that is using port 80 and 443" />.<br>Please thinkagain.</p>diff --git a/resources/views/livewire/subscription/actions.blade.php b/resources/views/livewire/subscription/actions.blade.phpindex 334adcfe42..8188ccf056 100644--- a/resources/views/livewire/subscription/actions.blade.php+++ b/resources/views/livewire/subscription/actions.blade.php@@ -1,7 +1,7 @@<div>- <div>Status: {{ auth()->user()->currentTeam()->subscription->lemon_status }}</div>- <div>Type: {{ auth()->user()->currentTeam()->subscription->lemon_variant_name }}</div>- @if (auth()->user()->currentTeam()->subscription->lemon_status === 'cancelled')+ <div>Status: {{ currentTeam()->subscription->lemon_status }}</div>+ <div>Type: {{ currentTeam()->subscription->lemon_variant_name }}</div>+ @if (currentTeam()->subscription->lemon_status === 'cancelled')<div class="pb-4">Subscriptions ends at: {{ getRenewDate() }}</div><div class="py-4">If you would like to change the subscription to a lower/higher plan, <aclass="text-white underline" href="https://docs.coollabs.io/contact" target="_blank">please@@ -12,7 +12,7 @@@endif<div class="flex flex-col gap-2"><div class="flex gap-2">- @if (auth()->user()->currentTeam()->subscription->lemon_status === 'cancelled')+ @if (currentTeam()->subscription->lemon_status === 'cancelled')<x-forms.button class="bg-coollabs-gradient" wire:click='resume'>Resume Subscription</x-forms.button>@elsediff --git a/resources/views/livewire/team/delete.blade.php b/resources/views/livewire/team/delete.blade.phpindex b25b2e3039..60a97b93f3 100644--- a/resources/views/livewire/team/delete.blade.php+++ b/resources/views/livewire/team/delete.blade.php@@ -11,11 +11,11 @@<div>This is the default team. You can't delete it.</div>@elseif(auth()->user()->teams()->get()->count() === 1)<div>You can't delete your last team.</div>- @elseif(auth()->user()->currentTeam()->subscription &&- auth()->user()->currentTeam()->subscription?->lemon_status !== 'cancelled')+ @elseif(currentTeam()->subscription &&+ currentTeam()->subscription?->lemon_status !== 'cancelled')<div>Please cancel your subscription before delete this team (Manage My Subscription button).</div>@else- @if (auth()->user()->currentTeam()->isEmpty())+ @if (currentTeam()->isEmpty())<div class="pb-4">This will delete your team. Beware! There is no coming back!</div><x-forms.button isError isModal modalId="deleteTeam">Delete@@ -25,25 +25,25 @@<div class="pb-4">You need to delete the following resources to be able to delete the team:</div><h4 class="pb-4">Projects:</h4><ul class="pl-8 list-disc">- @foreach (auth()->user()->currentTeam()->projects as $resource)+ @foreach (currentTeam()->projects as $resource)<li>{{ $resource->name }}</li>@endforeach</ul><h4 class="py-4">Servers:</h4><ul class="pl-8 list-disc">- @foreach (auth()->user()->currentTeam()->servers as $resource)+ @foreach (currentTeam()->servers as $resource)<li>{{ $resource->name }}</li>@endforeach</ul><h4 class="py-4">Private Keys:</h4><ul class="pl-8 list-disc">- @foreach (auth()->user()->currentTeam()->privateKeys as $resource)+ @foreach (currentTeam()->privateKeys as $resource)<li>{{ $resource->name }}</li>@endforeach</ul><h4 class="py-4">Sources:</h4><ul class="pl-8 list-disc">- @foreach (auth()->user()->currentTeam()->sources() as $resource)+ @foreach (currentTeam()->sources() as $resource)<li>{{ $resource->name }}</li>@endforeach</ul>diff --git a/resources/views/team/members.blade.php b/resources/views/team/members.blade.phpindex 9cb8fa2e8f..5366e61f49 100644--- a/resources/views/team/members.blade.php+++ b/resources/views/team/members.blade.php@@ -14,7 +14,7 @@</tr></thead><tbody>- @foreach (auth()->user()->currentTeam()->members->sortBy('name') as $member)+ @foreach (currentTeam()->members->sortBy('name') as $member)<livewire:team.member :member="$member" :wire:key="$member->id" />@endforeach</tbody>@@ -26,7 +26,7 @@<h3 class="pb-4">Invite a new member</h3>@else<h3>Invite a new member</h3>- @if (is_instance_admin())+ @if (isInstanceAdmin())<div class="pb-4 text-xs text-warning">You need to configure <a href="/settings/emails"class="underline text-warning">TransactionalEmails</a>diff --git a/resources/views/team/show.blade.php b/resources/views/team/show.blade.phpindex 3817022abf..1dcc08713c 100644--- a/resources/views/team/show.blade.php+++ b/resources/views/team/show.blade.php@@ -6,7 +6,7 @@@if (is_cloud())<div class="pb-8"><h2>Subscription</h2>- @if (data_get(auth()->user()->currentTeam(),+ @if (data_get(currentTeam(),'subscription'))<livewire:subscription.actions />@elsediff --git a/routes/web.php b/routes/web.phpindex 81dd776ecc..f48b31ac7c 100644--- a/routes/web.php+++ b/routes/web.php@@ -93,6 +93,7 @@ Route::middleware(['auth'])->group(function () {Route::middleware(['auth'])->group(function () {Route::get('/', [Controller::class, 'dashboard'])->name('dashboard');+ Route::get('/boarding', [Controller::class, 'boarding'])->name('boarding');Route::middleware(['throttle:force-password-reset'])->group(function() {Route::get('/force-password-reset', [Controller::class, 'force_passoword_reset'])->name('auth.force-password-reset');});@@ -126,7 +127,7 @@ Route::middleware(['auth'])->group(function () {Route::middleware(['auth'])->group(function () {Route::get('/source/new', fn () => view('source.new'))->name('source.new');Route::get('/sources', function () {- $sources = auth()->user()->currentTeam()->sources();+ $sources = currentTeam()->sources();return view('source.all', ['sources' => $sources,]);