From 973429d2c472322fa7f25993ffcbfe463c594715 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 17 Jan 2025 11:38:22 +0100 Subject: [PATCH 01/11] add debug logs --- app/Console/Commands/Init.php | 60 ++++++++++++++++++++++++++- database/seeders/ProductionSeeder.php | 40 +++++++++++++++++- 2 files changed, 97 insertions(+), 3 deletions(-) diff --git a/app/Console/Commands/Init.php b/app/Console/Commands/Init.php index cc9bee0a5..03fc5380d 100644 --- a/app/Console/Commands/Init.php +++ b/app/Console/Commands/Init.php @@ -26,6 +26,7 @@ class Init extends Command public function handle() { + echo "Starting handle()\n"; $this->optimize(); if (isCloud() && ! $this->option('force-cloud')) { @@ -34,13 +35,17 @@ class Init extends Command return; } + echo "Loading servers...\n"; $this->servers = Server::all(); if (isCloud()) { + echo "Running in cloud mode\n"; } else { + echo "Running in self-hosted mode\n"; $this->send_alive_signal(); get_public_ips(); } + echo "Starting backward compatibility checks...\n"; // Backward compatibility $this->replace_slash_in_environment_name(); $this->restore_coolify_db_backup(); @@ -48,25 +53,32 @@ class Init extends Command // $this->update_traefik_labels(); if (! isCloud() || $this->option('force-cloud')) { + echo "Cleaning up unused networks...\n"; $this->cleanup_unused_network_from_coolify_proxy(); } if (isCloud()) { + echo "Cleaning up unnecessary proxy configs...\n"; $this->cleanup_unnecessary_dynamic_proxy_configuration(); } else { + echo "Cleaning up in-progress deployments...\n"; $this->cleanup_in_progress_application_deployments(); } + echo "Running redis cleanup...\n"; $this->call('cleanup:redis'); + echo "Running stucked resources cleanup...\n"; $this->call('cleanup:stucked-resources'); try { + echo "Pulling helper image...\n"; $this->pullHelperImage(); } catch (\Throwable $e) { - // + echo "Error pulling helper image: {$e->getMessage()}\n"; } if (isCloud()) { try { + echo "Pulling templates from CDN (cloud mode)...\n"; $this->pullTemplatesFromCDN(); } catch (\Throwable $e) { echo "Could not pull templates from CDN: {$e->getMessage()}\n"; @@ -75,36 +87,45 @@ class Init extends Command if (! isCloud()) { try { + echo "Pulling templates from CDN (self-hosted mode)...\n"; $this->pullTemplatesFromCDN(); } catch (\Throwable $e) { echo "Could not pull templates from CDN: {$e->getMessage()}\n"; } try { + echo "Setting up localhost proxy config...\n"; $localhost = $this->servers->where('id', 0)->first(); $localhost->setupDynamicProxyConfiguration(); } catch (\Throwable $e) { echo "Could not setup dynamic configuration: {$e->getMessage()}\n"; } + echo "Checking auto-update settings...\n"; $settings = instanceSettings(); if (! is_null(config('constants.coolify.autoupdate', null))) { if (config('constants.coolify.autoupdate') == true) { + echo "Enabling auto-update\n"; $settings->update(['is_auto_update_enabled' => true]); } else { + echo "Disabling auto-update\n"; $settings->update(['is_auto_update_enabled' => false]); } } } + echo "handle() complete\n"; } private function pullHelperImage() { + echo "Dispatching CheckHelperImageJob\n"; CheckHelperImageJob::dispatch(); } private function pullTemplatesFromCDN() { + echo 'Pulling templates from '.config('constants.services.official')."\n"; $response = Http::retry(3, 1000)->get(config('constants.services.official')); if ($response->successful()) { + echo "Successfully pulled templates\n"; $services = $response->json(); File::put(base_path('templates/service-templates.json'), json_encode($services)); } @@ -112,14 +133,20 @@ class Init extends Command private function optimize() { + echo "Running optimize:clear\n"; Artisan::call('optimize:clear'); + echo "Running optimize\n"; Artisan::call('optimize'); } private function update_user_emails() { + echo "Starting user email updates...\n"; try { - User::whereRaw('email ~ \'[A-Z]\'')->get()->each(fn (User $user) => $user->update(['email' => strtolower($user->email)])); + User::whereRaw('email ~ \'[A-Z]\'')->get()->each(function (User $user) { + echo "Converting email to lowercase: {$user->email}\n"; + $user->update(['email' => strtolower($user->email)]); + }); } catch (\Throwable $e) { echo "Error in updating user emails: {$e->getMessage()}\n"; } @@ -127,8 +154,10 @@ class Init extends Command private function update_traefik_labels() { + echo "Updating traefik labels...\n"; try { Server::where('proxy->type', 'TRAEFIK_V2')->update(['proxy->type' => 'TRAEFIK']); + echo "Traefik labels updated successfully\n"; } catch (\Throwable $e) { echo "Error in updating traefik labels: {$e->getMessage()}\n"; } @@ -136,15 +165,21 @@ class Init extends Command private function cleanup_unnecessary_dynamic_proxy_configuration() { + echo "Starting cleanup of unnecessary proxy configs...\n"; foreach ($this->servers as $server) { try { if (! $server->isFunctional()) { + echo "Server {$server->id} not functional, skipping\n"; + continue; } if ($server->id === 0) { + echo "Skipping localhost server\n"; + continue; } $file = $server->proxyPath().'/dynamic/coolify.yaml'; + echo "Removing file: $file\n"; return instant_remote_process([ "rm -f $file", @@ -157,20 +192,28 @@ class Init extends Command private function cleanup_unused_network_from_coolify_proxy() { + echo "Starting cleanup of unused networks...\n"; foreach ($this->servers as $server) { if (! $server->isFunctional()) { + echo "Server {$server->id} not functional, skipping\n"; + continue; } if (! $server->isProxyShouldRun()) { + echo "Proxy should not run on server {$server->id}, skipping\n"; + continue; } try { + echo "Collecting docker networks for server {$server->id}\n"; ['networks' => $networks, 'allNetworks' => $allNetworks] = collectDockerNetworksByServer($server); $removeNetworks = $allNetworks->diff($networks); $commands = collect(); foreach ($removeNetworks as $network) { + echo "Checking network: $network\n"; $out = instant_remote_process(["docker network inspect -f json $network | jq '.[].Containers | if . == {} then null else . end'"], $server, false); if (empty($out)) { + echo "Network $network is empty, marking for removal\n"; $commands->push("docker network disconnect $network coolify-proxy >/dev/null 2>&1 || true"); $commands->push("docker network rm $network >/dev/null 2>&1 || true"); } else { @@ -179,6 +222,7 @@ class Init extends Command // If only coolify-proxy itself is connected to that network (it should not be possible, but who knows) $isCoolifyProxyItself = data_get($data->first(), 'Name') === 'coolify-proxy'; if ($isCoolifyProxyItself) { + echo "Network $network only has coolify-proxy, marking for removal\n"; $commands->push("docker network disconnect $network coolify-proxy >/dev/null 2>&1 || true"); $commands->push("docker network rm $network >/dev/null 2>&1 || true"); } @@ -186,6 +230,7 @@ class Init extends Command } } if ($commands->isNotEmpty()) { + echo "Executing network cleanup commands\n"; remote_process(command: $commands, type: ActivityTypes::INLINE->value, server: $server, ignore_errors: false); } } catch (\Throwable $e) { @@ -196,6 +241,7 @@ class Init extends Command private function restore_coolify_db_backup() { + echo "Checking if DB backup restore is needed...\n"; if (version_compare('4.0.0-beta.179', config('constants.coolify.version'), '<=')) { try { $database = StandalonePostgresql::withTrashed()->find(0); @@ -204,6 +250,7 @@ class Init extends Command $database->restore(); $scheduledBackup = ScheduledDatabaseBackup::find(0); if (! $scheduledBackup) { + echo "Creating scheduled backup\n"; ScheduledDatabaseBackup::create([ 'id' => 0, 'enabled' => true, @@ -223,6 +270,7 @@ class Init extends Command private function send_alive_signal() { + echo "Sending alive signal...\n"; $id = config('app.id'); $version = config('constants.coolify.version'); $settings = instanceSettings(); @@ -233,6 +281,7 @@ class Init extends Command return; } try { + echo "Sending request to undead.coolify.io\n"; Http::get("https://undead.coolify.io/v4/alive?appId=$id&version=$version"); } catch (\Throwable $e) { echo "Error in sending live signal: {$e->getMessage()}\n"; @@ -241,13 +290,18 @@ class Init extends Command private function cleanup_in_progress_application_deployments() { + echo "Starting cleanup of in-progress deployments...\n"; // Cleanup any failed deployments try { if (isCloud()) { + echo "Skipping cleanup in cloud mode\n"; + return; } + echo "Finding queued/in-progress deployments...\n"; $queued_inprogress_deployments = ApplicationDeploymentQueue::whereIn('status', [ApplicationDeploymentStatus::IN_PROGRESS->value, ApplicationDeploymentStatus::QUEUED->value])->get(); foreach ($queued_inprogress_deployments as $deployment) { + echo "Marking deployment {$deployment->id} as failed\n"; $deployment->status = ApplicationDeploymentStatus::FAILED->value; $deployment->save(); } @@ -258,10 +312,12 @@ class Init extends Command private function replace_slash_in_environment_name() { + echo "Checking for slashes in environment names...\n"; if (version_compare('4.0.0-beta.298', config('constants.coolify.version'), '<=')) { $environments = Environment::all(); foreach ($environments as $environment) { if (str_contains($environment->name, '/')) { + echo "Replacing slashes in environment: {$environment->name}\n"; $environment->name = str_replace('/', '-', $environment->name); $environment->save(); } diff --git a/database/seeders/ProductionSeeder.php b/database/seeders/ProductionSeeder.php index 1660e2694..6b7085128 100644 --- a/database/seeders/ProductionSeeder.php +++ b/database/seeders/ProductionSeeder.php @@ -21,6 +21,8 @@ class ProductionSeeder extends Seeder { public function run(): void { + echo "Starting ProductionSeeder...\n"; + if (isCloud()) { echo " Running in cloud mode.\n"; } else { @@ -28,8 +30,11 @@ class ProductionSeeder extends Seeder } // Fix for 4.0.0-beta.37 + echo "Checking for beta.37 fix...\n"; if (User::find(0) !== null && Team::find(0) !== null) { + echo " Found User 0 and Team 0\n"; if (DB::table('team_user')->where('user_id', 0)->first() === null) { + echo " Creating team_user relationship\n"; DB::table('team_user')->insert([ 'user_id' => 0, 'team_id' => 0, @@ -40,13 +45,17 @@ class ProductionSeeder extends Seeder } } + echo "Checking InstanceSettings...\n"; if (InstanceSettings::find(0) == null) { + echo " Creating InstanceSettings\n"; InstanceSettings::create([ 'id' => 0, ]); } + echo "Checking GithubApp...\n"; if (GithubApp::find(0) == null) { + echo " Creating GithubApp\n"; GithubApp::create([ 'id' => 0, 'name' => 'Public GitHub', @@ -56,7 +65,10 @@ class ProductionSeeder extends Seeder 'team_id' => 0, ]); } + + echo "Checking GitlabApp...\n"; if (GitlabApp::find(0) == null) { + echo " Creating GitlabApp\n"; GitlabApp::create([ 'id' => 0, 'name' => 'Public GitLab', @@ -66,9 +78,12 @@ class ProductionSeeder extends Seeder 'team_id' => 0, ]); } + // Add Coolify host (localhost) as Server if it doesn't exist if (! isCloud()) { + echo "Setting up localhost server...\n"; if (Server::find(0) == null) { + echo " Creating localhost server\n"; $server_details = [ 'id' => 0, 'name' => 'localhost', @@ -87,12 +102,16 @@ class ProductionSeeder extends Seeder $server->settings->is_usable = true; $server->settings->save(); } else { + echo " Updating existing localhost server\n"; $server = Server::find(0); $server->settings->is_reachable = true; $server->settings->is_usable = true; $server->settings->save(); } + + echo "Checking StandaloneDocker...\n"; if (StandaloneDocker::find(0) == null) { + echo " Creating StandaloneDocker\n"; StandaloneDocker::create([ 'id' => 0, 'name' => 'localhost-coolify', @@ -103,14 +122,17 @@ class ProductionSeeder extends Seeder } if (! isCloud() && config('constants.coolify.is_windows_docker_desktop') == false) { + echo "Setting up SSH keys for non-Windows environment...\n"; $coolify_key_name = '@host.docker.internal'; $ssh_keys_directory = Storage::disk('ssh-keys')->files(); + echo ' Found '.count($ssh_keys_directory)." SSH keys\n"; $coolify_key = collect($ssh_keys_directory)->firstWhere(fn ($item) => str($item)->contains($coolify_key_name)); $server = Server::find(0); $found = $server->privateKey; if (! $found) { if ($coolify_key) { + echo " Found Coolify SSH key\n"; $user = str($coolify_key)->before('@')->after('id.'); $coolify_key = Storage::disk('ssh-keys')->get($coolify_key); PrivateKey::create([ @@ -129,7 +151,10 @@ class ProductionSeeder extends Seeder } } } + if (config('constants.coolify.is_windows_docker_desktop')) { + echo "Setting up Windows Docker Desktop environment...\n"; + echo " Creating/updating private key\n"; PrivateKey::updateOrCreate( [ 'id' => 0, @@ -149,6 +174,7 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA== ] ); if (Server::find(0) == null) { + echo " Creating Windows localhost server\n"; $server_details = [ 'id' => 0, 'uuid' => 'coolify-testing-host', @@ -168,12 +194,16 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA== $server->settings->is_usable = true; $server->settings->save(); } else { + echo " Updating Windows localhost server\n"; $server = Server::find(0); $server->settings->is_reachable = true; $server->settings->is_usable = true; $server->settings->save(); } + + echo "Checking Windows StandaloneDocker...\n"; if (StandaloneDocker::find(0) == null) { + echo " Creating Windows StandaloneDocker\n"; StandaloneDocker::create([ 'id' => 0, 'name' => 'localhost-coolify', @@ -183,11 +213,19 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA== } } + echo "Getting public IPs...\n"; get_public_ips(); + echo "Running additional seeders...\n"; + echo " Running OauthSettingSeeder\n"; $this->call(OauthSettingSeeder::class); + echo " Running PopulateSshKeysDirectorySeeder\n"; $this->call(PopulateSshKeysDirectorySeeder::class); + echo " Running SentinelSeeder\n"; $this->call(SentinelSeeder::class); - // $this->call(RootUserSeeder::class); + echo " Running RootUserSeeder\n"; + $this->call(RootUserSeeder::class); + + echo "ProductionSeeder complete!\n"; } } From d3a6576a068e35e4ac3cb0e48eb2e58c9f263393 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 17 Jan 2025 12:14:03 +0100 Subject: [PATCH 02/11] fix: create the private key before the server in the prod seeder --- database/seeders/ProductionSeeder.php | 65 ++++++++++++++------------- 1 file changed, 33 insertions(+), 32 deletions(-) diff --git a/database/seeders/ProductionSeeder.php b/database/seeders/ProductionSeeder.php index 6b7085128..2ce7a56cc 100644 --- a/database/seeders/ProductionSeeder.php +++ b/database/seeders/ProductionSeeder.php @@ -21,6 +21,8 @@ class ProductionSeeder extends Seeder { public function run(): void { + + $user = 'root'; echo "Starting ProductionSeeder...\n"; if (isCloud()) { @@ -79,6 +81,36 @@ class ProductionSeeder extends Seeder ]); } + if (! isCloud() && config('constants.coolify.is_windows_docker_desktop') == false) { + echo "Setting up SSH keys for non-Windows environment...\n"; + $coolify_key_name = '@host.docker.internal'; + $ssh_keys_directory = Storage::disk('ssh-keys')->files(); + echo ' Found '.count($ssh_keys_directory)." SSH keys\n"; + $coolify_key = collect($ssh_keys_directory)->firstWhere(fn ($item) => str($item)->contains($coolify_key_name)); + + $server = Server::find(0); + $found = $server->privateKey; + if (! $found) { + if ($coolify_key) { + echo " Found Coolify SSH key\n"; + $user = str($coolify_key)->before('@')->after('id.'); + $coolify_key = Storage::disk('ssh-keys')->get($coolify_key); + PrivateKey::create([ + 'id' => 0, + 'team_id' => 0, + 'name' => 'localhost\'s key', + 'description' => 'The private key for the Coolify host machine (localhost).', + 'private_key' => $coolify_key, + ]); + echo "SSH key found for the Coolify host machine (localhost).\n"; + } else { + echo "No SSH key found for the Coolify host machine (localhost).\n"; + echo "Please read the following documentation (point 3) to fix it: https://coolify.io/docs/knowledge-base/server/openssh/\n"; + echo "Your localhost connection won't work until then."; + } + } + } + // Add Coolify host (localhost) as Server if it doesn't exist if (! isCloud()) { echo "Setting up localhost server...\n"; @@ -88,7 +120,7 @@ class ProductionSeeder extends Seeder 'id' => 0, 'name' => 'localhost', 'description' => "This is the server where Coolify is running on. Don't delete this!", - 'user' => 'root', + 'user' => $user, 'ip' => 'host.docker.internal', 'team_id' => 0, 'private_key_id' => 0, @@ -121,37 +153,6 @@ class ProductionSeeder extends Seeder } } - if (! isCloud() && config('constants.coolify.is_windows_docker_desktop') == false) { - echo "Setting up SSH keys for non-Windows environment...\n"; - $coolify_key_name = '@host.docker.internal'; - $ssh_keys_directory = Storage::disk('ssh-keys')->files(); - echo ' Found '.count($ssh_keys_directory)." SSH keys\n"; - $coolify_key = collect($ssh_keys_directory)->firstWhere(fn ($item) => str($item)->contains($coolify_key_name)); - - $server = Server::find(0); - $found = $server->privateKey; - if (! $found) { - if ($coolify_key) { - echo " Found Coolify SSH key\n"; - $user = str($coolify_key)->before('@')->after('id.'); - $coolify_key = Storage::disk('ssh-keys')->get($coolify_key); - PrivateKey::create([ - 'id' => 0, - 'team_id' => 0, - 'name' => 'localhost\'s key', - 'description' => 'The private key for the Coolify host machine (localhost).', - 'private_key' => $coolify_key, - ]); - $server->update(['user' => $user]); - echo "SSH key found for the Coolify host machine (localhost).\n"; - } else { - echo "No SSH key found for the Coolify host machine (localhost).\n"; - echo "Please read the following documentation (point 3) to fix it: https://coolify.io/docs/knowledge-base/server/openssh/\n"; - echo "Your localhost connection won't work until then."; - } - } - } - if (config('constants.coolify.is_windows_docker_desktop')) { echo "Setting up Windows Docker Desktop environment...\n"; echo " Creating/updating private key\n"; From 10b3c6b1079ea55633bc232368fb1329b700dcea Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 17 Jan 2025 12:24:31 +0100 Subject: [PATCH 03/11] fix: update ProductionSeeder to check for private key instead of server's private key --- database/seeders/ProductionSeeder.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/database/seeders/ProductionSeeder.php b/database/seeders/ProductionSeeder.php index 2ce7a56cc..e55240902 100644 --- a/database/seeders/ProductionSeeder.php +++ b/database/seeders/ProductionSeeder.php @@ -88,9 +88,8 @@ class ProductionSeeder extends Seeder echo ' Found '.count($ssh_keys_directory)." SSH keys\n"; $coolify_key = collect($ssh_keys_directory)->firstWhere(fn ($item) => str($item)->contains($coolify_key_name)); - $server = Server::find(0); - $found = $server->privateKey; - if (! $found) { + $private_key_found = PrivateKey::find(0); + if (! $private_key_found) { if ($coolify_key) { echo " Found Coolify SSH key\n"; $user = str($coolify_key)->before('@')->after('id.'); From d043fbfeb956d82002f3528e7be6f786d7a48f31 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 17 Jan 2025 12:33:03 +0100 Subject: [PATCH 04/11] refactor: streamline ProductionSeeder by removing debug logs and unnecessary checks, while ensuring essential seeding operations remain intact --- database/seeders/ProductionSeeder.php | 44 ++------------------------- 1 file changed, 2 insertions(+), 42 deletions(-) diff --git a/database/seeders/ProductionSeeder.php b/database/seeders/ProductionSeeder.php index e55240902..268fd8291 100644 --- a/database/seeders/ProductionSeeder.php +++ b/database/seeders/ProductionSeeder.php @@ -21,22 +21,10 @@ class ProductionSeeder extends Seeder { public function run(): void { - $user = 'root'; - echo "Starting ProductionSeeder...\n"; - if (isCloud()) { - echo " Running in cloud mode.\n"; - } else { - echo " Running in self-hosted mode.\n"; - } - - // Fix for 4.0.0-beta.37 - echo "Checking for beta.37 fix...\n"; if (User::find(0) !== null && Team::find(0) !== null) { - echo " Found User 0 and Team 0\n"; if (DB::table('team_user')->where('user_id', 0)->first() === null) { - echo " Creating team_user relationship\n"; DB::table('team_user')->insert([ 'user_id' => 0, 'team_id' => 0, @@ -47,17 +35,13 @@ class ProductionSeeder extends Seeder } } - echo "Checking InstanceSettings...\n"; if (InstanceSettings::find(0) == null) { - echo " Creating InstanceSettings\n"; InstanceSettings::create([ 'id' => 0, ]); } - echo "Checking GithubApp...\n"; if (GithubApp::find(0) == null) { - echo " Creating GithubApp\n"; GithubApp::create([ 'id' => 0, 'name' => 'Public GitHub', @@ -68,9 +52,7 @@ class ProductionSeeder extends Seeder ]); } - echo "Checking GitlabApp...\n"; if (GitlabApp::find(0) == null) { - echo " Creating GitlabApp\n"; GitlabApp::create([ 'id' => 0, 'name' => 'Public GitLab', @@ -82,16 +64,13 @@ class ProductionSeeder extends Seeder } if (! isCloud() && config('constants.coolify.is_windows_docker_desktop') == false) { - echo "Setting up SSH keys for non-Windows environment...\n"; $coolify_key_name = '@host.docker.internal'; $ssh_keys_directory = Storage::disk('ssh-keys')->files(); - echo ' Found '.count($ssh_keys_directory)." SSH keys\n"; $coolify_key = collect($ssh_keys_directory)->firstWhere(fn ($item) => str($item)->contains($coolify_key_name)); $private_key_found = PrivateKey::find(0); if (! $private_key_found) { if ($coolify_key) { - echo " Found Coolify SSH key\n"; $user = str($coolify_key)->before('@')->after('id.'); $coolify_key = Storage::disk('ssh-keys')->get($coolify_key); PrivateKey::create([ @@ -104,17 +83,15 @@ class ProductionSeeder extends Seeder echo "SSH key found for the Coolify host machine (localhost).\n"; } else { echo "No SSH key found for the Coolify host machine (localhost).\n"; - echo "Please read the following documentation (point 3) to fix it: https://coolify.io/docs/knowledge-base/server/openssh/\n"; + echo "Please read the following documentation (point 3) to fix it: https://coolify. + io/docs/knowledge-base/server/openssh/\n"; echo "Your localhost connection won't work until then."; } } } - // Add Coolify host (localhost) as Server if it doesn't exist if (! isCloud()) { - echo "Setting up localhost server...\n"; if (Server::find(0) == null) { - echo " Creating localhost server\n"; $server_details = [ 'id' => 0, 'name' => 'localhost', @@ -133,16 +110,13 @@ class ProductionSeeder extends Seeder $server->settings->is_usable = true; $server->settings->save(); } else { - echo " Updating existing localhost server\n"; $server = Server::find(0); $server->settings->is_reachable = true; $server->settings->is_usable = true; $server->settings->save(); } - echo "Checking StandaloneDocker...\n"; if (StandaloneDocker::find(0) == null) { - echo " Creating StandaloneDocker\n"; StandaloneDocker::create([ 'id' => 0, 'name' => 'localhost-coolify', @@ -153,8 +127,6 @@ class ProductionSeeder extends Seeder } if (config('constants.coolify.is_windows_docker_desktop')) { - echo "Setting up Windows Docker Desktop environment...\n"; - echo " Creating/updating private key\n"; PrivateKey::updateOrCreate( [ 'id' => 0, @@ -174,7 +146,6 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA== ] ); if (Server::find(0) == null) { - echo " Creating Windows localhost server\n"; $server_details = [ 'id' => 0, 'uuid' => 'coolify-testing-host', @@ -194,16 +165,13 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA== $server->settings->is_usable = true; $server->settings->save(); } else { - echo " Updating Windows localhost server\n"; $server = Server::find(0); $server->settings->is_reachable = true; $server->settings->is_usable = true; $server->settings->save(); } - echo "Checking Windows StandaloneDocker...\n"; if (StandaloneDocker::find(0) == null) { - echo " Creating Windows StandaloneDocker\n"; StandaloneDocker::create([ 'id' => 0, 'name' => 'localhost-coolify', @@ -213,19 +181,11 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA== } } - echo "Getting public IPs...\n"; get_public_ips(); - echo "Running additional seeders...\n"; - echo " Running OauthSettingSeeder\n"; $this->call(OauthSettingSeeder::class); - echo " Running PopulateSshKeysDirectorySeeder\n"; $this->call(PopulateSshKeysDirectorySeeder::class); - echo " Running SentinelSeeder\n"; $this->call(SentinelSeeder::class); - echo " Running RootUserSeeder\n"; $this->call(RootUserSeeder::class); - - echo "ProductionSeeder complete!\n"; } } From 03c50a387cdb85c7bb735a50ca539c7d9bca772e Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 17 Jan 2025 12:35:22 +0100 Subject: [PATCH 05/11] refactor: remove debug echo statements from Init command to clean up output and improve readability --- app/Console/Commands/Init.php | 50 +---------------------------------- 1 file changed, 1 insertion(+), 49 deletions(-) diff --git a/app/Console/Commands/Init.php b/app/Console/Commands/Init.php index 03fc5380d..1e4663073 100644 --- a/app/Console/Commands/Init.php +++ b/app/Console/Commands/Init.php @@ -26,7 +26,6 @@ class Init extends Command public function handle() { - echo "Starting handle()\n"; $this->optimize(); if (isCloud() && ! $this->option('force-cloud')) { @@ -35,7 +34,6 @@ class Init extends Command return; } - echo "Loading servers...\n"; $this->servers = Server::all(); if (isCloud()) { echo "Running in cloud mode\n"; @@ -45,7 +43,6 @@ class Init extends Command get_public_ips(); } - echo "Starting backward compatibility checks...\n"; // Backward compatibility $this->replace_slash_in_environment_name(); $this->restore_coolify_db_backup(); @@ -53,24 +50,18 @@ class Init extends Command // $this->update_traefik_labels(); if (! isCloud() || $this->option('force-cloud')) { - echo "Cleaning up unused networks...\n"; $this->cleanup_unused_network_from_coolify_proxy(); } if (isCloud()) { - echo "Cleaning up unnecessary proxy configs...\n"; $this->cleanup_unnecessary_dynamic_proxy_configuration(); } else { - echo "Cleaning up in-progress deployments...\n"; $this->cleanup_in_progress_application_deployments(); } - echo "Running redis cleanup...\n"; $this->call('cleanup:redis'); - echo "Running stucked resources cleanup...\n"; $this->call('cleanup:stucked-resources'); try { - echo "Pulling helper image...\n"; $this->pullHelperImage(); } catch (\Throwable $e) { echo "Error pulling helper image: {$e->getMessage()}\n"; @@ -78,7 +69,6 @@ class Init extends Command if (isCloud()) { try { - echo "Pulling templates from CDN (cloud mode)...\n"; $this->pullTemplatesFromCDN(); } catch (\Throwable $e) { echo "Could not pull templates from CDN: {$e->getMessage()}\n"; @@ -87,19 +77,16 @@ class Init extends Command if (! isCloud()) { try { - echo "Pulling templates from CDN (self-hosted mode)...\n"; $this->pullTemplatesFromCDN(); } catch (\Throwable $e) { echo "Could not pull templates from CDN: {$e->getMessage()}\n"; } try { - echo "Setting up localhost proxy config...\n"; $localhost = $this->servers->where('id', 0)->first(); $localhost->setupDynamicProxyConfiguration(); } catch (\Throwable $e) { echo "Could not setup dynamic configuration: {$e->getMessage()}\n"; } - echo "Checking auto-update settings...\n"; $settings = instanceSettings(); if (! is_null(config('constants.coolify.autoupdate', null))) { if (config('constants.coolify.autoupdate') == true) { @@ -111,21 +98,17 @@ class Init extends Command } } } - echo "handle() complete\n"; } private function pullHelperImage() { - echo "Dispatching CheckHelperImageJob\n"; CheckHelperImageJob::dispatch(); } private function pullTemplatesFromCDN() { - echo 'Pulling templates from '.config('constants.services.official')."\n"; $response = Http::retry(3, 1000)->get(config('constants.services.official')); if ($response->successful()) { - echo "Successfully pulled templates\n"; $services = $response->json(); File::put(base_path('templates/service-templates.json'), json_encode($services)); } @@ -133,18 +116,15 @@ class Init extends Command private function optimize() { - echo "Running optimize:clear\n"; Artisan::call('optimize:clear'); - echo "Running optimize\n"; Artisan::call('optimize'); } private function update_user_emails() { - echo "Starting user email updates...\n"; try { User::whereRaw('email ~ \'[A-Z]\'')->get()->each(function (User $user) { - echo "Converting email to lowercase: {$user->email}\n"; + $user->update(['email' => strtolower($user->email)]); $user->update(['email' => strtolower($user->email)]); }); } catch (\Throwable $e) { @@ -154,10 +134,8 @@ class Init extends Command private function update_traefik_labels() { - echo "Updating traefik labels...\n"; try { Server::where('proxy->type', 'TRAEFIK_V2')->update(['proxy->type' => 'TRAEFIK']); - echo "Traefik labels updated successfully\n"; } catch (\Throwable $e) { echo "Error in updating traefik labels: {$e->getMessage()}\n"; } @@ -165,21 +143,15 @@ class Init extends Command private function cleanup_unnecessary_dynamic_proxy_configuration() { - echo "Starting cleanup of unnecessary proxy configs...\n"; foreach ($this->servers as $server) { try { if (! $server->isFunctional()) { - echo "Server {$server->id} not functional, skipping\n"; - continue; } if ($server->id === 0) { - echo "Skipping localhost server\n"; - continue; } $file = $server->proxyPath().'/dynamic/coolify.yaml'; - echo "Removing file: $file\n"; return instant_remote_process([ "rm -f $file", @@ -192,28 +164,20 @@ class Init extends Command private function cleanup_unused_network_from_coolify_proxy() { - echo "Starting cleanup of unused networks...\n"; foreach ($this->servers as $server) { if (! $server->isFunctional()) { - echo "Server {$server->id} not functional, skipping\n"; - continue; } if (! $server->isProxyShouldRun()) { - echo "Proxy should not run on server {$server->id}, skipping\n"; - continue; } try { - echo "Collecting docker networks for server {$server->id}\n"; ['networks' => $networks, 'allNetworks' => $allNetworks] = collectDockerNetworksByServer($server); $removeNetworks = $allNetworks->diff($networks); $commands = collect(); foreach ($removeNetworks as $network) { - echo "Checking network: $network\n"; $out = instant_remote_process(["docker network inspect -f json $network | jq '.[].Containers | if . == {} then null else . end'"], $server, false); if (empty($out)) { - echo "Network $network is empty, marking for removal\n"; $commands->push("docker network disconnect $network coolify-proxy >/dev/null 2>&1 || true"); $commands->push("docker network rm $network >/dev/null 2>&1 || true"); } else { @@ -222,7 +186,6 @@ class Init extends Command // If only coolify-proxy itself is connected to that network (it should not be possible, but who knows) $isCoolifyProxyItself = data_get($data->first(), 'Name') === 'coolify-proxy'; if ($isCoolifyProxyItself) { - echo "Network $network only has coolify-proxy, marking for removal\n"; $commands->push("docker network disconnect $network coolify-proxy >/dev/null 2>&1 || true"); $commands->push("docker network rm $network >/dev/null 2>&1 || true"); } @@ -230,7 +193,6 @@ class Init extends Command } } if ($commands->isNotEmpty()) { - echo "Executing network cleanup commands\n"; remote_process(command: $commands, type: ActivityTypes::INLINE->value, server: $server, ignore_errors: false); } } catch (\Throwable $e) { @@ -241,16 +203,13 @@ class Init extends Command private function restore_coolify_db_backup() { - echo "Checking if DB backup restore is needed...\n"; if (version_compare('4.0.0-beta.179', config('constants.coolify.version'), '<=')) { try { $database = StandalonePostgresql::withTrashed()->find(0); if ($database && $database->trashed()) { - echo "Restoring coolify db backup\n"; $database->restore(); $scheduledBackup = ScheduledDatabaseBackup::find(0); if (! $scheduledBackup) { - echo "Creating scheduled backup\n"; ScheduledDatabaseBackup::create([ 'id' => 0, 'enabled' => true, @@ -281,7 +240,6 @@ class Init extends Command return; } try { - echo "Sending request to undead.coolify.io\n"; Http::get("https://undead.coolify.io/v4/alive?appId=$id&version=$version"); } catch (\Throwable $e) { echo "Error in sending live signal: {$e->getMessage()}\n"; @@ -290,15 +248,11 @@ class Init extends Command private function cleanup_in_progress_application_deployments() { - echo "Starting cleanup of in-progress deployments...\n"; // Cleanup any failed deployments try { if (isCloud()) { - echo "Skipping cleanup in cloud mode\n"; - return; } - echo "Finding queued/in-progress deployments...\n"; $queued_inprogress_deployments = ApplicationDeploymentQueue::whereIn('status', [ApplicationDeploymentStatus::IN_PROGRESS->value, ApplicationDeploymentStatus::QUEUED->value])->get(); foreach ($queued_inprogress_deployments as $deployment) { echo "Marking deployment {$deployment->id} as failed\n"; @@ -312,12 +266,10 @@ class Init extends Command private function replace_slash_in_environment_name() { - echo "Checking for slashes in environment names...\n"; if (version_compare('4.0.0-beta.298', config('constants.coolify.version'), '<=')) { $environments = Environment::all(); foreach ($environments as $environment) { if (str_contains($environment->name, '/')) { - echo "Replacing slashes in environment: {$environment->name}\n"; $environment->name = str_replace('/', '-', $environment->name); $environment->save(); } From 37e4bfe93ffa15fdac99dafb51bf08059e19e6d7 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 17 Jan 2025 13:16:06 +0100 Subject: [PATCH 06/11] test php8.2 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index f01913b5f..830e489ca 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ "server" ], "require": { - "php": "^8.4", + "php": "^8.2", "3sidedcube/laravel-redoc": "^1.0", "danharrin/livewire-rate-limiting": "2.0.0", "doctrine/dbal": "^4.2", From 56ae346b9d7802ca67a99d1aeb8d431749d19747 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 17 Jan 2025 13:22:04 +0100 Subject: [PATCH 07/11] test --- database/seeders/ProductionSeeder.php | 57 ++++++++++++++------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/database/seeders/ProductionSeeder.php b/database/seeders/ProductionSeeder.php index 268fd8291..3bcf7d193 100644 --- a/database/seeders/ProductionSeeder.php +++ b/database/seeders/ProductionSeeder.php @@ -63,40 +63,13 @@ class ProductionSeeder extends Seeder ]); } - if (! isCloud() && config('constants.coolify.is_windows_docker_desktop') == false) { - $coolify_key_name = '@host.docker.internal'; - $ssh_keys_directory = Storage::disk('ssh-keys')->files(); - $coolify_key = collect($ssh_keys_directory)->firstWhere(fn ($item) => str($item)->contains($coolify_key_name)); - - $private_key_found = PrivateKey::find(0); - if (! $private_key_found) { - if ($coolify_key) { - $user = str($coolify_key)->before('@')->after('id.'); - $coolify_key = Storage::disk('ssh-keys')->get($coolify_key); - PrivateKey::create([ - 'id' => 0, - 'team_id' => 0, - 'name' => 'localhost\'s key', - 'description' => 'The private key for the Coolify host machine (localhost).', - 'private_key' => $coolify_key, - ]); - echo "SSH key found for the Coolify host machine (localhost).\n"; - } else { - echo "No SSH key found for the Coolify host machine (localhost).\n"; - echo "Please read the following documentation (point 3) to fix it: https://coolify. - io/docs/knowledge-base/server/openssh/\n"; - echo "Your localhost connection won't work until then."; - } - } - } - if (! isCloud()) { if (Server::find(0) == null) { $server_details = [ 'id' => 0, 'name' => 'localhost', 'description' => "This is the server where Coolify is running on. Don't delete this!", - 'user' => $user, + 'user' => 'root', 'ip' => 'host.docker.internal', 'team_id' => 0, 'private_key_id' => 0, @@ -125,7 +98,35 @@ class ProductionSeeder extends Seeder ]); } } + if (! isCloud() && config('constants.coolify.is_windows_docker_desktop') == false) { + $coolify_key_name = '@host.docker.internal'; + $ssh_keys_directory = Storage::disk('ssh-keys')->files(); + $coolify_key = collect($ssh_keys_directory)->firstWhere(fn ($item) => str($item)->contains($coolify_key_name)); + $private_key_found = PrivateKey::find(0); + if (! $private_key_found) { + if ($coolify_key) { + $user = str($coolify_key)->before('@')->after('id.'); + $coolify_key = Storage::disk('ssh-keys')->get($coolify_key); + PrivateKey::create([ + 'id' => 0, + 'team_id' => 0, + 'name' => 'localhost\'s key', + 'description' => 'The private key for the Coolify host machine (localhost).', + 'private_key' => $coolify_key, + ]); + $server = Server::find(0); + $server->user = $user; + $server->save(); + echo "SSH key found for the Coolify host machine (localhost).\n"; + } else { + echo "No SSH key found for the Coolify host machine (localhost).\n"; + echo "Please read the following documentation (point 3) to fix it: https://coolify. + io/docs/knowledge-base/server/openssh/\n"; + echo "Your localhost connection won't work until then."; + } + } + } if (config('constants.coolify.is_windows_docker_desktop')) { PrivateKey::updateOrCreate( [ From 4f37b310d5c13fbb8b110722d04e63e595a05f89 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 17 Jan 2025 13:33:13 +0100 Subject: [PATCH 08/11] hmm --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 830e489ca..b983f6ed8 100644 --- a/composer.json +++ b/composer.json @@ -11,13 +11,13 @@ "server" ], "require": { - "php": "^8.2", + "php": "^8.4", "3sidedcube/laravel-redoc": "^1.0", "danharrin/livewire-rate-limiting": "2.0.0", "doctrine/dbal": "^4.2", "guzzlehttp/guzzle": "^7.5.0", "laravel/fortify": "^1.16.0", - "laravel/framework": "^11.0", + "laravel/framework": "11.35.0", "laravel/horizon": "^5.29.1", "laravel/pail": "^1.1", "laravel/prompts": "^0.1.18|^0.2.0|^0.3.0", From 78cd01d230904f38106aa9789db32b47fb796b77 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 17 Jan 2025 13:35:28 +0100 Subject: [PATCH 09/11] lock --- composer.lock | 151 +++++++++++++++++++++++++------------------------- 1 file changed, 75 insertions(+), 76 deletions(-) diff --git a/composer.lock b/composer.lock index 0d70b8629..998584b4f 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": "83823b6e6da5f7d476556d5c95620f5b", + "content-hash": "ef45e2ecf9ff00aa6c51c0f49fd072e0", "packages": [ { "name": "3sidedcube/laravel-redoc", @@ -928,16 +928,16 @@ }, { "name": "aws/aws-sdk-php", - "version": "3.336.14", + "version": "3.337.1", "source": { "type": "git", "url": "https://github.com/aws/aws-sdk-php.git", - "reference": "dc9ac0ab313bbfc4e41635ce6d6083f28d202bf0" + "reference": "fa70febad922e9868c83bfe03c6d078fc2633e17" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/dc9ac0ab313bbfc4e41635ce6d6083f28d202bf0", - "reference": "dc9ac0ab313bbfc4e41635ce6d6083f28d202bf0", + "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/fa70febad922e9868c83bfe03c6d078fc2633e17", + "reference": "fa70febad922e9868c83bfe03c6d078fc2633e17", "shasum": "" }, "require": { @@ -1020,9 +1020,9 @@ "support": { "forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80", "issues": "https://github.com/aws/aws-sdk-php/issues", - "source": "https://github.com/aws/aws-sdk-php/tree/3.336.14" + "source": "https://github.com/aws/aws-sdk-php/tree/3.337.1" }, - "time": "2025-01-13T19:04:40+00:00" + "time": "2025-01-16T19:12:46+00:00" }, { "name": "bacon/bacon-qr-code", @@ -1432,16 +1432,16 @@ }, { "name": "doctrine/dbal", - "version": "4.2.1", + "version": "4.2.2", "source": { "type": "git", "url": "https://github.com/doctrine/dbal.git", - "reference": "dadd35300837a3a2184bd47d403333b15d0a9bd0" + "reference": "19a2b7deb5fe8c2df0ff817ecea305e50acb62ec" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/dbal/zipball/dadd35300837a3a2184bd47d403333b15d0a9bd0", - "reference": "dadd35300837a3a2184bd47d403333b15d0a9bd0", + "url": "https://api.github.com/repos/doctrine/dbal/zipball/19a2b7deb5fe8c2df0ff817ecea305e50acb62ec", + "reference": "19a2b7deb5fe8c2df0ff817ecea305e50acb62ec", "shasum": "" }, "require": { @@ -1454,16 +1454,14 @@ "doctrine/coding-standard": "12.0.0", "fig/log-test": "^1", "jetbrains/phpstorm-stubs": "2023.2", - "phpstan/phpstan": "1.12.6", - "phpstan/phpstan-phpunit": "1.4.0", - "phpstan/phpstan-strict-rules": "^1.6", - "phpunit/phpunit": "10.5.30", - "psalm/plugin-phpunit": "0.19.0", + "phpstan/phpstan": "2.1.1", + "phpstan/phpstan-phpunit": "2.0.3", + "phpstan/phpstan-strict-rules": "^2", + "phpunit/phpunit": "10.5.39", "slevomat/coding-standard": "8.13.1", "squizlabs/php_codesniffer": "3.10.2", "symfony/cache": "^6.3.8|^7.0", - "symfony/console": "^5.4|^6.3|^7.0", - "vimeo/psalm": "5.25.0" + "symfony/console": "^5.4|^6.3|^7.0" }, "suggest": { "symfony/console": "For helpful console commands such as SQL execution and import of files." @@ -1520,7 +1518,7 @@ ], "support": { "issues": "https://github.com/doctrine/dbal/issues", - "source": "https://github.com/doctrine/dbal/tree/4.2.1" + "source": "https://github.com/doctrine/dbal/tree/4.2.2" }, "funding": [ { @@ -1536,7 +1534,7 @@ "type": "tidelift" } ], - "time": "2024-10-10T18:01:27+00:00" + "time": "2025-01-16T08:40:56+00:00" }, { "name": "doctrine/deprecations", @@ -2670,16 +2668,16 @@ }, { "name": "laravel/fortify", - "version": "v1.25.1", + "version": "v1.25.2", "source": { "type": "git", "url": "https://github.com/laravel/fortify.git", - "reference": "5022e7c01385fd6edcef91c12b19071f8f20d6d8" + "reference": "a20e8033e7329b05820007c398f06065a38ae188" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/fortify/zipball/5022e7c01385fd6edcef91c12b19071f8f20d6d8", - "reference": "5022e7c01385fd6edcef91c12b19071f8f20d6d8", + "url": "https://api.github.com/repos/laravel/fortify/zipball/a20e8033e7329b05820007c398f06065a38ae188", + "reference": "a20e8033e7329b05820007c398f06065a38ae188", "shasum": "" }, "require": { @@ -2731,20 +2729,20 @@ "issues": "https://github.com/laravel/fortify/issues", "source": "https://github.com/laravel/fortify" }, - "time": "2024-11-27T14:51:15+00:00" + "time": "2025-01-10T20:33:47+00:00" }, { "name": "laravel/framework", - "version": "v11.37.0", + "version": "v11.35.0", "source": { "type": "git", "url": "https://github.com/laravel/framework.git", - "reference": "6cb103d2024b087eae207654b3f4b26646119ba5" + "reference": "f1a7aaa3c1235b7a95ccaa58db90e0cd9d8c3fcc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/framework/zipball/6cb103d2024b087eae207654b3f4b26646119ba5", - "reference": "6cb103d2024b087eae207654b3f4b26646119ba5", + "url": "https://api.github.com/repos/laravel/framework/zipball/f1a7aaa3c1235b7a95ccaa58db90e0cd9d8c3fcc", + "reference": "f1a7aaa3c1235b7a95ccaa58db90e0cd9d8c3fcc", "shasum": "" }, "require": { @@ -2765,7 +2763,7 @@ "guzzlehttp/uri-template": "^1.0", "laravel/prompts": "^0.1.18|^0.2.0|^0.3.0", "laravel/serializable-closure": "^1.3|^2.0", - "league/commonmark": "^2.6", + "league/commonmark": "^2.2.1", "league/flysystem": "^3.25.1", "league/flysystem-local": "^3.25.1", "league/uri": "^7.5.1", @@ -2780,7 +2778,7 @@ "symfony/console": "^7.0.3", "symfony/error-handler": "^7.0.3", "symfony/finder": "^7.0.3", - "symfony/http-foundation": "^7.2.0", + "symfony/http-foundation": "^7.0.3", "symfony/http-kernel": "^7.0.3", "symfony/mailer": "^7.0.3", "symfony/mime": "^7.0.3", @@ -2794,6 +2792,7 @@ "voku/portable-ascii": "^2.0.2" }, "conflict": { + "mockery/mockery": "1.6.8", "tightenco/collect": "<5.5.33" }, "provide": { @@ -2945,20 +2944,20 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2025-01-02T20:10:21+00:00" + "time": "2024-12-10T16:09:29+00:00" }, { "name": "laravel/horizon", - "version": "v5.30.1", + "version": "v5.30.2", "source": { "type": "git", "url": "https://github.com/laravel/horizon.git", - "reference": "77177646679ef2f2acf71d4d4b16036d18002040" + "reference": "baef526f036717b0090754cbd9c9b67f879739fd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/horizon/zipball/77177646679ef2f2acf71d4d4b16036d18002040", - "reference": "77177646679ef2f2acf71d4d4b16036d18002040", + "url": "https://api.github.com/repos/laravel/horizon/zipball/baef526f036717b0090754cbd9c9b67f879739fd", + "reference": "baef526f036717b0090754cbd9c9b67f879739fd", "shasum": "" }, "require": { @@ -3023,9 +3022,9 @@ ], "support": { "issues": "https://github.com/laravel/horizon/issues", - "source": "https://github.com/laravel/horizon/tree/v5.30.1" + "source": "https://github.com/laravel/horizon/tree/v5.30.2" }, - "time": "2024-12-13T14:08:51+00:00" + "time": "2025-01-13T16:51:22+00:00" }, { "name": "laravel/pail", @@ -3107,16 +3106,16 @@ }, { "name": "laravel/prompts", - "version": "v0.3.2", + "version": "v0.3.3", "source": { "type": "git", "url": "https://github.com/laravel/prompts.git", - "reference": "0e0535747c6b8d6d10adca8b68293cf4517abb0f" + "reference": "749395fcd5f8f7530fe1f00dfa84eb22c83d94ea" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/prompts/zipball/0e0535747c6b8d6d10adca8b68293cf4517abb0f", - "reference": "0e0535747c6b8d6d10adca8b68293cf4517abb0f", + "url": "https://api.github.com/repos/laravel/prompts/zipball/749395fcd5f8f7530fe1f00dfa84eb22c83d94ea", + "reference": "749395fcd5f8f7530fe1f00dfa84eb22c83d94ea", "shasum": "" }, "require": { @@ -3160,9 +3159,9 @@ "description": "Add beautiful and user-friendly forms to your command-line applications.", "support": { "issues": "https://github.com/laravel/prompts/issues", - "source": "https://github.com/laravel/prompts/tree/v0.3.2" + "source": "https://github.com/laravel/prompts/tree/v0.3.3" }, - "time": "2024-11-12T14:59:47+00:00" + "time": "2024-12-30T15:53:31+00:00" }, { "name": "laravel/sanctum", @@ -11756,16 +11755,16 @@ }, { "name": "zircote/swagger-php", - "version": "5.0.2", + "version": "5.0.3", "source": { "type": "git", "url": "https://github.com/zircote/swagger-php.git", - "reference": "c6956de52edb270da4df2630b938c9ac3e26e42f" + "reference": "7708510b17502a416214148edaa8c9958b23b6cd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zircote/swagger-php/zipball/c6956de52edb270da4df2630b938c9ac3e26e42f", - "reference": "c6956de52edb270da4df2630b938c9ac3e26e42f", + "url": "https://api.github.com/repos/zircote/swagger-php/zipball/7708510b17502a416214148edaa8c9958b23b6cd", + "reference": "7708510b17502a416214148edaa8c9958b23b6cd", "shasum": "" }, "require": { @@ -11836,9 +11835,9 @@ ], "support": { "issues": "https://github.com/zircote/swagger-php/issues", - "source": "https://github.com/zircote/swagger-php/tree/5.0.2" + "source": "https://github.com/zircote/swagger-php/tree/5.0.3" }, - "time": "2025-01-09T19:42:31+00:00" + "time": "2025-01-15T21:02:43+00:00" } ], "packages-dev": [ @@ -12302,16 +12301,16 @@ }, { "name": "laravel/dusk", - "version": "v8.2.12", + "version": "v8.2.13", "source": { "type": "git", "url": "https://github.com/laravel/dusk.git", - "reference": "a399aa31c1c9cef793ad747403017e56df77396c" + "reference": "8ddd53a74c2e6f9c3b68cf8189dad44077b585b0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/dusk/zipball/a399aa31c1c9cef793ad747403017e56df77396c", - "reference": "a399aa31c1c9cef793ad747403017e56df77396c", + "url": "https://api.github.com/repos/laravel/dusk/zipball/8ddd53a74c2e6f9c3b68cf8189dad44077b585b0", + "reference": "8ddd53a74c2e6f9c3b68cf8189dad44077b585b0", "shasum": "" }, "require": { @@ -12368,22 +12367,22 @@ ], "support": { "issues": "https://github.com/laravel/dusk/issues", - "source": "https://github.com/laravel/dusk/tree/v8.2.12" + "source": "https://github.com/laravel/dusk/tree/v8.2.13" }, - "time": "2024-11-21T17:37:39+00:00" + "time": "2025-01-06T14:52:17+00:00" }, { "name": "laravel/pint", - "version": "v1.19.0", + "version": "v1.20.0", "source": { "type": "git", "url": "https://github.com/laravel/pint.git", - "reference": "8169513746e1bac70c85d6ea1524d9225d4886f0" + "reference": "53072e8ea22213a7ed168a8a15b96fbb8b82d44b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/pint/zipball/8169513746e1bac70c85d6ea1524d9225d4886f0", - "reference": "8169513746e1bac70c85d6ea1524d9225d4886f0", + "url": "https://api.github.com/repos/laravel/pint/zipball/53072e8ea22213a7ed168a8a15b96fbb8b82d44b", + "reference": "53072e8ea22213a7ed168a8a15b96fbb8b82d44b", "shasum": "" }, "require": { @@ -12436,20 +12435,20 @@ "issues": "https://github.com/laravel/pint/issues", "source": "https://github.com/laravel/pint" }, - "time": "2024-12-30T16:20:10+00:00" + "time": "2025-01-14T16:20:53+00:00" }, { "name": "laravel/telescope", - "version": "v5.2.6", + "version": "v5.3.0", "source": { "type": "git", "url": "https://github.com/laravel/telescope.git", - "reference": "7ee46fbea8e3b01108575c8edf7377abddfe8bb9" + "reference": "216fd8d41eb17b49469bea9359b4f0f711b882b3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/telescope/zipball/7ee46fbea8e3b01108575c8edf7377abddfe8bb9", - "reference": "7ee46fbea8e3b01108575c8edf7377abddfe8bb9", + "url": "https://api.github.com/repos/laravel/telescope/zipball/216fd8d41eb17b49469bea9359b4f0f711b882b3", + "reference": "216fd8d41eb17b49469bea9359b4f0f711b882b3", "shasum": "" }, "require": { @@ -12503,9 +12502,9 @@ ], "support": { "issues": "https://github.com/laravel/telescope/issues", - "source": "https://github.com/laravel/telescope/tree/v5.2.6" + "source": "https://github.com/laravel/telescope/tree/v5.3.0" }, - "time": "2024-11-25T20:34:58+00:00" + "time": "2024-12-26T21:37:35+00:00" }, { "name": "maximebf/debugbar", @@ -14792,16 +14791,16 @@ }, { "name": "serversideup/spin", - "version": "v3.0.1", + "version": "v3.0.2", "source": { "type": "git", "url": "https://github.com/serversideup/spin.git", - "reference": "ed3ee8f2b9eeaf9e2a0654438441a1eb8ccf5d3d" + "reference": "f0e9c78dad8fd86db6030871a9f143fd6ab918e3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/serversideup/spin/zipball/ed3ee8f2b9eeaf9e2a0654438441a1eb8ccf5d3d", - "reference": "ed3ee8f2b9eeaf9e2a0654438441a1eb8ccf5d3d", + "url": "https://api.github.com/repos/serversideup/spin/zipball/f0e9c78dad8fd86db6030871a9f143fd6ab918e3", + "reference": "f0e9c78dad8fd86db6030871a9f143fd6ab918e3", "shasum": "" }, "bin": [ @@ -14825,7 +14824,7 @@ "description": "Replicate your production environment locally using Docker. Just run \"spin up\". It's really that easy.", "support": { "issues": "https://github.com/serversideup/spin/issues", - "source": "https://github.com/serversideup/spin/tree/v3.0.1" + "source": "https://github.com/serversideup/spin/tree/v3.0.2" }, "funding": [ { @@ -14833,7 +14832,7 @@ "type": "github" } ], - "time": "2024-12-20T17:23:06+00:00" + "time": "2025-01-14T19:02:40+00:00" }, { "name": "spatie/error-solutions", @@ -15489,12 +15488,12 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": {}, "prefer-stable": true, "prefer-lowest": false, "platform": { "php": "^8.4" }, - "platform-dev": [], - "plugin-api-version": "2.3.0" + "platform-dev": {}, + "plugin-api-version": "2.6.0" } From 6e9960c010305f15fa2e58a6f7bf89ef3ccf3b0b Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 17 Jan 2025 13:44:37 +0100 Subject: [PATCH 10/11] revert revert so it will be good (say what?) --- composer.json | 2 +- composer.lock | 17 ++++---- database/seeders/ProductionSeeder.php | 57 +++++++++++++-------------- 3 files changed, 37 insertions(+), 39 deletions(-) diff --git a/composer.json b/composer.json index b983f6ed8..f01913b5f 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ "doctrine/dbal": "^4.2", "guzzlehttp/guzzle": "^7.5.0", "laravel/fortify": "^1.16.0", - "laravel/framework": "11.35.0", + "laravel/framework": "^11.0", "laravel/horizon": "^5.29.1", "laravel/pail": "^1.1", "laravel/prompts": "^0.1.18|^0.2.0|^0.3.0", diff --git a/composer.lock b/composer.lock index 998584b4f..97b40f7c7 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": "ef45e2ecf9ff00aa6c51c0f49fd072e0", + "content-hash": "9c1a0833be38d1f058f216dcaa522077", "packages": [ { "name": "3sidedcube/laravel-redoc", @@ -2733,16 +2733,16 @@ }, { "name": "laravel/framework", - "version": "v11.35.0", + "version": "v11.38.2", "source": { "type": "git", "url": "https://github.com/laravel/framework.git", - "reference": "f1a7aaa3c1235b7a95ccaa58db90e0cd9d8c3fcc" + "reference": "9d290aa90fcad44048bedca5219d2b872e98772a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/framework/zipball/f1a7aaa3c1235b7a95ccaa58db90e0cd9d8c3fcc", - "reference": "f1a7aaa3c1235b7a95ccaa58db90e0cd9d8c3fcc", + "url": "https://api.github.com/repos/laravel/framework/zipball/9d290aa90fcad44048bedca5219d2b872e98772a", + "reference": "9d290aa90fcad44048bedca5219d2b872e98772a", "shasum": "" }, "require": { @@ -2763,7 +2763,7 @@ "guzzlehttp/uri-template": "^1.0", "laravel/prompts": "^0.1.18|^0.2.0|^0.3.0", "laravel/serializable-closure": "^1.3|^2.0", - "league/commonmark": "^2.2.1", + "league/commonmark": "^2.6", "league/flysystem": "^3.25.1", "league/flysystem-local": "^3.25.1", "league/uri": "^7.5.1", @@ -2778,7 +2778,7 @@ "symfony/console": "^7.0.3", "symfony/error-handler": "^7.0.3", "symfony/finder": "^7.0.3", - "symfony/http-foundation": "^7.0.3", + "symfony/http-foundation": "^7.2.0", "symfony/http-kernel": "^7.0.3", "symfony/mailer": "^7.0.3", "symfony/mime": "^7.0.3", @@ -2792,7 +2792,6 @@ "voku/portable-ascii": "^2.0.2" }, "conflict": { - "mockery/mockery": "1.6.8", "tightenco/collect": "<5.5.33" }, "provide": { @@ -2944,7 +2943,7 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2024-12-10T16:09:29+00:00" + "time": "2025-01-15T00:06:46+00:00" }, { "name": "laravel/horizon", diff --git a/database/seeders/ProductionSeeder.php b/database/seeders/ProductionSeeder.php index 3bcf7d193..268fd8291 100644 --- a/database/seeders/ProductionSeeder.php +++ b/database/seeders/ProductionSeeder.php @@ -63,13 +63,40 @@ class ProductionSeeder extends Seeder ]); } + if (! isCloud() && config('constants.coolify.is_windows_docker_desktop') == false) { + $coolify_key_name = '@host.docker.internal'; + $ssh_keys_directory = Storage::disk('ssh-keys')->files(); + $coolify_key = collect($ssh_keys_directory)->firstWhere(fn ($item) => str($item)->contains($coolify_key_name)); + + $private_key_found = PrivateKey::find(0); + if (! $private_key_found) { + if ($coolify_key) { + $user = str($coolify_key)->before('@')->after('id.'); + $coolify_key = Storage::disk('ssh-keys')->get($coolify_key); + PrivateKey::create([ + 'id' => 0, + 'team_id' => 0, + 'name' => 'localhost\'s key', + 'description' => 'The private key for the Coolify host machine (localhost).', + 'private_key' => $coolify_key, + ]); + echo "SSH key found for the Coolify host machine (localhost).\n"; + } else { + echo "No SSH key found for the Coolify host machine (localhost).\n"; + echo "Please read the following documentation (point 3) to fix it: https://coolify. + io/docs/knowledge-base/server/openssh/\n"; + echo "Your localhost connection won't work until then."; + } + } + } + if (! isCloud()) { if (Server::find(0) == null) { $server_details = [ 'id' => 0, 'name' => 'localhost', 'description' => "This is the server where Coolify is running on. Don't delete this!", - 'user' => 'root', + 'user' => $user, 'ip' => 'host.docker.internal', 'team_id' => 0, 'private_key_id' => 0, @@ -98,35 +125,7 @@ class ProductionSeeder extends Seeder ]); } } - if (! isCloud() && config('constants.coolify.is_windows_docker_desktop') == false) { - $coolify_key_name = '@host.docker.internal'; - $ssh_keys_directory = Storage::disk('ssh-keys')->files(); - $coolify_key = collect($ssh_keys_directory)->firstWhere(fn ($item) => str($item)->contains($coolify_key_name)); - $private_key_found = PrivateKey::find(0); - if (! $private_key_found) { - if ($coolify_key) { - $user = str($coolify_key)->before('@')->after('id.'); - $coolify_key = Storage::disk('ssh-keys')->get($coolify_key); - PrivateKey::create([ - 'id' => 0, - 'team_id' => 0, - 'name' => 'localhost\'s key', - 'description' => 'The private key for the Coolify host machine (localhost).', - 'private_key' => $coolify_key, - ]); - $server = Server::find(0); - $server->user = $user; - $server->save(); - echo "SSH key found for the Coolify host machine (localhost).\n"; - } else { - echo "No SSH key found for the Coolify host machine (localhost).\n"; - echo "Please read the following documentation (point 3) to fix it: https://coolify. - io/docs/knowledge-base/server/openssh/\n"; - echo "Your localhost connection won't work until then."; - } - } - } if (config('constants.coolify.is_windows_docker_desktop')) { PrivateKey::updateOrCreate( [ From ca2c66943c795f556ce57f26585d709861708775 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 17 Jan 2025 14:00:20 +0100 Subject: [PATCH 11/11] fix --- app/Console/Commands/Init.php | 10 ++-------- database/seeders/ProductionSeeder.php | 6 ++++++ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/Console/Commands/Init.php b/app/Console/Commands/Init.php index 1e4663073..a954b10fd 100644 --- a/app/Console/Commands/Init.php +++ b/app/Console/Commands/Init.php @@ -35,10 +35,7 @@ class Init extends Command } $this->servers = Server::all(); - if (isCloud()) { - echo "Running in cloud mode\n"; - } else { - echo "Running in self-hosted mode\n"; + if (! isCloud()) { $this->send_alive_signal(); get_public_ips(); } @@ -64,7 +61,7 @@ class Init extends Command try { $this->pullHelperImage(); } catch (\Throwable $e) { - echo "Error pulling helper image: {$e->getMessage()}\n"; + // } if (isCloud()) { @@ -125,7 +122,6 @@ class Init extends Command try { User::whereRaw('email ~ \'[A-Z]\'')->get()->each(function (User $user) { $user->update(['email' => strtolower($user->email)]); - $user->update(['email' => strtolower($user->email)]); }); } catch (\Throwable $e) { echo "Error in updating user emails: {$e->getMessage()}\n"; @@ -229,7 +225,6 @@ class Init extends Command private function send_alive_signal() { - echo "Sending alive signal...\n"; $id = config('app.id'); $version = config('constants.coolify.version'); $settings = instanceSettings(); @@ -255,7 +250,6 @@ class Init extends Command } $queued_inprogress_deployments = ApplicationDeploymentQueue::whereIn('status', [ApplicationDeploymentStatus::IN_PROGRESS->value, ApplicationDeploymentStatus::QUEUED->value])->get(); foreach ($queued_inprogress_deployments as $deployment) { - echo "Marking deployment {$deployment->id} as failed\n"; $deployment->status = ApplicationDeploymentStatus::FAILED->value; $deployment->save(); } diff --git a/database/seeders/ProductionSeeder.php b/database/seeders/ProductionSeeder.php index 268fd8291..bbb9fcb75 100644 --- a/database/seeders/ProductionSeeder.php +++ b/database/seeders/ProductionSeeder.php @@ -23,6 +23,12 @@ class ProductionSeeder extends Seeder { $user = 'root'; + if (isCloud()) { + echo " Running in cloud mode.\n"; + } else { + echo " Running in self-hosted mode.\n"; + } + if (User::find(0) !== null && Team::find(0) !== null) { if (DB::table('team_user')->where('user_id', 0)->first() === null) { DB::table('team_user')->insert([