| @@ -4,12 +4,14 @@ namespace App\Actions\Service; | |||||||
| 
 | 
 | ||||||
| use Lorisleiva\Actions\Concerns\AsAction; | use Lorisleiva\Actions\Concerns\AsAction; | ||||||
| use App\Models\Service; | use App\Models\Service; | ||||||
|  | use Symfony\Component\Yaml\Yaml; | ||||||
| 
 | 
 | ||||||
| class StartService | class StartService | ||||||
| { | { | ||||||
|     use AsAction; |     use AsAction; | ||||||
|     public function handle(Service $service) |     public function handle(Service $service) | ||||||
|     { |     { | ||||||
|  |         $network = $service->destination->network; | ||||||
|         $service->saveComposeConfigs(); |         $service->saveComposeConfigs(); | ||||||
|         $commands[] = "cd " . $service->workdir(); |         $commands[] = "cd " . $service->workdir(); | ||||||
|         $commands[] = "echo '####### Saved configuration files to {$service->workdir()}.'"; |         $commands[] = "echo '####### Saved configuration files to {$service->workdir()}.'"; | ||||||
| @@ -21,6 +23,11 @@ class StartService | |||||||
|         $commands[] = "echo '####### Starting containers.'"; |         $commands[] = "echo '####### Starting containers.'"; | ||||||
|         $commands[] = "docker compose up -d --remove-orphans --force-recreate"; |         $commands[] = "docker compose up -d --remove-orphans --force-recreate"; | ||||||
|         $commands[] = "docker network connect $service->uuid coolify-proxy 2>/dev/null || true"; |         $commands[] = "docker network connect $service->uuid coolify-proxy 2>/dev/null || true"; | ||||||
|  |         $compose = data_get($service,'docker_compose',[]); | ||||||
|  |         $serviceNames = data_get(Yaml::parse($compose),'services',[]); | ||||||
|  |         foreach($serviceNames as $serviceName => $serviceConfig){ | ||||||
|  |             $commands[] = "docker network connect --alias {$serviceName}-{$service->uuid}  $network {$serviceName}-{$service->uuid} 2>/dev/null || true"; | ||||||
|  |         } | ||||||
|         $activity = remote_process($commands, $service->server); |         $activity = remote_process($commands, $service->server); | ||||||
|         return $activity; |         return $activity; | ||||||
|     } |     } | ||||||
|   | |||||||
							
								
								
									
										49
									
								
								app/Console/Commands/ResetRootPassword.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										49
									
								
								app/Console/Commands/ResetRootPassword.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,49 @@ | |||||||
|  | <?php | ||||||
|  | 
 | ||||||
|  | namespace App\Console\Commands; | ||||||
|  | 
 | ||||||
|  | use App\Models\User; | ||||||
|  | use Illuminate\Console\Command; | ||||||
|  | use Illuminate\Support\Facades\Hash; | ||||||
|  | 
 | ||||||
|  | use function Laravel\Prompts\password; | ||||||
|  | 
 | ||||||
|  | class ResetRootPassword extends Command | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * The name and signature of the console command. | ||||||
|  |      * | ||||||
|  |      * @var string | ||||||
|  |      */ | ||||||
|  |     protected $signature = 'app:reset-root-password'; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * The console command description. | ||||||
|  |      * | ||||||
|  |      * @var string | ||||||
|  |      */ | ||||||
|  |     protected $description = 'Reset Root Password'; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Execute the console command. | ||||||
|  |      */ | ||||||
|  |     public function handle() | ||||||
|  |     { | ||||||
|  |         //
 | ||||||
|  |         $this->info('You are about to reset the root password.'); | ||||||
|  |         $password = password('Give me a new password for root user: '); | ||||||
|  |         $passwordAgain = password('Again'); | ||||||
|  |         if ($password != $passwordAgain) { | ||||||
|  |             $this->error('Passwords do not match.'); | ||||||
|  |             return; | ||||||
|  |         } | ||||||
|  |         $this->info('Updating root password...'); | ||||||
|  |         try { | ||||||
|  |             User::find(0)->update(['password' => Hash::make($password)]); | ||||||
|  |             $this->info('Root password updated successfully.'); | ||||||
|  |         } catch (\Exception $e) { | ||||||
|  |             $this->error('Failed to update root password.'); | ||||||
|  |             return; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
| @@ -6,7 +6,7 @@ use App\Models\EnvironmentVariable; | |||||||
| use App\Models\Project; | use App\Models\Project; | ||||||
| use App\Models\Server; | use App\Models\Server; | ||||||
| use App\Models\Service; | use App\Models\Service; | ||||||
| use Illuminate\Support\Facades\Cache; | use App\Models\StandaloneDocker; | ||||||
| use Illuminate\Support\Str; | use Illuminate\Support\Str; | ||||||
| 
 | 
 | ||||||
| class ProjectController extends Controller | class ProjectController extends Controller | ||||||
| @@ -75,11 +75,14 @@ class ProjectController extends Controller | |||||||
|                 $oneClickDotEnvs = Str::of(base64_decode($oneClickDotEnvs))->split('/\r\n|\r|\n/'); |                 $oneClickDotEnvs = Str::of(base64_decode($oneClickDotEnvs))->split('/\r\n|\r|\n/'); | ||||||
|             } |             } | ||||||
|             if ($oneClickService) { |             if ($oneClickService) { | ||||||
|  |                 $destination = StandaloneDocker::whereUuid($destination_uuid)->first(); | ||||||
|                 $service = Service::create([ |                 $service = Service::create([ | ||||||
|                     'name' => "$oneClickServiceName-" . Str::random(10), |                     'name' => "$oneClickServiceName-" . Str::random(10), | ||||||
|                     'docker_compose_raw' => base64_decode($oneClickService), |                     'docker_compose_raw' => base64_decode($oneClickService), | ||||||
|                     'environment_id' => $environment->id, |                     'environment_id' => $environment->id, | ||||||
|                     'server_id' => (int) $server_id, |                     'server_id' => (int) $server_id, | ||||||
|  |                     'destination_id' => $destination->id, | ||||||
|  |                     'destination_type' => $destination->getMorphClass(), | ||||||
|                 ]); |                 ]); | ||||||
|                 $service->name = "$oneClickServiceName-" . $service->uuid; |                 $service->name = "$oneClickServiceName-" . $service->uuid; | ||||||
|                 $service->save(); |                 $service->save(); | ||||||
|   | |||||||
| @@ -32,8 +32,6 @@ class DockerCompose extends Component | |||||||
|                 - type: volume |                 - type: volume | ||||||
|                   source: mydata |                   source: mydata | ||||||
|                   target: /data |                   target: /data | ||||||
|                   volume: |  | ||||||
|                     nocopy: true |  | ||||||
|                 - type: bind |                 - type: bind | ||||||
|                   source: ./var/lib/ghost/data |                   source: ./var/lib/ghost/data | ||||||
|                   target: /data |                   target: /data | ||||||
|   | |||||||
| @@ -23,6 +23,9 @@ class Index extends Component | |||||||
|     } |     } | ||||||
|     public function mount() |     public function mount() | ||||||
|     { |     { | ||||||
|  |         if (config('coolify.waitlist') == false) { | ||||||
|  |             return redirect()->route('register'); | ||||||
|  |         } | ||||||
|         $this->waitingInLine = Waitlist::whereVerified(true)->count(); |         $this->waitingInLine = Waitlist::whereVerified(true)->count(); | ||||||
|         $this->users = User::count(); |         $this->users = User::count(); | ||||||
|         if (isDev()) { |         if (isDev()) { | ||||||
|   | |||||||
| @@ -63,6 +63,10 @@ class Service extends BaseModel | |||||||
|     { |     { | ||||||
|         return $this->hasMany(ServiceDatabase::class); |         return $this->hasMany(ServiceDatabase::class); | ||||||
|     } |     } | ||||||
|  |     public function destination() | ||||||
|  |     { | ||||||
|  |         return $this->morphTo(); | ||||||
|  |     } | ||||||
|     public function environment() |     public function environment() | ||||||
|     { |     { | ||||||
|         return $this->belongsTo(Environment::class); |         return $this->belongsTo(Environment::class); | ||||||
| @@ -124,9 +128,16 @@ class Service extends BaseModel | |||||||
|             $topLevelNetworks = collect(data_get($yaml, 'networks', [])); |             $topLevelNetworks = collect(data_get($yaml, 'networks', [])); | ||||||
|             $dockerComposeVersion = data_get($yaml, 'version') ?? '3.8'; |             $dockerComposeVersion = data_get($yaml, 'version') ?? '3.8'; | ||||||
|             $services = data_get($yaml, 'services'); |             $services = data_get($yaml, 'services'); | ||||||
|             $definedNetwork = $this->uuid; |  | ||||||
| 
 | 
 | ||||||
|             $generatedServiceFQDNS = collect([]); |             $generatedServiceFQDNS = collect([]); | ||||||
|  |             if (is_null($this->destination)) { | ||||||
|  |                 $destination = $this->server->destinations()->first(); | ||||||
|  |                 if ($destination) { | ||||||
|  |                     $this->destination()->associate($destination); | ||||||
|  |                     $this->save(); | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             $definedNetwork = collect([$this->uuid]); | ||||||
| 
 | 
 | ||||||
|             $services = collect($services)->map(function ($service, $serviceName) use ($topLevelVolumes, $topLevelNetworks, $definedNetwork, $isNew, $generatedServiceFQDNS) { |             $services = collect($services)->map(function ($service, $serviceName) use ($topLevelVolumes, $topLevelNetworks, $definedNetwork, $isNew, $generatedServiceFQDNS) { | ||||||
|                 $serviceVolumes = collect(data_get($service, 'volumes', [])); |                 $serviceVolumes = collect(data_get($service, 'volumes', [])); | ||||||
| @@ -237,13 +248,19 @@ class Service extends BaseModel | |||||||
|                     return $value == $definedNetwork; |                     return $value == $definedNetwork; | ||||||
|                 }); |                 }); | ||||||
|                 if (!$definedNetworkExists) { |                 if (!$definedNetworkExists) { | ||||||
|                     $topLevelNetworks->put($definedNetwork, [ |                     foreach ($definedNetwork as $network) { | ||||||
|                         'name' => $definedNetwork, |                         $topLevelNetworks->put($network,  [ | ||||||
|  |                             'name' => $network, | ||||||
|                             'external' => true |                             'external' => true | ||||||
|                         ]); |                         ]); | ||||||
|                     } |                     } | ||||||
|  |                 } | ||||||
|                 $networks = $serviceNetworks->toArray(); |                 $networks = $serviceNetworks->toArray(); | ||||||
|                 $networks = array_merge($networks, [$definedNetwork]); |                 foreach ($definedNetwork as $key => $network) { | ||||||
|  |                     $networks = array_merge($networks, [ | ||||||
|  |                         $network | ||||||
|  |                     ]); | ||||||
|  |                 } | ||||||
|                 data_set($service, 'networks', $networks); |                 data_set($service, 'networks', $networks); | ||||||
| 
 | 
 | ||||||
|                 // Collect/create/update volumes
 |                 // Collect/create/update volumes
 | ||||||
| @@ -308,7 +325,7 @@ class Service extends BaseModel | |||||||
|                                 $target = Str::of($volume)->after(':')->beforeLast(':'); |                                 $target = Str::of($volume)->after(':')->beforeLast(':'); | ||||||
|                                 $source = $name; |                                 $source = $name; | ||||||
|                                 $volume = "$source:$target"; |                                 $volume = "$source:$target"; | ||||||
|                             } else if(is_array($volume)) { |                             } else if (is_array($volume)) { | ||||||
|                                 data_set($volume, 'source', $name); |                                 data_set($volume, 'source', $name); | ||||||
|                             } |                             } | ||||||
|                             $topLevelVolumes->put($name, null); |                             $topLevelVolumes->put($name, null); | ||||||
|   | |||||||
| @@ -7,7 +7,7 @@ return [ | |||||||
| 
 | 
 | ||||||
|     // The release version of your application
 |     // The release version of your application
 | ||||||
|     // Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD'))
 |     // Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD'))
 | ||||||
|     'release' => '4.0.0-beta.57', |     'release' => '4.0.0-beta.58', | ||||||
|     // When left empty or `null` the Laravel environment will be used
 |     // When left empty or `null` the Laravel environment will be used
 | ||||||
|     'environment' => config('app.env'), |     'environment' => config('app.env'), | ||||||
| 
 | 
 | ||||||
|   | |||||||
| @@ -1,3 +1,3 @@ | |||||||
| <?php | <?php | ||||||
| 
 | 
 | ||||||
| return '4.0.0-beta.57'; | return '4.0.0-beta.58'; | ||||||
|   | |||||||
| @@ -0,0 +1,28 @@ | |||||||
|  | <?php | ||||||
|  | 
 | ||||||
|  | use Illuminate\Database\Migrations\Migration; | ||||||
|  | use Illuminate\Database\Schema\Blueprint; | ||||||
|  | use Illuminate\Support\Facades\Schema; | ||||||
|  | 
 | ||||||
|  | return new class extends Migration | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Run the migrations. | ||||||
|  |      */ | ||||||
|  |     public function up(): void | ||||||
|  |     { | ||||||
|  |         Schema::table('services', function (Blueprint $table) { | ||||||
|  |             $table->nullableMorphs('destination'); | ||||||
|  |         }); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Reverse the migrations. | ||||||
|  |      */ | ||||||
|  |     public function down(): void | ||||||
|  |     { | ||||||
|  |         Schema::table('services', function (Blueprint $table) { | ||||||
|  |             $table->dropMorphs('destination'); | ||||||
|  |         }); | ||||||
|  |     } | ||||||
|  | }; | ||||||
| @@ -7,7 +7,7 @@ | |||||||
|     "uptime-kuma": { |     "uptime-kuma": { | ||||||
|         "documentation": "https://github.com/louislam/uptime-kuma", |         "documentation": "https://github.com/louislam/uptime-kuma", | ||||||
|         "slogan": "A free and fancy self-hosted monitoring tool.", |         "slogan": "A free and fancy self-hosted monitoring tool.", | ||||||
|         "compose": "c2VydmljZXM6CiAgdXB0aW1lLWt1bWE6CiAgICBpbWFnZTogbG91aXNsYW0vdXB0aW1lLWt1bWE6MQogICAgZW52aXJvbm1lbnQ6CiAgICAgIC0gU0VSVklDRV9GUUROCiAgICB2b2x1bWVzOgogICAgICAtIHVwdGltZS1rdW1hOi9hcHAvZGF0YQ==" |         "compose": "c2VydmljZXM6CiAgdXB0aW1lLWt1bWE6CiAgICBpbWFnZTogbG91aXNsYW0vdXB0aW1lLWt1bWE6MQogICAgZW52aXJvbm1lbnQ6CiAgICAgIC0gU0VSVklDRV9GUUROCiAgICB2b2x1bWVzOgogICAgICAtIHVwdGltZS1rdW1hOi9hcHAvZGF0YQogICAgaGVhbHRoY2hlY2s6CiAgICAgIHRlc3Q6IFsiQ01ELVNIRUxMIiwgImV4dHJhL2hlYWx0aGNoZWNrIl0KICAgICAgaW50ZXJ2YWw6IDJzCiAgICAgIHRpbWVvdXQ6IDEwcwogICAgICByZXRyaWVzOiAxNQ==" | ||||||
|     }, |     }, | ||||||
|     "appsmith": { |     "appsmith": { | ||||||
|         "documentation": "https://docs.appsmith.com/", |         "documentation": "https://docs.appsmith.com/", | ||||||
|   | |||||||
| @@ -4,7 +4,7 @@ | |||||||
|             "version": "3.12.36" |             "version": "3.12.36" | ||||||
|         }, |         }, | ||||||
|         "v4": { |         "v4": { | ||||||
|             "version": "4.0.0-beta.57" |             "version": "4.0.0-beta.58" | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Andras Bacsai
					Andras Bacsai