diff --git a/.env.production b/.env.production index 7ea84bd0e..05e553f39 100644 --- a/.env.production +++ b/.env.production @@ -1,3 +1,6 @@ +COOLIFY_DEFAULT_PROXY=traefik +COOLIFY_DEFAULT_NETWORK=coolify + APP_NAME=Coolify APP_SERVICE=php APP_ENV=local diff --git a/app/Actions/Proxy/InstallProxy.php b/app/Actions/Proxy/InstallProxy.php index 5b61118cd..42492ba41 100644 --- a/app/Actions/Proxy/InstallProxy.php +++ b/app/Actions/Proxy/InstallProxy.php @@ -11,7 +11,6 @@ class InstallProxy { - public function __invoke(Server $server): Activity { $proxy_path = config('coolify.proxy_config_path'); diff --git a/app/Http/Livewire/Project/Application/Danger.php b/app/Http/Livewire/Project/Application/Danger.php index 0a2f59d34..55eb7e084 100644 --- a/app/Http/Livewire/Project/Application/Danger.php +++ b/app/Http/Livewire/Project/Application/Danger.php @@ -2,8 +2,27 @@ namespace App\Http\Livewire\Project\Application; +use App\Models\Application; use Livewire\Component; class Danger extends Component { + public Application $application; + public array $parameters; + + public function mount() + { + $this->parameters = getParameters(); + } + public function delete() + { + $destination = $this->application->destination->getMorphClass()::where('id', $this->application->destination->id)->first(); + + instantRemoteProcess(["docker rm -f {$this->application->uuid}"], $destination->server); + $this->application->delete(); + return redirect()->route('project.resources', [ + 'project_uuid' => $this->parameters['project_uuid'], + 'environment_name' => $this->parameters['environment_name'] + ]); + } } diff --git a/app/Http/Livewire/Project/Application/Deploy.php b/app/Http/Livewire/Project/Application/Deploy.php index 39181ce90..2a655473e 100644 --- a/app/Http/Livewire/Project/Application/Deploy.php +++ b/app/Http/Livewire/Project/Application/Deploy.php @@ -64,15 +64,6 @@ public function forceRebuild() return $this->redirectToDeployment(); } - public function delete() - { - $this->stop(); - Application::find($this->applicationId)->delete(); - return redirect()->route('project.resources', [ - 'project_uuid' => $this->parameters['project_uuid'], - 'environment_name' => $this->parameters['environment_name'] - ]); - } public function stop() { instantRemoteProcess(["docker rm -f {$this->application->uuid}"], $this->destination->server); diff --git a/app/Jobs/AutoUpdateJob.php b/app/Jobs/AutoUpdateJob.php index 1da36f365..dc1927efd 100644 --- a/app/Jobs/AutoUpdateJob.php +++ b/app/Jobs/AutoUpdateJob.php @@ -6,7 +6,6 @@ use App\Models\InstanceSettings; use App\Models\Server; use Illuminate\Bus\Queueable; -use Illuminate\Contracts\Queue\ShouldBeUnique; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Queue\InteractsWithQueue; @@ -15,7 +14,7 @@ class AutoUpdateJob implements ShouldQueue { - use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, ShouldBeUnique; + use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; /** * Create a new job instance. @@ -24,8 +23,6 @@ public function __construct() { $instance_settings = InstanceSettings::get(); if (!$instance_settings->is_auto_update_enabled) { - Log::info('Auto update is disabled'); - dd('Auto update is disabled'); $this->delete(); } } @@ -39,11 +36,9 @@ public function handle(): void $latest_version = getLatestVersionOfCoolify(); $current_version = config('version'); if ($latest_version === $current_version) { - dd('no update, versions match', $latest_version, $current_version); return; } if (version_compare($latest_version, $current_version, '<')) { - dd('no update, latest version is lower than current version'); return; } @@ -57,7 +52,6 @@ public function handle(): void remoteProcess([ "sleep 10" ], $server, ActivityTypes::INLINE->value); - dd('update done'); } else { $latest_version = getLatestVersionOfCoolify(); $current_version = config('version'); diff --git a/database/seeders/ProductionSeeder.php b/database/seeders/ProductionSeeder.php index 68d536216..d6e5074b7 100644 --- a/database/seeders/ProductionSeeder.php +++ b/database/seeders/ProductionSeeder.php @@ -2,11 +2,13 @@ namespace Database\Seeders; +use App\Data\ServerMetadata; +use App\Enums\ProxyStatus; +use App\Enums\ProxyTypes; use App\Models\GithubApp; use App\Models\GitlabApp; use App\Models\InstanceSettings; use App\Models\PrivateKey; -use App\Models\Project; use App\Models\Server; use App\Models\Team; use Illuminate\Database\Seeder; @@ -73,20 +75,26 @@ public function run(): void // TODO: Add a command to generate a new SSH key for the Coolify host machine (localhost). echo "No SSH key found for the Coolify host machine (localhost).\n"; echo "Please generate one and save it in storage/app/ssh-keys/{$coolify_key_name}\n"; - exit(1); } // Add Coolify host (localhost) as Server if it doesn't exist if (Server::find(0) == null) { - $server = Server::create([ + $server_details = [ 'id' => 0, 'name' => "localhost", - 'description' => "This is the local machine", + 'description' => "This is the server where Coolify is running on. Don't delete this!", 'user' => 'root', 'ip' => "host.docker.internal", 'team_id' => 0, - 'private_key_id' => 0, - ]); + 'private_key_id' => 0 + ]; + if (env('COOLIFY_DEFAULT_PROXY') == 'traefik') { + $server_details['extra_attributes'] = ServerMetadata::from([ + 'proxy_type' => ProxyTypes::TRAEFIK_V2->value, + 'proxy_status' => ProxyStatus::EXITED->value + ]); + } + $server = Server::create($server_details); $server->settings->is_validated = true; $server->settings->save(); } diff --git a/resources/views/livewire/server/form.blade.php b/resources/views/livewire/server/form.blade.php index 8e9a5bdcb..ef70c569b 100644 --- a/resources/views/livewire/server/form.blade.php +++ b/resources/views/livewire/server/form.blade.php @@ -4,9 +4,11 @@