fixes
This commit is contained in:
@@ -53,6 +53,8 @@ class Deploy extends Component
|
||||
|
||||
public function stop()
|
||||
{
|
||||
dispatch(new ContainerStopJob($this->application->id, $this->destination->server));
|
||||
instant_remote_process(["docker rm -f {$this->application->uuid}"], $this->application->destination->server);
|
||||
$this->application->status = get_container_status(server: $this->application->destination->server, container_id: $this->application->uuid);
|
||||
$this->application->save();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,9 @@ class Status extends Component
|
||||
{
|
||||
public Application $application;
|
||||
|
||||
protected $listeners = [
|
||||
'applicationStatusChanged' => 'pollingStatus',
|
||||
];
|
||||
public function pollingStatus()
|
||||
{
|
||||
$this->application->refresh();
|
||||
|
||||
@@ -7,6 +7,7 @@ use App\Models\Server;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Livewire\Component;
|
||||
use LocalStorage;
|
||||
|
||||
class PrivateKey extends Component
|
||||
{
|
||||
@@ -19,8 +20,7 @@ class PrivateKey extends Component
|
||||
'private_key_id' => $private_key_id
|
||||
]);
|
||||
// Delete the old ssh mux file to force a new one to be created
|
||||
Storage::disk('local')->delete(".ssh/ssh_mux_{$server->first()->ip}_{$server->first()->port}_{$server->first()->user}");
|
||||
|
||||
LocalStorage::ssh_mux()->delete("{$server->first()->ip}_{$server->first()->port}_{$server->first()->user}");
|
||||
return redirect()->route('server.show', $this->parameters['server_uuid']);
|
||||
}
|
||||
public function mount()
|
||||
|
||||
@@ -2,8 +2,12 @@
|
||||
|
||||
namespace App\Http\Livewire\Settings;
|
||||
|
||||
use App\Enums\ActivityTypes;
|
||||
use App\Models\InstanceSettings as ModelsInstanceSettings;
|
||||
use App\Models\Server;
|
||||
use Livewire\Component;
|
||||
use Spatie\Url\Url;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
class Form extends Component
|
||||
{
|
||||
@@ -44,5 +48,59 @@ class Form extends Component
|
||||
}
|
||||
$this->validate();
|
||||
$this->settings->save();
|
||||
if (isset($this->settings->fqdn)) {
|
||||
if (config('app.env') == 'local') {
|
||||
$server = Server::findOrFail(1);
|
||||
$dynamic_config_path = '/data/coolify/proxy/dynamic';
|
||||
} else {
|
||||
$server = Server::findOrFail(0);
|
||||
$dynamic_config_path = '/traefik/dynamic';
|
||||
}
|
||||
$url = Url::fromString($this->settings->fqdn);
|
||||
$host = $url->getHost();
|
||||
$schema = $url->getScheme();
|
||||
$entryPoints = [
|
||||
0 => 'http',
|
||||
];
|
||||
if ($schema === 'https') {
|
||||
$entryPoints[] = 'https';
|
||||
}
|
||||
$traefik_dynamic_conf = [
|
||||
'http' =>
|
||||
[
|
||||
'routers' =>
|
||||
[
|
||||
'coolify' =>
|
||||
[
|
||||
'entryPoints' => $entryPoints,
|
||||
'service' => 'coolify',
|
||||
'rule' => "Host(`{$host}`)",
|
||||
],
|
||||
],
|
||||
'services' =>
|
||||
[
|
||||
'coolify' =>
|
||||
[
|
||||
'loadBalancer' =>
|
||||
[
|
||||
'servers' =>
|
||||
[
|
||||
0 =>
|
||||
[
|
||||
'url' => 'http://coolify:80',
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
$yaml = Yaml::dump($traefik_dynamic_conf);
|
||||
$base64 = base64_encode($yaml);
|
||||
remote_process([
|
||||
"mkdir -p $dynamic_config_path",
|
||||
"echo '$base64' | base64 -d > $dynamic_config_path/coolify.yaml",
|
||||
], $server, ActivityTypes::INLINE->value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@ use Illuminate\Support\Facades\Storage;
|
||||
use Spatie\Activitylog\Models\Activity;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
use Illuminate\Support\Str;
|
||||
use LocalStorage;
|
||||
use Log;
|
||||
use Spatie\Url\Url;
|
||||
|
||||
class ApplicationDeploymentJob implements ShouldQueue
|
||||
@@ -203,7 +205,7 @@ COPY --from={$this->application->uuid}:{$this->git_commit}-build /app/{$this->ap
|
||||
$this->fail();
|
||||
} finally {
|
||||
if (isset($this->docker_compose)) {
|
||||
Storage::disk('deployments')->put(Str::kebab($this->application->name) . '/docker-compose.yml', $this->docker_compose);
|
||||
LocalStorage::deployments()->put(Str::kebab($this->application->name) . '/docker-compose.yml', $this->docker_compose);
|
||||
}
|
||||
$this->execute_now(["docker rm -f {$this->deployment_uuid} >/dev/null 2>&1"], hideFromOutput: true);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ class ContainerStatusJob implements ShouldQueue, ShouldBeUnique
|
||||
public string|null $application_id = null,
|
||||
) {
|
||||
if ($this->application_id) {
|
||||
$this->application = Application::find($this->application_id)->first();
|
||||
$this->application = Application::find($this->application_id);
|
||||
}
|
||||
}
|
||||
public function uniqueId(): string
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Models\Application;
|
||||
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;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class ContainerStopJob implements ShouldQueue, ShouldBeUnique
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
public function __construct(
|
||||
public int $application_id,
|
||||
public Server $server,
|
||||
) {
|
||||
}
|
||||
public function uniqueId(): int
|
||||
{
|
||||
return $this->application_id;
|
||||
}
|
||||
public function handle(): void
|
||||
{
|
||||
try {
|
||||
$application = Application::find($this->application_id)->first();
|
||||
instant_remote_process(["docker rm -f {$application->uuid}"], $this->server);
|
||||
$application->status = get_container_status(server: $application->destination->server, container_id: $application->uuid);
|
||||
$application->save();
|
||||
} catch (\Exception $e) {
|
||||
Log::error($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ use Illuminate\Support\Facades\Process;
|
||||
use Illuminate\Support\Facades\Queue;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Support\Str;
|
||||
use LocalStorage;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user