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_SERVICE=php
APP_ENV=local

View File

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

View File

@ -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']
]);
}
}

View File

@ -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);

View File

@ -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');

View File

@ -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();
}

View File

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