@@ -21,6 +21,8 @@ class ProductionSeeder extends Seeder
21
21
{
22
22
public function run (): void
23
23
{
24
+
25
+ $ user = 'root ' ;
24
26
echo "Starting ProductionSeeder... \n" ;
25
27
26
28
if (isCloud ()) {
@@ -79,6 +81,36 @@ public function run(): void
79
81
]);
80
82
}
81
83
84
+ if (! isCloud () && config ('constants.coolify.is_windows_docker_desktop ' ) == false ) {
85
+ echo "Setting up SSH keys for non-Windows environment... \n" ;
86
+ $ coolify_key_name = '@host.docker.internal ' ;
87
+ $ ssh_keys_directory = Storage::disk ('ssh-keys ' )->files ();
88
+ echo ' Found ' .count ($ ssh_keys_directory )." SSH keys \n" ;
89
+ $ coolify_key = collect ($ ssh_keys_directory )->firstWhere (fn ($ item ) => str ($ item )->contains ($ coolify_key_name ));
90
+
91
+ $ server = Server::find (0 );
92
+ $ found = $ server ->privateKey ;
93
+ if (! $ found ) {
94
+ if ($ coolify_key ) {
95
+ echo " Found Coolify SSH key \n" ;
96
+ $ user = str ($ coolify_key )->before ('@ ' )->after ('id. ' );
97
+ $ coolify_key = Storage::disk ('ssh-keys ' )->get ($ coolify_key );
98
+ PrivateKey::create ([
99
+ 'id ' => 0 ,
100
+ 'team_id ' => 0 ,
101
+ 'name ' => 'localhost \'s key ' ,
102
+ 'description ' => 'The private key for the Coolify host machine (localhost). ' ,
103
+ 'private_key ' => $ coolify_key ,
104
+ ]);
105
+ echo "SSH key found for the Coolify host machine (localhost). \n" ;
106
+ } else {
107
+ echo "No SSH key found for the Coolify host machine (localhost). \n" ;
108
+ echo "Please read the following documentation (point 3) to fix it: https://coolify.io/docs/knowledge-base/server/openssh/ \n" ;
109
+ echo "Your localhost connection won't work until then. " ;
110
+ }
111
+ }
112
+ }
113
+
82
114
// Add Coolify host (localhost) as Server if it doesn't exist
83
115
if (! isCloud ()) {
84
116
echo "Setting up localhost server... \n" ;
@@ -88,7 +120,7 @@ public function run(): void
88
120
'id ' => 0 ,
89
121
'name ' => 'localhost ' ,
90
122
'description ' => "This is the server where Coolify is running on. Don't delete this! " ,
91
- 'user ' => ' root ' ,
123
+ 'user ' => $ user ,
92
124
'ip ' => 'host.docker.internal ' ,
93
125
'team_id ' => 0 ,
94
126
'private_key_id ' => 0 ,
@@ -121,37 +153,6 @@ public function run(): void
121
153
}
122
154
}
123
155
124
- if (! isCloud () && config ('constants.coolify.is_windows_docker_desktop ' ) == false ) {
125
- echo "Setting up SSH keys for non-Windows environment... \n" ;
126
- $ coolify_key_name = '@host.docker.internal ' ;
127
- $ ssh_keys_directory = Storage::disk ('ssh-keys ' )->files ();
128
- echo ' Found ' .count ($ ssh_keys_directory )." SSH keys \n" ;
129
- $ coolify_key = collect ($ ssh_keys_directory )->firstWhere (fn ($ item ) => str ($ item )->contains ($ coolify_key_name ));
130
-
131
- $ server = Server::find (0 );
132
- $ found = $ server ->privateKey ;
133
- if (! $ found ) {
134
- if ($ coolify_key ) {
135
- echo " Found Coolify SSH key \n" ;
136
- $ user = str ($ coolify_key )->before ('@ ' )->after ('id. ' );
137
- $ coolify_key = Storage::disk ('ssh-keys ' )->get ($ coolify_key );
138
- PrivateKey::create ([
139
- 'id ' => 0 ,
140
- 'team_id ' => 0 ,
141
- 'name ' => 'localhost \'s key ' ,
142
- 'description ' => 'The private key for the Coolify host machine (localhost). ' ,
143
- 'private_key ' => $ coolify_key ,
144
- ]);
145
- $ server ->update (['user ' => $ user ]);
146
- echo "SSH key found for the Coolify host machine (localhost). \n" ;
147
- } else {
148
- echo "No SSH key found for the Coolify host machine (localhost). \n" ;
149
- echo "Please read the following documentation (point 3) to fix it: https://coolify.io/docs/knowledge-base/server/openssh/ \n" ;
150
- echo "Your localhost connection won't work until then. " ;
151
- }
152
- }
153
- }
154
-
155
156
if (config ('constants.coolify.is_windows_docker_desktop ' )) {
156
157
echo "Setting up Windows Docker Desktop environment... \n" ;
157
158
echo " Creating/updating private key \n" ;
0 commit comments