From 847b3fe54f2204eefb43fac3f57d127c96389e45 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 17 Aug 2023 16:12:08 +0200 Subject: [PATCH 01/41] feat: invite by email from waitlist --- app/Console/Commands/InviteFromWaitlist.php | 14 +++++++++++--- config/version.php | 2 +- versions.json | 2 +- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/app/Console/Commands/InviteFromWaitlist.php b/app/Console/Commands/InviteFromWaitlist.php index 4adc60693..2794b7441 100644 --- a/app/Console/Commands/InviteFromWaitlist.php +++ b/app/Console/Commands/InviteFromWaitlist.php @@ -19,21 +19,29 @@ class InviteFromWaitlist extends Command * * @var string */ - protected $signature = 'app:invite-from-waitlist'; + protected $signature = 'app:invite-from-waitlist {email?}'; /** * The console command description. * * @var string */ - protected $description = 'Send invitation to the next user in the waitlist'; + protected $description = 'Send invitation to the next user (or by email) in the waitlist'; /** * Execute the console command. */ public function handle() { - $this->next_patient = Waitlist::orderBy('created_at', 'asc')->where('verified', true)->first(); + if ($this->argument('email')) { + $this->next_patient = Waitlist::where('email', $this->argument('email'))->first(); + if (!$this->next_patient) { + $this->error("{$this->argument('email')} not found in the waitlist."); + return; + } + } else { + $this->next_patient = Waitlist::orderBy('created_at', 'asc')->where('verified', true)->first(); + } if ($this->next_patient) { $this->register_user(); $this->remove_from_waitlist(); diff --git a/config/version.php b/config/version.php index 7764582fa..7ea9c5731 100644 --- a/config/version.php +++ b/config/version.php @@ -1,3 +1,3 @@ Date: Thu, 17 Aug 2023 16:20:27 +0200 Subject: [PATCH 02/41] change secrets for bunny sync --- .env.development.example | 6 ++++++ .env.secrets.example | 6 ------ 2 files changed, 6 insertions(+), 6 deletions(-) delete mode 100644 .env.secrets.example diff --git a/.env.development.example b/.env.development.example index e73b8c1dd..43d3a10fd 100644 --- a/.env.development.example +++ b/.env.development.example @@ -14,3 +14,9 @@ APP_URL=http://localhost APP_PORT=8000 DUSK_DRIVER_URL=http://selenium:4444 + +## For Andras only +# To purge cache +BUNNY_API_KEY= +# To upload assets +BUNNY_STORAGE_API_KEY= diff --git a/.env.secrets.example b/.env.secrets.example deleted file mode 100644 index a114f6982..000000000 --- a/.env.secrets.example +++ /dev/null @@ -1,6 +0,0 @@ -# Secrets related to pushing to GH, Sync files to BunnyCDN etc. Only for maintainers. -# Not related to Coolify, but to how we publish new versions. - -GITHUB_TOKEN= -BUNNY_API_KEY= -BUNNY_STORAGE_API_KEY= From d049acad709ef1ede65e8a0dc5ca8692abfb18dd Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 17 Aug 2023 16:22:49 +0200 Subject: [PATCH 03/41] update compose for prod --- docker-compose.prod.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index 4a9e0c192..2f9058269 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -34,6 +34,7 @@ services: - PHP_PM_MAX_SPARE_SERVERS=10 - SELF_HOSTED - WAITLIST + - LEMON_SQUEEZY_API_KEY - LEMON_SQUEEZY_WEBHOOK_SECRET - LEMON_SQUEEZY_CHECKOUT_ID_MONTHLY_BASIC - LEMON_SQUEEZY_CHECKOUT_ID_MONTHLY_PRO From 7e37068fc0150b2d0591cdd372e6c2fbe6ae85e1 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 17 Aug 2023 16:26:55 +0200 Subject: [PATCH 04/41] send notification of autoupdate --- app/Actions/Server/UpdateCoolify.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/Actions/Server/UpdateCoolify.php b/app/Actions/Server/UpdateCoolify.php index 8f81852d8..60d0f9a73 100644 --- a/app/Actions/Server/UpdateCoolify.php +++ b/app/Actions/Server/UpdateCoolify.php @@ -42,10 +42,12 @@ class UpdateCoolify } $this->update(); } + send_internal_notification('InstanceAutoUpdateJob done on: ' . $this->server->ip . "(fqdn:{$this->server->fqdn})" . ' to version: ' . $this->latest_version . ' from version: ' . $this->current_version); return; - } catch (\Exception $e) { + } catch (\Exception $th) { ray('InstanceAutoUpdateJob failed'); - ray($e->getMessage()); + ray($th->getMessage()); + send_internal_notification('InstanceAutoUpdateJob failed: ' . $th->getMessage()); return; } } From b7ec1d7d65c29c103cb4ff38517d08ef330088cd Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Mon, 21 Aug 2023 10:18:11 +0200 Subject: [PATCH 05/41] fix: limits & server creation page --- app/Http/Controllers/ServerController.php | 4 ++-- app/Http/Livewire/Project/New/Select.php | 2 +- app/Models/Server.php | 3 ++- .../views/livewire/project/new/select.blade.php | 12 ++++++++++-- resources/views/server/all.blade.php | 6 +++++- 5 files changed, 20 insertions(+), 7 deletions(-) diff --git a/app/Http/Controllers/ServerController.php b/app/Http/Controllers/ServerController.php index e7f9feb57..2c2a34363 100644 --- a/app/Http/Controllers/ServerController.php +++ b/app/Http/Controllers/ServerController.php @@ -20,8 +20,8 @@ class ServerController extends Controller } $servers = auth()->user()->currentTeam()->servers->count(); $subscription = auth()->user()->currentTeam()?->subscription->type(); - $limits = config('constants.limits.server')[strtolower($subscription)]; - $limit_reached = true ?? $servers >= $limits[$subscription]; + $your_limit = config('constants.limits.server')[strtolower($subscription)]; + $limit_reached = $servers >= $your_limit; return view('server.create', [ 'limit_reached' => $limit_reached, diff --git a/app/Http/Livewire/Project/New/Select.php b/app/Http/Livewire/Project/New/Select.php index f95599154..e2271ab53 100644 --- a/app/Http/Livewire/Project/New/Select.php +++ b/app/Http/Livewire/Project/New/Select.php @@ -46,6 +46,6 @@ class Select extends Component public function load_servers() { - $this->servers = Server::ownedByCurrentTeam()->get(); + $this->servers = Server::isUsable()->get(); } } diff --git a/app/Models/Server.php b/app/Models/Server.php index 91adb6b9b..1d8ea0f77 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -33,8 +33,9 @@ class Server extends BaseModel static public function ownedByCurrentTeam(array $select = ['*']) { + $teamId = auth()->user()->currentTeam()->id; $selectArray = collect($select)->concat(['id']); - return Server::whereTeamId(auth()->user()->currentTeam()->id)->with('settings')->select($selectArray->all())->orderBy('name'); + return Server::whereTeamId($teamId)->with('settings')->select($selectArray->all())->orderBy('name'); } static public function isUsable() diff --git a/resources/views/livewire/project/new/select.blade.php b/resources/views/livewire/project/new/select.blade.php index fa07a0ec1..c187a98fc 100644 --- a/resources/views/livewire/project/new/select.blade.php +++ b/resources/views/livewire/project/new/select.blade.php @@ -80,7 +80,7 @@
  • Select a Destination
  • - @foreach ($servers as $server) + @forelse($servers as $server)
    @@ -91,7 +91,15 @@ {{ $server->description }}
    - @endforeach + @empty +
    +
    No validated & reachable servers found. + Go to servers page +
    + + +
    + @endforelse @endif @if ($current_step === 'destinations') diff --git a/resources/views/server/all.blade.php b/resources/views/server/all.blade.php index afa223b91..048fb311c 100644 --- a/resources/views/server/all.blade.php +++ b/resources/views/server/all.blade.php @@ -1,5 +1,9 @@ -

    Servers

    +
    +

    Servers

    + + Add + +
    All Servers
    @forelse ($servers as $server) From a3f3470137e2e2352adb90021f9adf1bd9a170ce Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Mon, 21 Aug 2023 11:11:51 +0200 Subject: [PATCH 06/41] add resend as mailer --- app/Notifications/Channels/EmailChannel.php | 29 +++-- composer.json | 1 + composer.lock | 127 +++++++++++++++++++- config/mail.php | 4 +- 4 files changed, 147 insertions(+), 14 deletions(-) diff --git a/app/Notifications/Channels/EmailChannel.php b/app/Notifications/Channels/EmailChannel.php index 638939589..b412bebd6 100644 --- a/app/Notifications/Channels/EmailChannel.php +++ b/app/Notifications/Channels/EmailChannel.php @@ -6,13 +6,13 @@ use Exception; use Illuminate\Mail\Message; use Illuminate\Notifications\Notification; use Illuminate\Support\Facades\Mail; +use Illuminate\Support\Str; class EmailChannel { public function send(SendsEmail $notifiable, Notification $notification): void { $this->bootConfigs($notifiable); - ray($notification); $recepients = $notifiable->getRecepients($notification); if (count($recepients) === 0) { @@ -39,16 +39,21 @@ class EmailChannel $password = data_get($notifiable, 'smtp_password'); if ($password) $password = decrypt($password); - config()->set('mail.default', 'smtp'); - config()->set('mail.mailers.smtp', [ - "transport" => "smtp", - "host" => data_get($notifiable, 'smtp_host'), - "port" => data_get($notifiable, 'smtp_port'), - "encryption" => data_get($notifiable, 'smtp_encryption'), - "username" => data_get($notifiable, 'smtp_username'), - "password" => $password, - "timeout" => data_get($notifiable, 'smtp_timeout'), - "local_domain" => null, - ]); + if (Str::contains(data_get($notifiable, 'smtp_host'),'resend.com')) { + config()->set('mail.default', 'resend'); + config()->set('resend.api_key', $password); + } else { + config()->set('mail.default', 'smtp'); + config()->set('mail.mailers.smtp', [ + "transport" => "smtp", + "host" => data_get($notifiable, 'smtp_host'), + "port" => data_get($notifiable, 'smtp_port'), + "encryption" => data_get($notifiable, 'smtp_encryption'), + "username" => data_get($notifiable, 'smtp_username'), + "password" => $password, + "timeout" => data_get($notifiable, 'smtp_timeout'), + "local_domain" => null, + ]); + } } } diff --git a/composer.json b/composer.json index 7fcdd9e26..c43f5d09c 100644 --- a/composer.json +++ b/composer.json @@ -24,6 +24,7 @@ "masmerise/livewire-toaster": "^1.2", "nubs/random-name-generator": "^2.2", "poliander/cron": "^3.0", + "resend/resend-laravel": "^0.5.0", "sentry/sentry-laravel": "^3.4", "spatie/laravel-activitylog": "^4.7.3", "spatie/laravel-data": "^3.4.3", diff --git a/composer.lock b/composer.lock index 45671727a..a64169d6e 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": "0c023bed552776ee5e4eeda1ff0a5e19", + "content-hash": "15eb89e93c667bb63f48ef548ed38bed", "packages": [ { "name": "aws/aws-crt-php", @@ -5404,6 +5404,131 @@ ], "time": "2023-04-15T23:01:58+00:00" }, + { + "name": "resend/resend-laravel", + "version": "v0.5.0", + "source": { + "type": "git", + "url": "https://github.com/resendlabs/resend-laravel.git", + "reference": "e598d1e25e49a7aa4c35f653d1d828f69ee4fc1d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/resendlabs/resend-laravel/zipball/e598d1e25e49a7aa4c35f653d1d828f69ee4fc1d", + "reference": "e598d1e25e49a7aa4c35f653d1d828f69ee4fc1d", + "shasum": "" + }, + "require": { + "illuminate/support": "^9.21|^10.0", + "php": "^8.1", + "resend/resend-php": "^0.7.1", + "symfony/mailer": "^6.2" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^3.14", + "mockery/mockery": "^1.5", + "orchestra/testbench": "^7.22|^8.0", + "pestphp/pest": "^1.22" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.x-dev" + }, + "laravel": { + "providers": [ + "Resend\\Laravel\\ResendServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Resend\\Laravel\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Resend and contributors", + "homepage": "https://github.com/resendlabs/resend-laravel/contributors" + } + ], + "description": "Resend for Laravel", + "homepage": "https://resend.com/", + "keywords": [ + "api", + "client", + "laravel", + "php", + "resend", + "sdk" + ], + "support": { + "issues": "https://github.com/resendlabs/resend-laravel/issues", + "source": "https://github.com/resendlabs/resend-laravel/tree/v0.5.0" + }, + "time": "2023-07-15T17:56:14+00:00" + }, + { + "name": "resend/resend-php", + "version": "v0.7.1", + "source": { + "type": "git", + "url": "https://github.com/resendlabs/resend-php.git", + "reference": "3b2e2eae0ded191b2ea67d0ee2e87cdc442316a0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/resendlabs/resend-php/zipball/3b2e2eae0ded191b2ea67d0ee2e87cdc442316a0", + "reference": "3b2e2eae0ded191b2ea67d0ee2e87cdc442316a0", + "shasum": "" + }, + "require": { + "guzzlehttp/guzzle": "^7.5", + "php": "^8.1.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^3.13", + "pestphp/pest": "^2.0", + "pestphp/pest-plugin-mock": "^2.0" + }, + "type": "library", + "autoload": { + "files": [ + "src/Resend.php" + ], + "psr-4": { + "Resend\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Resend and contributors", + "homepage": "https://github.com/resendlabs/resend-php/contributors" + } + ], + "description": "Resend PHP library.", + "homepage": "https://resend.com/", + "keywords": [ + "api", + "client", + "php", + "resend", + "sdk" + ], + "support": { + "issues": "https://github.com/resendlabs/resend-php/issues", + "source": "https://github.com/resendlabs/resend-php/tree/v0.7.1" + }, + "time": "2023-07-12T07:08:27+00:00" + }, { "name": "sentry/sdk", "version": "3.5.0", diff --git a/config/mail.php b/config/mail.php index 4c63daf4f..ec2125fab 100644 --- a/config/mail.php +++ b/config/mail.php @@ -44,7 +44,9 @@ return [ 'timeout' => null, 'local_domain' => env('MAIL_EHLO_DOMAIN'), ], - + 'resend'=> [ + 'transport' => 'resend' + ], 'ses' => [ 'transport' => 'ses', ], From bed959f1cd921085521840d99d7ba013fc3f20c5 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Mon, 21 Aug 2023 18:00:12 +0200 Subject: [PATCH 07/41] feat: rolling update --- app/Actions/Database/StartPostgresql.php | 4 +- .../Livewire/Project/Application/General.php | 11 ++- .../Livewire/Project/Application/Heading.php | 30 ++++--- .../Livewire/Project/Application/Previews.php | 11 ++- .../Livewire/Project/Database/Heading.php | 7 +- .../Livewire/Project/New/SimpleDockerfile.php | 4 + app/Http/Livewire/Server/Proxy/Deploy.php | 2 +- app/Jobs/ApplicationContainerStatusJob.php | 53 ++++++++++++ app/Jobs/ApplicationDeploymentJob.php | 86 +++++++++++++++---- app/Jobs/ContainerStatusJob.php | 54 ------------ app/Jobs/DatabaseContainerStatusJob.php | 52 +++++++++++ app/Jobs/ProxyCheckJob.php | 2 +- app/Jobs/ProxyContainerStatusJob.php | 2 +- app/Jobs/ProxyStartJob.php | 2 +- app/Jobs/ResourceStatusJob.php | 13 ++- bootstrap/helpers/constants.php | 1 + bootstrap/helpers/docker.php | 43 ++++++++-- bootstrap/helpers/proxy.php | 2 +- routes/webhooks.php | 2 +- 19 files changed, 263 insertions(+), 118 deletions(-) create mode 100644 app/Jobs/ApplicationContainerStatusJob.php delete mode 100644 app/Jobs/ContainerStatusJob.php create mode 100644 app/Jobs/DatabaseContainerStatusJob.php diff --git a/app/Actions/Database/StartPostgresql.php b/app/Actions/Database/StartPostgresql.php index 1b5d22f44..ba427a93d 100644 --- a/app/Actions/Database/StartPostgresql.php +++ b/app/Actions/Database/StartPostgresql.php @@ -17,7 +17,7 @@ class StartPostgresql public function __invoke(Server $server, StandalonePostgresql $database) { $this->database = $database; - $container_name = generate_container_name($this->database->uuid); + $container_name = $this->database->uuid; $this->configuration_dir = database_configuration_dir() . '/' . $container_name; $this->commands = [ @@ -36,7 +36,7 @@ class StartPostgresql 'image' => $this->database->image, 'container_name' => $container_name, 'environment' => $environment_variables, - 'restart' => 'always', + 'restart' => RESTART_MODE, 'networks' => [ $this->database->destination->network, ], diff --git a/app/Http/Livewire/Project/Application/General.php b/app/Http/Livewire/Project/Application/General.php index 04be74140..ce7fa773b 100644 --- a/app/Http/Livewire/Project/Application/General.php +++ b/app/Http/Livewire/Project/Application/General.php @@ -136,15 +136,18 @@ class General extends Component public function submit() { + ray($this->application); try { $this->validate(); $domains = Str::of($this->application->fqdn)->trim()->explode(',')->map(function ($domain) { return Str::of($domain)->trim()->lower(); }); - $port = get_port_from_dockerfile($this->application->dockerfile); - if ($port) { - $this->application->ports_exposes = $port; + if ($this->application->dockerfile) { + $port = get_port_from_dockerfile($this->application->dockerfile); + if ($port) { + $this->application->ports_exposes = $port; + } } if ($this->application->base_directory && $this->application->base_directory !== '/') { $this->application->base_directory = rtrim($this->application->base_directory, '/'); @@ -152,7 +155,7 @@ class General extends Component if ($this->application->publish_directory && $this->application->publish_directory !== '/') { $this->application->publish_directory = rtrim($this->application->publish_directory, '/'); } - $this->application->fqdn = data_get($domains->implode(','), '', null); + $this->application->fqdn = $domains->implode(','); $this->application->save(); $this->emit('success', 'Application settings updated!'); } catch (\Exception $e) { diff --git a/app/Http/Livewire/Project/Application/Heading.php b/app/Http/Livewire/Project/Application/Heading.php index fdbe5f71e..e71d4765a 100644 --- a/app/Http/Livewire/Project/Application/Heading.php +++ b/app/Http/Livewire/Project/Application/Heading.php @@ -2,7 +2,7 @@ namespace App\Http\Livewire\Project\Application; -use App\Jobs\ContainerStatusJob; +use App\Jobs\ApplicationContainerStatusJob; use App\Models\Application; use App\Notifications\Application\StatusChanged; use Livewire\Component; @@ -22,9 +22,8 @@ class Heading extends Component public function check_status() { - dispatch_sync(new ContainerStatusJob( - resource: $this->application, - container_name: generate_container_name($this->application->uuid), + dispatch_sync(new ApplicationContainerStatusJob( + application: $this->application, )); $this->application->refresh(); } @@ -58,12 +57,21 @@ class Heading extends Component public function stop() { - remote_process( - ["docker rm -f {$this->application->uuid}"], - $this->application->destination->server - ); - $this->application->status = 'stopped'; - $this->application->save(); - $this->application->environment->project->team->notify(new StatusChanged($this->application)); + $containers = getCurrentApplicationContainerStatus($this->application->destination->server, $this->application->id); + if ($containers->count() === 0) { + return; + } + foreach ($containers as $container) { + $containerName = data_get($container, 'Names'); + if ($containerName) { + remote_process( + ["docker rm -f {$containerName}"], + $this->application->destination->server + ); + $this->application->status = 'stopped'; + $this->application->save(); + $this->application->environment->project->team->notify(new StatusChanged($this->application)); + } + } } } diff --git a/app/Http/Livewire/Project/Application/Previews.php b/app/Http/Livewire/Project/Application/Previews.php index b3582fbef..ad3ca5ad9 100644 --- a/app/Http/Livewire/Project/Application/Previews.php +++ b/app/Http/Livewire/Project/Application/Previews.php @@ -2,7 +2,7 @@ namespace App\Http\Livewire\Project\Application; -use App\Jobs\ContainerStatusJob; +use App\Jobs\ApplicationContainerStatusJob; use App\Models\Application; use App\Models\ApplicationPreview; use Illuminate\Support\Collection; @@ -25,10 +25,9 @@ class Previews extends Component public function loadStatus($pull_request_id) { - dispatch(new ContainerStatusJob( - resource: $this->application, - container_name: generate_container_name($this->application->uuid, $pull_request_id), - pull_request_id: $pull_request_id + dispatch(new ApplicationContainerStatusJob( + application: $this->application, + pullRequestId: $pull_request_id )); } @@ -82,7 +81,7 @@ class Previews extends Component public function stop(int $pull_request_id) { try { - $container_name = generate_container_name($this->application->uuid, $pull_request_id); + $container_name = generateApplicationContainerName($this->application->uuid, $pull_request_id); ray('Stopping container: ' . $container_name); instant_remote_process(["docker rm -f $container_name"], $this->application->destination->server, throwError: false); diff --git a/app/Http/Livewire/Project/Database/Heading.php b/app/Http/Livewire/Project/Database/Heading.php index 59f4955a6..0d90fbf96 100644 --- a/app/Http/Livewire/Project/Database/Heading.php +++ b/app/Http/Livewire/Project/Database/Heading.php @@ -3,7 +3,7 @@ namespace App\Http\Livewire\Project\Database; use App\Actions\Database\StartPostgresql; -use App\Jobs\ContainerStatusJob; +use App\Jobs\DatabaseContainerStatusJob; use App\Notifications\Application\StatusChanged; use Livewire\Component; @@ -25,9 +25,8 @@ class Heading extends Component public function check_status() { - dispatch_sync(new ContainerStatusJob( - resource: $this->database, - container_name: generate_container_name($this->database->uuid), + dispatch_sync(new DatabaseContainerStatusJob( + database: $this->database, )); $this->database->refresh(); } diff --git a/app/Http/Livewire/Project/New/SimpleDockerfile.php b/app/Http/Livewire/Project/New/SimpleDockerfile.php index bbc82fcd5..6c4731658 100644 --- a/app/Http/Livewire/Project/New/SimpleDockerfile.php +++ b/app/Http/Livewire/Project/New/SimpleDockerfile.php @@ -59,6 +59,10 @@ CMD ["nginx", "-g", "daemon off;"] 'source_id' => 0, 'source_type' => GithubApp::class ]); + $application->update([ + 'name' => 'dockerfile-' . $application->id + ]); + redirect()->route('project.application.configuration', [ 'application_uuid' => $application->uuid, 'environment_name' => $environment->name, diff --git a/app/Http/Livewire/Server/Proxy/Deploy.php b/app/Http/Livewire/Server/Proxy/Deploy.php index 9ec3898f1..f78763479 100644 --- a/app/Http/Livewire/Server/Proxy/Deploy.php +++ b/app/Http/Livewire/Server/Proxy/Deploy.php @@ -17,7 +17,7 @@ class Deploy extends Component $this->server->proxy->last_applied_settings && $this->server->proxy->last_saved_settings !== $this->server->proxy->last_applied_settings ) { - $this->emit('saveConfiguration', $server); + $this->emit('saveConfiguration', $this->server); } $activity = resolve(StartProxy::class)($this->server); $this->emit('newMonitorActivity', $activity->id); diff --git a/app/Jobs/ApplicationContainerStatusJob.php b/app/Jobs/ApplicationContainerStatusJob.php new file mode 100644 index 000000000..6930fc69a --- /dev/null +++ b/app/Jobs/ApplicationContainerStatusJob.php @@ -0,0 +1,53 @@ +containerName = generateApplicationContainerName($application->uuid, $pullRequestId); + } + + public function uniqueId(): string + { + return $this->containerName; + } + + public function handle(): void + { + try { + $status = getApplicationContainerStatus(application: $this->application); + if ($this->application->status === 'running' && $status !== 'running') { + $this->application->environment->project->team->notify(new StatusChanged($this->application)); + } + + if ($this->pullRequestId !== 0) { + $preview = ApplicationPreview::findPreviewByApplicationAndPullId($this->application->id, $this->pullRequestId); + $preview->status = $status; + $preview->save(); + } else { + $this->application->status = $status; + $this->application->save(); + } + } catch (\Exception $e) { + ray($e->getMessage()); + } + } +} diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php index fc0a3a1b7..5a76b26ba 100644 --- a/app/Jobs/ApplicationDeploymentJob.php +++ b/app/Jobs/ApplicationDeploymentJob.php @@ -50,6 +50,7 @@ class ApplicationDeploymentJob implements ShouldQueue private ApplicationPreview|null $preview = null; private string $container_name; + private string|null $currently_running_container_name = null; private string $workdir; private string $configuration_dir; private string $build_workdir; @@ -86,7 +87,7 @@ class ApplicationDeploymentJob implements ShouldQueue $this->build_workdir = "{$this->workdir}" . rtrim($this->application->base_directory, '/'); $this->is_debug_enabled = $this->application->settings->is_debug_enabled; - $this->container_name = generate_container_name($this->application->uuid, $this->pull_request_id); + $this->container_name = generateApplicationContainerName($this->application->uuid, $this->pull_request_id); $this->private_key_location = save_private_key_for_server($this->server); $this->saved_outputs = collect(); @@ -113,6 +114,10 @@ class ApplicationDeploymentJob implements ShouldQueue public function handle(): void { // ray()->measure(); + $containers = getCurrentApplicationContainerStatus($this->server, $this->application->id); + if ($containers->count() > 0) { + $this->currently_running_container_name = data_get($containers[0], 'Names'); + } $this->application_deployment_queue->update([ 'status' => ApplicationDeploymentStatus::IN_PROGRESS->value, ]); @@ -175,9 +180,9 @@ class ApplicationDeploymentJob implements ShouldQueue $this->generate_build_env_variables(); $this->add_build_env_variables_to_dockerfile(); $this->build_image(); - $this->stop_running_container(); - $this->start_by_compose_file(); + $this->rolling_update(); } + private function deploy() { $this->execute_remote_command( @@ -206,8 +211,7 @@ class ApplicationDeploymentJob implements ShouldQueue "echo 'Docker Image found locally with the same Git Commit SHA {$this->application->uuid}:{$this->commit}. Build step skipped...'" ]); $this->generate_compose_file(); - $this->stop_running_container(); - $this->start_by_compose_file(); + $this->rolling_update(); return; } } @@ -219,8 +223,54 @@ class ApplicationDeploymentJob implements ShouldQueue $this->generate_build_env_variables(); $this->add_build_env_variables_to_dockerfile(); $this->build_image(); - $this->stop_running_container(); + $this->rolling_update(); + } + + private function rolling_update() + { $this->start_by_compose_file(); + $this->health_check(); + $this->stop_running_container(); + } + private function health_check() + { + ray('New container name: ',$this->container_name); + if ($this->container_name) { + $counter = 0; + $this->execute_remote_command( + [ + "echo 'Waiting for health check to pass on the new version of your application.'" + ], + ); + while ($counter < $this->application->health_check_retries) { + $this->execute_remote_command( + [ + "echo 'Attempt {$counter} of {$this->application->health_check_retries}'" + ], + [ + "docker inspect --format='{{json .State.Health.Status}}' {$this->container_name}", + "hidden" => true, + "save" => "health_check" + ], + + ); + $this->execute_remote_command( + [ + "echo 'New application version health check status: {$this->saved_outputs->get('health_check')}'" + ], + ); + if (Str::of($this->saved_outputs->get('health_check'))->contains('healthy')) { + $this->execute_remote_command( + [ + "echo 'Rolling update completed.'" + ], + ); + break; + } + $counter++; + sleep($this->application->health_check_interval); + } + } } private function deploy_pull_request() { @@ -241,8 +291,7 @@ class ApplicationDeploymentJob implements ShouldQueue // $this->generate_build_env_variables(); // $this->add_build_env_variables_to_dockerfile(); $this->build_image(); - $this->stop_running_container(); - $this->start_by_compose_file(); + $this->rolling_update(); } private function prepare_builder_image() @@ -409,7 +458,7 @@ class ApplicationDeploymentJob implements ShouldQueue $this->container_name => [ 'image' => $this->production_image_name, 'container_name' => $this->container_name, - 'restart' => 'always', + 'restart' => RESTART_MODE, 'environment' => $environment_variables, 'labels' => $this->set_labels_for_applications(), 'expose' => $ports, @@ -539,8 +588,8 @@ class ApplicationDeploymentJob implements ShouldQueue $schema = $url->getScheme(); $slug = Str::slug($host . $path); - $http_label = "{$this->application->uuid}-{$slug}-http"; - $https_label = "{$this->application->uuid}-{$slug}-https"; + $http_label = "{$this->container_name}-{$slug}-http"; + $https_label = "{$this->container_name}-{$slug}-https"; if ($schema === 'https') { // Set labels for https @@ -647,23 +696,22 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf"); private function stop_running_container() { - $this->execute_remote_command( - ["echo -n 'Removing old running application.'"], - [$this->execute_in_builder("docker rm -f $this->container_name >/dev/null 2>&1"), "hidden" => true], - ); + if ($this->currently_running_container_name) { + $this->execute_remote_command( + ["echo -n 'Removing old application version.'"], + [$this->execute_in_builder("docker rm -f $this->currently_running_container_name >/dev/null 2>&1"), "hidden" => true], + ); + } } private function start_by_compose_file() { $this->execute_remote_command( - ["echo -n 'Starting new application... '"], + ["echo -n 'Rolling update started.'"], [$this->execute_in_builder("docker compose --project-directory {$this->workdir} up -d >/dev/null"), "hidden" => true], - ["echo 'Done. 🎉'"], ); } - - private function generate_build_env_variables() { $this->build_args = collect(["--build-arg SOURCE_COMMIT={$this->commit}"]); diff --git a/app/Jobs/ContainerStatusJob.php b/app/Jobs/ContainerStatusJob.php deleted file mode 100644 index f2be8b4d7..000000000 --- a/app/Jobs/ContainerStatusJob.php +++ /dev/null @@ -1,54 +0,0 @@ -resource = $resource; - $this->container_name = $container_name; - $this->pull_request_id = $pull_request_id; - } - - public function uniqueId(): string - { - return $this->container_name; - } - - public function handle(): void - { - try { - $status = get_container_status(server: $this->resource->destination->server, container_id: $this->container_name, throwError: false); - if ($this->resource->status === 'running' && $status !== 'running') { - $this->resource->environment->project->team->notify(new StatusChanged($this->resource)); - } - - if ($this->pull_request_id) { - $preview = ApplicationPreview::findPreviewByApplicationAndPullId($this->resource->id, $this->pull_request_id); - $preview->status = $status; - $preview->save(); - } else { - $this->resource->status = $status; - $this->resource->save(); - } - } catch (\Exception $e) { - ray($e->getMessage()); - } - } -} diff --git a/app/Jobs/DatabaseContainerStatusJob.php b/app/Jobs/DatabaseContainerStatusJob.php new file mode 100644 index 000000000..f2fc7053c --- /dev/null +++ b/app/Jobs/DatabaseContainerStatusJob.php @@ -0,0 +1,52 @@ +containerName = $database->uuid; + } + + public function uniqueId(): string + { + return $this->containerName; + } + + public function handle(): void + { + try { + $status = getContainerStatus( + server: $this->database->destination->server, + container_id: $this->containerName, + throwError: false + ); + + if ($this->database->status === 'running' && $status !== 'running') { + $this->database->environment->project->team->notify(new StatusChanged($this->database)); + } + if ($this->database->status !== $status) { + $this->database->status = $status; + $this->database->save(); + } + } catch (\Exception $e) { + ray($e->getMessage()); + } + } +} diff --git a/app/Jobs/ProxyCheckJob.php b/app/Jobs/ProxyCheckJob.php index 7c498107d..bcaf8c8bd 100755 --- a/app/Jobs/ProxyCheckJob.php +++ b/app/Jobs/ProxyCheckJob.php @@ -24,7 +24,7 @@ class ProxyCheckJob implements ShouldQueue $container_name = 'coolify-proxy'; $servers = Server::isUsable()->whereNotNull('proxy')->get(); foreach ($servers as $server) { - $status = get_container_status(server: $server, container_id: $container_name); + $status = getContainerStatus(server: $server, container_id: $container_name); if ($status === 'running') { continue; } diff --git a/app/Jobs/ProxyContainerStatusJob.php b/app/Jobs/ProxyContainerStatusJob.php index 68372895a..3f8c21a3e 100644 --- a/app/Jobs/ProxyContainerStatusJob.php +++ b/app/Jobs/ProxyContainerStatusJob.php @@ -39,7 +39,7 @@ class ProxyContainerStatusJob implements ShouldQueue, ShouldBeUnique public function handle(): void { try { - $container = get_container_status(server: $this->server, all_data: true, container_id: 'coolify-proxy', throwError: true); + $container = getContainerStatus(server: $this->server, all_data: true, container_id: 'coolify-proxy', throwError: true); $status = $container['State']['Status']; if ($this->server->proxy->status !== $status) { $this->server->proxy->status = $status; diff --git a/app/Jobs/ProxyStartJob.php b/app/Jobs/ProxyStartJob.php index 5119210fc..90811d836 100755 --- a/app/Jobs/ProxyStartJob.php +++ b/app/Jobs/ProxyStartJob.php @@ -23,7 +23,7 @@ class ProxyStartJob implements ShouldQueue try { $container_name = 'coolify-proxy'; ray('Starting proxy for server: ' . $this->server->name); - $status = get_container_status(server: $this->server, container_id: $container_name); + $status = getContainerStatus(server: $this->server, container_id: $container_name); if ($status === 'running') { return; } diff --git a/app/Jobs/ResourceStatusJob.php b/app/Jobs/ResourceStatusJob.php index 5ac162d3f..122423f0a 100644 --- a/app/Jobs/ResourceStatusJob.php +++ b/app/Jobs/ResourceStatusJob.php @@ -3,6 +3,7 @@ namespace App\Jobs; use App\Models\Application; +use App\Models\StandalonePostgresql; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldBeUnique; use Illuminate\Contracts\Queue\ShouldQueue; @@ -15,19 +16,25 @@ class ResourceStatusJob implements ShouldQueue, ShouldBeUnique use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; public $applications; + public $postgresqls; public function __construct() { $this->applications = Application::all(); + $this->postgresqls = StandalonePostgresql::all(); } public function handle(): void { try { foreach ($this->applications as $application) { - dispatch(new ContainerStatusJob( - resource: $application, - container_name: generate_container_name($application->uuid), + dispatch(new ApplicationContainerStatusJob( + application: $application, + )); + } + foreach ($this->postgresqls as $postgresql) { + dispatch(new DatabaseContainerStatusJob( + database: $postgresql, )); } } catch (\Exception $e) { diff --git a/bootstrap/helpers/constants.php b/bootstrap/helpers/constants.php index 0e42b311e..cea780c24 100644 --- a/bootstrap/helpers/constants.php +++ b/bootstrap/helpers/constants.php @@ -9,3 +9,4 @@ const VALID_CRON_STRINGS = [ 'monthly' => '0 0 1 * *', 'yearly' => '0 0 1 1 *', ]; +const RESTART_MODE = 'unless-stopped'; diff --git a/bootstrap/helpers/docker.php b/bootstrap/helpers/docker.php index 7b78abe8a..1d4004d07 100644 --- a/bootstrap/helpers/docker.php +++ b/bootstrap/helpers/docker.php @@ -1,14 +1,27 @@ reject(fn ($line) => empty($line)) ->map(fn ($outputLine) => json_decode($outputLine, true, flags: JSON_THROW_ON_ERROR)); } @@ -44,26 +57,38 @@ function format_docker_envs_to_json($rawOutput) } } -function get_container_status(Server $server, string $container_id, bool $all_data = false, bool $throwError = false) +function getApplicationContainerStatus(Application $application) { + $server = $application->destination->server; + $id = $application->id; + + $containers = getCurrentApplicationContainerStatus($server, $id); + if ($containers->count() > 0) { + $status = data_get($containers[0], 'State', 'exited'); + return $status; + } + return 'exited'; +} +function getContainerStatus(Server $server, string $container_id, bool $all_data = false, bool $throwError = false) { - check_server_connection($server); + // check_server_connection($server); $container = instant_remote_process(["docker inspect --format '{{json .}}' {$container_id}"], $server, $throwError); if (!$container) { return 'exited'; } $container = format_docker_command_output_to_json($container); if ($all_data) { - return $container[0]; + return $container; } return data_get($container[0], 'State.Status', 'exited'); } -function generate_container_name(string $uuid, int $pull_request_id = 0) +function generateApplicationContainerName(string $uuid, int $pull_request_id = 0) { - if ($pull_request_id !== 0) { - return $uuid . '-pr-' . $pull_request_id; + $now = now()->format('YmdHis'); + if ($pull_request_id !== 0 && $pull_request_id !== null) { + return $uuid . '-pr-' . $pull_request_id . '-' . $now; } else { - return $uuid; + return $uuid . '-' . $now; } } function get_port_from_dockerfile($dockerfile): int diff --git a/bootstrap/helpers/proxy.php b/bootstrap/helpers/proxy.php index 86c9ca528..37049aaa3 100644 --- a/bootstrap/helpers/proxy.php +++ b/bootstrap/helpers/proxy.php @@ -32,7 +32,7 @@ function generate_default_proxy_configuration(Server $server) "traefik" => [ "container_name" => "coolify-proxy", "image" => "traefik:v2.10", - "restart" => "always", + "restart" => RESTART_MODE, "extra_hosts" => [ "host.docker.internal:host-gateway", ], diff --git a/routes/webhooks.php b/routes/webhooks.php index 77ef23c5d..1e196181b 100644 --- a/routes/webhooks.php +++ b/routes/webhooks.php @@ -161,7 +161,7 @@ Route::post('/source/github/events', function () { $found = ApplicationPreview::where('application_id', $application->id)->where('pull_request_id', $pull_request_id)->first(); if ($found) { $found->delete(); - $container_name = generate_container_name($application->uuid, $pull_request_id); + $container_name = generateApplicationContainerName($application->uuid, $pull_request_id); ray('Stopping container: ' . $container_name); remote_process(["docker rm -f $container_name"], $application->destination->server); return response('Preview Deployment closed.'); From 2414ddd36006b5758dd1a82e84182bab7f1d5255 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Mon, 21 Aug 2023 20:19:47 +0200 Subject: [PATCH 08/41] remove seeders in dev --- ...ScheduledDatabaseBackupExecutionSeeder.php | 24 ++++++------- .../seeders/ScheduledDatabaseBackupSeeder.php | 34 +++++++++---------- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/database/seeders/ScheduledDatabaseBackupExecutionSeeder.php b/database/seeders/ScheduledDatabaseBackupExecutionSeeder.php index e4b5780c9..7e4c33764 100644 --- a/database/seeders/ScheduledDatabaseBackupExecutionSeeder.php +++ b/database/seeders/ScheduledDatabaseBackupExecutionSeeder.php @@ -12,17 +12,17 @@ class ScheduledDatabaseBackupExecutionSeeder extends Seeder */ public function run(): void { - ScheduledDatabaseBackupExecution::create([ - 'status' => 'success', - 'message' => 'Backup created successfully.', - 'size' => '10243467789556', - 'scheduled_database_backup_id' => 1, - ]); - ScheduledDatabaseBackupExecution::create([ - 'status' => 'failed', - 'message' => 'Backup failed.', - 'size' => '10243456', - 'scheduled_database_backup_id' => 1, - ]); + // ScheduledDatabaseBackupExecution::create([ + // 'status' => 'success', + // 'message' => 'Backup created successfully.', + // 'size' => '10243467789556', + // 'scheduled_database_backup_id' => 1, + // ]); + // ScheduledDatabaseBackupExecution::create([ + // 'status' => 'failed', + // 'message' => 'Backup failed.', + // 'size' => '10243456', + // 'scheduled_database_backup_id' => 1, + // ]); } } diff --git a/database/seeders/ScheduledDatabaseBackupSeeder.php b/database/seeders/ScheduledDatabaseBackupSeeder.php index 96ca0c012..fefbada0d 100644 --- a/database/seeders/ScheduledDatabaseBackupSeeder.php +++ b/database/seeders/ScheduledDatabaseBackupSeeder.php @@ -12,22 +12,22 @@ class ScheduledDatabaseBackupSeeder extends Seeder */ public function run(): void { - ScheduledDatabaseBackup::create([ - 'enabled' => true, - 'frequency' => '* * * * *', - 'number_of_backups_locally' => 2, - 'database_id' => 1, - 'database_type' => 'App\Models\StandalonePostgresql', - 's3_storage_id' => 1, - 'team_id' => 0, - ]); - ScheduledDatabaseBackup::create([ - 'enabled' => true, - 'frequency' => '* * * * *', - 'number_of_backups_locally' => 3, - 'database_id' => 1, - 'database_type' => 'App\Models\StandalonePostgresql', - 'team_id' => 0, - ]); + // ScheduledDatabaseBackup::create([ + // 'enabled' => true, + // 'frequency' => '* * * * *', + // 'number_of_backups_locally' => 2, + // 'database_id' => 1, + // 'database_type' => 'App\Models\StandalonePostgresql', + // 's3_storage_id' => 1, + // 'team_id' => 0, + // ]); + // ScheduledDatabaseBackup::create([ + // 'enabled' => true, + // 'frequency' => '* * * * *', + // 'number_of_backups_locally' => 3, + // 'database_id' => 1, + // 'database_type' => 'App\Models\StandalonePostgresql', + // 'team_id' => 0, + // ]); } } From b39ca51d415279280098e324f007241cc8f74f59 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 22 Aug 2023 17:44:49 +0200 Subject: [PATCH 09/41] wip: boarding --- .ssh/known_hosts | 1 + app/Actions/Server/UpdateCoolify.php | 3 - .../Controllers/ApplicationController.php | 6 +- app/Http/Controllers/Controller.php | 14 +- app/Http/Controllers/DatabaseController.php | 10 +- app/Http/Controllers/MagicController.php | 4 +- app/Http/Controllers/ProjectController.php | 8 +- app/Http/Controllers/ServerController.php | 6 +- app/Http/Kernel.php | 1 + app/Http/Livewire/Boarding.php | 147 ++++++++++++++++ .../Destination/New/StandaloneDocker.php | 2 +- .../Notifications/DiscordSettings.php | 3 +- .../Livewire/Notifications/EmailSettings.php | 6 +- app/Http/Livewire/PrivateKey/Change.php | 7 +- app/Http/Livewire/PrivateKey/Create.php | 2 +- app/Http/Livewire/Project/AddEmpty.php | 2 +- .../Livewire/Project/Application/Source.php | 2 +- .../Database/CreateScheduledBackup.php | 2 +- .../Livewire/Project/New/EmptyProject.php | 2 +- .../New/GithubPrivateRepositoryDeployKey.php | 2 +- app/Http/Livewire/Server/Form.php | 2 +- app/Http/Livewire/Server/New/ByIp.php | 2 +- app/Http/Livewire/Settings/Backup.php | 2 +- app/Http/Livewire/Source/Github/Create.php | 2 +- app/Http/Livewire/Subscription/Actions.php | 4 +- app/Http/Livewire/Team/Create.php | 2 +- app/Http/Livewire/Team/Delete.php | 4 +- app/Http/Livewire/Team/Form.php | 4 +- app/Http/Livewire/Team/Invitations.php | 2 +- app/Http/Livewire/Team/InviteLink.php | 6 +- app/Http/Livewire/Team/Member.php | 6 +- app/Http/Livewire/Team/Storage/Create.php | 2 +- app/Http/Middleware/IsBoardingFlow.php | 28 +++ app/Http/Middleware/SubscriptionValid.php | 3 +- app/Models/EnvironmentVariable.php | 2 +- app/Models/GithubApp.php | 4 +- app/Models/PrivateKey.php | 2 +- app/Models/Project.php | 9 +- app/Models/S3Storage.php | 2 +- app/Models/Server.php | 2 +- app/Models/User.php | 13 +- bootstrap/helpers/remoteProcess.php | 6 +- bootstrap/helpers/shared.php | 35 +++- bootstrap/helpers/subscriptions.php | 16 +- composer.json | 1 + composer.lock | 162 +++++++++++++++++- ...023_08_22_071048_add_boarding_to_teams.php | 28 +++ database/seeders/ServerSeeder.php | 4 +- package.json | 3 +- postcss.config.js => postcss.config.cjs | 0 resources/css/app.css | 2 +- resources/js/components/MagicBar.vue | 6 +- resources/views/boarding.blade.php | 3 + .../views/components/boarding-step.blade.php | 25 +++ .../views/components/forms/input.blade.php | 2 +- .../views/components/forms/select.blade.php | 2 +- .../views/components/forms/textarea.blade.php | 6 +- .../views/components/highlighted.blade.php | 1 + .../views/components/layout-simple.blade.php | 2 +- .../components/layout-subscription.blade.php | 2 +- resources/views/components/navbar.blade.php | 4 +- resources/views/dashboard.blade.php | 2 +- resources/views/livewire/boarding.blade.php | 146 ++++++++++++++++ .../views/livewire/destination/show.blade.php | 2 +- .../notifications/email-settings.blade.php | 2 +- .../livewire/server/proxy/deploy.blade.php | 5 +- .../livewire/subscription/actions.blade.php | 8 +- .../views/livewire/team/delete.blade.php | 14 +- resources/views/team/members.blade.php | 4 +- resources/views/team/show.blade.php | 2 +- routes/web.php | 3 +- 71 files changed, 694 insertions(+), 137 deletions(-) create mode 100644 .ssh/known_hosts create mode 100644 app/Http/Livewire/Boarding.php create mode 100644 app/Http/Middleware/IsBoardingFlow.php create mode 100644 database/migrations/2023_08_22_071048_add_boarding_to_teams.php rename postcss.config.js => postcss.config.cjs (100%) create mode 100644 resources/views/boarding.blade.php create mode 100644 resources/views/components/boarding-step.blade.php create mode 100644 resources/views/components/highlighted.blade.php create mode 100644 resources/views/livewire/boarding.blade.php diff --git a/.ssh/known_hosts b/.ssh/known_hosts new file mode 100644 index 000000000..a59e3d0b4 --- /dev/null +++ b/.ssh/known_hosts @@ -0,0 +1 @@ +|1|TRkudHmvsBVekjyAfpo3EWrkQSs=|XdMLpIt2l32hhdSyWnDwMMlVBSI= ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIK/Ln1b72Lc5JtHRDiZd4lYyW7F5aVuJH42HdHXuYudT diff --git a/app/Actions/Server/UpdateCoolify.php b/app/Actions/Server/UpdateCoolify.php index 60d0f9a73..08740a8ed 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.php index 9b87492e4..aa2787de7 100644 --- a/app/Http/Controllers/ApplicationController.php +++ b/app/Http/Controllers/ApplicationController.php @@ -12,7 +12,7 @@ class ApplicationController extends Controller public 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 Controller public 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.php index 84da5de2e..d78e67505 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.php index bb6baf5ec..958d6d5ab 100644 --- a/app/Http/Controllers/DatabaseController.php +++ b/app/Http/Controllers/DatabaseController.php @@ -11,7 +11,7 @@ class DatabaseController extends Controller public 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 Controller public 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.php index 515bc14d1..d7635fda0 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.php index 2ad941e92..476d54437 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -18,7 +18,7 @@ class ProjectController extends Controller public 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 Controller public 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 Controller public 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.php index 2c2a34363..54b8c7a8c 100644 --- a/app/Http/Controllers/ServerController.php +++ b/app/Http/Controllers/ServerController.php @@ -12,14 +12,14 @@ class ServerController extends Controller public 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.php index 57b5edfec..eb93b6d35 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.php new file mode 100644 index 000000000..47dd072ba --- /dev/null +++ b/app/Http/Livewire/Boarding.php @@ -0,0 +1,147 @@ +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.php index fa884ec37..f67180b69 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.php index 03cac4753..f9de6d662 100644 --- a/app/Http/Livewire/Notifications/DiscordSettings.php +++ b/app/Http/Livewire/Notifications/DiscordSettings.php @@ -41,10 +41,9 @@ class DiscordSettings extends Component public 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.php index eceb4e88b..a2887f989 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.php index 91d42bd7a..bd9332ca2 100644 --- a/app/Http/Livewire/PrivateKey/Change.php +++ b/app/Http/Livewire/PrivateKey/Change.php @@ -26,7 +26,7 @@ class Change extends Component try { 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 Component public 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.php index 82218f4a5..d8d3cc41a 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.php index 1024bc66f..fc20f9850 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.php index 5affe9e45..801d533aa 100644 --- a/app/Http/Livewire/Project/Application/Source.php +++ b/app/Http/Livewire/Project/Application/Source.php @@ -29,7 +29,7 @@ class Source extends Component private 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.php index e3ea97735..9297f65f6 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.php index e77ab983e..9dba4338b 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.php index a1f275f32..a2ccd5298 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.php index 4dcebc101..290c06dd7 100644 --- a/app/Http/Livewire/Server/Form.php +++ b/app/Http/Livewire/Server/Form.php @@ -42,7 +42,7 @@ class Form extends Component public 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.php index c4f340413..e6813a55f 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.php index fcb105fd4..263db027d 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.php index 862964c45..4d6f8b26b 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.php index 588a0521c..6c74880b7 100644 --- a/app/Http/Livewire/Subscription/Actions.php +++ b/app/Http/Livewire/Subscription/Actions.php @@ -10,7 +10,7 @@ class Actions extends Component public 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 Component public 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.php index 6c1c71580..bd2c24313 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.php index d14e82ccc..5e206704b 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.php index eedd60c83..caa6d2c9e 100644 --- a/app/Http/Livewire/Team/Form.php +++ b/app/Http/Livewire/Team/Form.php @@ -19,7 +19,7 @@ class Form extends Component public 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.php index ba0b654aa..ba6c1e91f 100644 --- a/app/Http/Livewire/Team/Invitations.php +++ b/app/Http/Livewire/Team/Invitations.php @@ -18,6 +18,6 @@ class Invitations extends Component public 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.php index ddbe75182..aaf22f0e8 100644 --- a/app/Http/Livewire/Team/InviteLink.php +++ b/app/Http/Livewire/Team/InviteLink.php @@ -35,9 +35,9 @@ class InviteLink extends Component return 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.php index 237d38818..df8fcd7af 100644 --- a/app/Http/Livewire/Team/Member.php +++ b/app/Http/Livewire/Team/Member.php @@ -11,19 +11,19 @@ class Member extends Component public 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.php index ed7d277fb..52ce3779d 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.php new file mode 100644 index 000000000..e13e71f31 --- /dev/null +++ b/app/Http/Middleware/IsBoardingFlow.php @@ -0,0 +1,28 @@ +path(), $allowed_paths)) { + return redirect('boarding'); + } + return $next($request); + } +} diff --git a/app/Http/Middleware/SubscriptionValid.php b/app/Http/Middleware/SubscriptionValid.php index f84e6eede..01bd7a0e5 100644 --- a/app/Http/Middleware/SubscriptionValid.php +++ b/app/Http/Middleware/SubscriptionValid.php @@ -17,8 +17,7 @@ class SubscriptionValid return $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.php index bb4a5ca47..62a08c87f 100644 --- a/app/Models/EnvironmentVariable.php +++ b/app/Models/EnvironmentVariable.php @@ -41,7 +41,7 @@ class EnvironmentVariable extends Model private 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.php index 74462e8d7..c4cd3568d 100644 --- a/app/Models/GithubApp.php +++ b/app/Models/GithubApp.php @@ -19,12 +19,12 @@ class GithubApp extends BaseModel static 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(): void diff --git a/app/Models/PrivateKey.php b/app/Models/PrivateKey.php index 4d59e9ca8..d4fd0bfa2 100644 --- a/app/Models/PrivateKey.php +++ b/app/Models/PrivateKey.php @@ -16,7 +16,7 @@ class PrivateKey extends BaseModel static 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.php index a50dde167..9bcd2a0fe 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.php index 5cd2f1318..cbcdb97a9 100644 --- a/app/Models/S3Storage.php +++ b/app/Models/S3Storage.php @@ -17,7 +17,7 @@ class S3Storage extends BaseModel static 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.php index 1d8ea0f77..d14d5f974 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -33,7 +33,7 @@ class Server extends BaseModel static 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.php index b048ef9e6..8cd5b0a56 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -22,6 +22,7 @@ class User extends Authenticatable implements SendsEmail protected $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 SendsEmail public 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 SendsEmail if ($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.php index ecc679b3f..86e11bcf3 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 created Storage::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.php index 4b470cb48..d02522245 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): string return "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.php index 90d0947ad..5cb17d588 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.json index c43f5d09c..fd8a5eb01 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.lock index a64169d6e..cf0183f12 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": "security@paragonie.com", + "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": "info@paragonie.com", + "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": "terrafrost@php.net", + "role": "Lead Developer" + }, + { + "name": "Patrick Monnerat", + "email": "pm@datasphere.ch", + "role": "Developer" + }, + { + "name": "Andreas Fischer", + "email": "bantu@phpbb.com", + "role": "Developer" + }, + { + "name": "Hans-Jürgen Petrich", + "email": "petrich@tronic-media.com", + "role": "Developer" + }, + { + "name": "Graham Campbell", + "email": "graham@alt-three.com", + "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.php new file mode 100644 index 000000000..0fe2062e3 --- /dev/null +++ b/database/migrations/2023_08_22_071048_add_boarding_to_teams.php @@ -0,0 +1,28 @@ +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.php index 77a4516e5..f201862f0 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.json index ed81d6a26..81e0dd5a8 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.cjs similarity index 100% rename from postcss.config.js rename to postcss.config.cjs diff --git a/resources/css/app.css b/resources/css/app.css index b5f58fc74..2e0f079ee 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.vue index f0203b885..a0b08c283 100644 --- a/resources/js/components/MagicBar.vue +++ b/resources/js/components/MagicBar.vue @@ -53,12 +53,12 @@ {{ sequenceState.sequence[sequenceState.currentActionIndex] }} name will be: - {{ search - }} + + {{ sequenceState.sequence[sequenceState.currentActionIndex] }} name will be: - randomly generated (type to change) + diff --git a/resources/views/boarding.blade.php b/resources/views/boarding.blade.php new file mode 100644 index 000000000..d089e0650 --- /dev/null +++ b/resources/views/boarding.blade.php @@ -0,0 +1,3 @@ + + + diff --git a/resources/views/components/boarding-step.blade.php b/resources/views/components/boarding-step.blade.php new file mode 100644 index 000000000..4776f3365 --- /dev/null +++ b/resources/views/components/boarding-step.blade.php @@ -0,0 +1,25 @@ +
    +
    +

    {{$title}}

    +
    + @isset($question) +

    + {{$question}} +

    + @endisset +
    + @if($actions) +
    + {{$actions}} +
    + @endif +
    + @if($explanation) +
    +

    Explanation

    +
    + {{$explanation}} +
    +
    + @endif +
    diff --git a/resources/views/components/forms/input.blade.php b/resources/views/components/forms/input.blade.php index a12366238..2abc8a91e 100644 --- a/resources/views/components/forms/input.blade.php +++ b/resources/views/components/forms/input.blade.php @@ -2,7 +2,7 @@ @if ($label)