update proxy things

This commit is contained in:
Andras Bacsai 2023-05-22 12:47:15 +02:00
parent f5bf07a7c3
commit c1bafccac1
7 changed files with 42 additions and 26 deletions

View File

@ -1,3 +1,6 @@
COOLIFY_DEFAULT_PROXY=traefik
COOLIFY_DEFAULT_NETWORK=coolify
APP_NAME=Coolify APP_NAME=Coolify
APP_SERVICE=php APP_SERVICE=php
APP_ENV=local APP_ENV=local

View File

@ -11,7 +11,6 @@ use Spatie\Url\Url;
class InstallProxy class InstallProxy
{ {
public function __invoke(Server $server): Activity public function __invoke(Server $server): Activity
{ {
$proxy_path = config('coolify.proxy_config_path'); $proxy_path = config('coolify.proxy_config_path');

View File

@ -2,8 +2,27 @@
namespace App\Http\Livewire\Project\Application; namespace App\Http\Livewire\Project\Application;
use App\Models\Application;
use Livewire\Component; use Livewire\Component;
class Danger extends 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']
]);
}
} }

View File

@ -64,15 +64,6 @@ class Deploy extends Component
return $this->redirectToDeployment(); 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() public function stop()
{ {
instantRemoteProcess(["docker rm -f {$this->application->uuid}"], $this->destination->server); instantRemoteProcess(["docker rm -f {$this->application->uuid}"], $this->destination->server);

View File

@ -6,7 +6,6 @@ use App\Enums\ActivityTypes;
use App\Models\InstanceSettings; use App\Models\InstanceSettings;
use App\Models\Server; use App\Models\Server;
use Illuminate\Bus\Queueable; use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\InteractsWithQueue;
@ -15,7 +14,7 @@ use Illuminate\Support\Facades\Log;
class AutoUpdateJob implements ShouldQueue class AutoUpdateJob implements ShouldQueue
{ {
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, ShouldBeUnique; use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
/** /**
* Create a new job instance. * Create a new job instance.
@ -24,8 +23,6 @@ class AutoUpdateJob implements ShouldQueue
{ {
$instance_settings = InstanceSettings::get(); $instance_settings = InstanceSettings::get();
if (!$instance_settings->is_auto_update_enabled) { if (!$instance_settings->is_auto_update_enabled) {
Log::info('Auto update is disabled');
dd('Auto update is disabled');
$this->delete(); $this->delete();
} }
} }
@ -39,11 +36,9 @@ class AutoUpdateJob implements ShouldQueue
$latest_version = getLatestVersionOfCoolify(); $latest_version = getLatestVersionOfCoolify();
$current_version = config('version'); $current_version = config('version');
if ($latest_version === $current_version) { if ($latest_version === $current_version) {
dd('no update, versions match', $latest_version, $current_version);
return; return;
} }
if (version_compare($latest_version, $current_version, '<')) { if (version_compare($latest_version, $current_version, '<')) {
dd('no update, latest version is lower than current version');
return; return;
} }
@ -57,7 +52,6 @@ class AutoUpdateJob implements ShouldQueue
remoteProcess([ remoteProcess([
"sleep 10" "sleep 10"
], $server, ActivityTypes::INLINE->value); ], $server, ActivityTypes::INLINE->value);
dd('update done');
} else { } else {
$latest_version = getLatestVersionOfCoolify(); $latest_version = getLatestVersionOfCoolify();
$current_version = config('version'); $current_version = config('version');

View File

@ -2,11 +2,13 @@
namespace Database\Seeders; namespace Database\Seeders;
use App\Data\ServerMetadata;
use App\Enums\ProxyStatus;
use App\Enums\ProxyTypes;
use App\Models\GithubApp; use App\Models\GithubApp;
use App\Models\GitlabApp; use App\Models\GitlabApp;
use App\Models\InstanceSettings; use App\Models\InstanceSettings;
use App\Models\PrivateKey; use App\Models\PrivateKey;
use App\Models\Project;
use App\Models\Server; use App\Models\Server;
use App\Models\Team; use App\Models\Team;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
@ -73,20 +75,26 @@ class ProductionSeeder extends Seeder
// TODO: Add a command to generate a new SSH key for the Coolify host machine (localhost). // 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 "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"; 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 // Add Coolify host (localhost) as Server if it doesn't exist
if (Server::find(0) == null) { if (Server::find(0) == null) {
$server = Server::create([ $server_details = [
'id' => 0, 'id' => 0,
'name' => "localhost", 'name' => "localhost",
'description' => "This is the local machine", 'description' => "This is the server where Coolify is running on. Don't delete this!",
'user' => 'root', 'user' => 'root',
'ip' => "host.docker.internal", 'ip' => "host.docker.internal",
'team_id' => 0, '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->is_validated = true;
$server->settings->save(); $server->settings->save();
} }

View File

@ -4,9 +4,11 @@
<div class="flex gap-2"> <div class="flex gap-2">
<h2>General</h2> <h2>General</h2>
<x-inputs.button type="submit">Save</x-inputs.button> <x-inputs.button type="submit">Save</x-inputs.button>
<x-inputs.button isWarning x-on:click.prevent="deleteServer = true"> @if ($server_id !== 0)
Delete <x-inputs.button isWarning x-on:click.prevent="deleteServer = true">
</x-inputs.button> Delete
</x-inputs.button>
@endif
</div> </div>
<div class="flex flex-col gap-2 xl:flex-row"> <div class="flex flex-col gap-2 xl:flex-row">
<div class="flex flex-col w-96"> <div class="flex flex-col w-96">