Skip to content

Commit d043fbf

Browse files
committed
refactor: streamline ProductionSeeder by removing debug logs and unnecessary checks, while ensuring essential seeding operations remain intact
1 parent 10b3c6b commit d043fbf

File tree

1 file changed

+2
-42
lines changed

1 file changed

+2
-42
lines changed

database/seeders/ProductionSeeder.php

+2-42
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,10 @@ class ProductionSeeder extends Seeder
2121
{
2222
public function run(): void
2323
{
24-
2524
$user = 'root';
26-
echo "Starting ProductionSeeder...\n";
27-
28-
if (isCloud()) {
29-
echo " Running in cloud mode.\n";
30-
} else {
31-
echo " Running in self-hosted mode.\n";
32-
}
3325

34-
// Fix for 4.0.0-beta.37
35-
echo "Checking for beta.37 fix...\n";
3626
if (User::find(0) !== null && Team::find(0) !== null) {
37-
echo " Found User 0 and Team 0\n";
3827
if (DB::table('team_user')->where('user_id', 0)->first() === null) {
39-
echo " Creating team_user relationship\n";
4028
DB::table('team_user')->insert([
4129
'user_id' => 0,
4230
'team_id' => 0,
@@ -47,17 +35,13 @@ public function run(): void
4735
}
4836
}
4937

50-
echo "Checking InstanceSettings...\n";
5138
if (InstanceSettings::find(0) == null) {
52-
echo " Creating InstanceSettings\n";
5339
InstanceSettings::create([
5440
'id' => 0,
5541
]);
5642
}
5743

58-
echo "Checking GithubApp...\n";
5944
if (GithubApp::find(0) == null) {
60-
echo " Creating GithubApp\n";
6145
GithubApp::create([
6246
'id' => 0,
6347
'name' => 'Public GitHub',
@@ -68,9 +52,7 @@ public function run(): void
6852
]);
6953
}
7054

71-
echo "Checking GitlabApp...\n";
7255
if (GitlabApp::find(0) == null) {
73-
echo " Creating GitlabApp\n";
7456
GitlabApp::create([
7557
'id' => 0,
7658
'name' => 'Public GitLab',
@@ -82,16 +64,13 @@ public function run(): void
8264
}
8365

8466
if (! isCloud() && config('constants.coolify.is_windows_docker_desktop') == false) {
85-
echo "Setting up SSH keys for non-Windows environment...\n";
8667
$coolify_key_name = '@host.docker.internal';
8768
$ssh_keys_directory = Storage::disk('ssh-keys')->files();
88-
echo ' Found '.count($ssh_keys_directory)." SSH keys\n";
8969
$coolify_key = collect($ssh_keys_directory)->firstWhere(fn ($item) => str($item)->contains($coolify_key_name));
9070

9171
$private_key_found = PrivateKey::find(0);
9272
if (! $private_key_found) {
9373
if ($coolify_key) {
94-
echo " Found Coolify SSH key\n";
9574
$user = str($coolify_key)->before('@')->after('id.');
9675
$coolify_key = Storage::disk('ssh-keys')->get($coolify_key);
9776
PrivateKey::create([
@@ -104,17 +83,15 @@ public function run(): void
10483
echo "SSH key found for the Coolify host machine (localhost).\n";
10584
} else {
10685
echo "No SSH key found for the Coolify host machine (localhost).\n";
107-
echo "Please read the following documentation (point 3) to fix it: https://coolify.io/docs/knowledge-base/server/openssh/\n";
86+
echo "Please read the following documentation (point 3) to fix it: https://coolify.
87+
io/docs/knowledge-base/server/openssh/\n";
10888
echo "Your localhost connection won't work until then.";
10989
}
11090
}
11191
}
11292

113-
// Add Coolify host (localhost) as Server if it doesn't exist
11493
if (! isCloud()) {
115-
echo "Setting up localhost server...\n";
11694
if (Server::find(0) == null) {
117-
echo " Creating localhost server\n";
11895
$server_details = [
11996
'id' => 0,
12097
'name' => 'localhost',
@@ -133,16 +110,13 @@ public function run(): void
133110
$server->settings->is_usable = true;
134111
$server->settings->save();
135112
} else {
136-
echo " Updating existing localhost server\n";
137113
$server = Server::find(0);
138114
$server->settings->is_reachable = true;
139115
$server->settings->is_usable = true;
140116
$server->settings->save();
141117
}
142118

143-
echo "Checking StandaloneDocker...\n";
144119
if (StandaloneDocker::find(0) == null) {
145-
echo " Creating StandaloneDocker\n";
146120
StandaloneDocker::create([
147121
'id' => 0,
148122
'name' => 'localhost-coolify',
@@ -153,8 +127,6 @@ public function run(): void
153127
}
154128

155129
if (config('constants.coolify.is_windows_docker_desktop')) {
156-
echo "Setting up Windows Docker Desktop environment...\n";
157-
echo " Creating/updating private key\n";
158130
PrivateKey::updateOrCreate(
159131
[
160132
'id' => 0,
@@ -174,7 +146,6 @@ public function run(): void
174146
]
175147
);
176148
if (Server::find(0) == null) {
177-
echo " Creating Windows localhost server\n";
178149
$server_details = [
179150
'id' => 0,
180151
'uuid' => 'coolify-testing-host',
@@ -194,16 +165,13 @@ public function run(): void
194165
$server->settings->is_usable = true;
195166
$server->settings->save();
196167
} else {
197-
echo " Updating Windows localhost server\n";
198168
$server = Server::find(0);
199169
$server->settings->is_reachable = true;
200170
$server->settings->is_usable = true;
201171
$server->settings->save();
202172
}
203173

204-
echo "Checking Windows StandaloneDocker...\n";
205174
if (StandaloneDocker::find(0) == null) {
206-
echo " Creating Windows StandaloneDocker\n";
207175
StandaloneDocker::create([
208176
'id' => 0,
209177
'name' => 'localhost-coolify',
@@ -213,19 +181,11 @@ public function run(): void
213181
}
214182
}
215183

216-
echo "Getting public IPs...\n";
217184
get_public_ips();
218185

219-
echo "Running additional seeders...\n";
220-
echo " Running OauthSettingSeeder\n";
221186
$this->call(OauthSettingSeeder::class);
222-
echo " Running PopulateSshKeysDirectorySeeder\n";
223187
$this->call(PopulateSshKeysDirectorySeeder::class);
224-
echo " Running SentinelSeeder\n";
225188
$this->call(SentinelSeeder::class);
226-
echo " Running RootUserSeeder\n";
227189
$this->call(RootUserSeeder::class);
228-
229-
echo "ProductionSeeder complete!\n";
230190
}
231191
}

0 commit comments

Comments
 (0)