@@ -3,8 +3,8 @@
 | 
				
			|||||||
namespace App\Console;
 | 
					namespace App\Console;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use App\Jobs\InstanceAutoUpdateJob;
 | 
					use App\Jobs\InstanceAutoUpdateJob;
 | 
				
			||||||
use App\Jobs\InstanceProxyCheckJob;
 | 
					use App\Jobs\ProxyCheckJob;
 | 
				
			||||||
use App\Jobs\InstanceDockerCleanupJob;
 | 
					use App\Jobs\DockerCleanupJob;
 | 
				
			||||||
use Illuminate\Console\Scheduling\Schedule;
 | 
					use Illuminate\Console\Scheduling\Schedule;
 | 
				
			||||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
 | 
					use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -14,12 +14,12 @@ class Kernel extends ConsoleKernel
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        if (isDev()) {
 | 
					        if (isDev()) {
 | 
				
			||||||
            $schedule->command('horizon:snapshot')->everyMinute();
 | 
					            $schedule->command('horizon:snapshot')->everyMinute();
 | 
				
			||||||
            // $schedule->job(new InstanceDockerCleanupJob)->everyMinute();
 | 
					            // $schedule->job(new DockerCleanupJob)->everyOddHour();
 | 
				
			||||||
            // $schedule->job(new InstanceAutoUpdateJob(true))->everyMinute();
 | 
					            // $schedule->job(new InstanceAutoUpdateJob(true))->everyMinute();
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            $schedule->command('horizon:snapshot')->everyFiveMinutes();
 | 
					            $schedule->command('horizon:snapshot')->everyFiveMinutes();
 | 
				
			||||||
            $schedule->job(new InstanceDockerCleanupJob)->everyFiveMinutes();
 | 
					            $schedule->job(new DockerCleanupJob)->everyTenMinutes();
 | 
				
			||||||
            $schedule->job(new InstanceProxyCheckJob)->everyFiveMinutes();
 | 
					            $schedule->job(new ProxyCheckJob)->everyFiveMinutes();
 | 
				
			||||||
            $schedule->job(new InstanceAutoUpdateJob)->everyTenMinutes();
 | 
					            $schedule->job(new InstanceAutoUpdateJob)->everyTenMinutes();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,6 +5,7 @@ namespace App\Http\Livewire\Project\Application;
 | 
				
			|||||||
use App\Enums\ApplicationDeploymentStatus;
 | 
					use App\Enums\ApplicationDeploymentStatus;
 | 
				
			||||||
use App\Models\Application;
 | 
					use App\Models\Application;
 | 
				
			||||||
use App\Models\ApplicationDeploymentQueue;
 | 
					use App\Models\ApplicationDeploymentQueue;
 | 
				
			||||||
 | 
					use App\Models\Server;
 | 
				
			||||||
use Illuminate\Support\Carbon;
 | 
					use Illuminate\Support\Carbon;
 | 
				
			||||||
use Illuminate\Support\Facades\Process;
 | 
					use Illuminate\Support\Facades\Process;
 | 
				
			||||||
use Livewire\Component;
 | 
					use Livewire\Component;
 | 
				
			||||||
@@ -15,29 +16,34 @@ class DeploymentNavbar extends Component
 | 
				
			|||||||
    protected $listeners = ['deploymentFinished'];
 | 
					    protected $listeners = ['deploymentFinished'];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public ApplicationDeploymentQueue $application_deployment_queue;
 | 
					    public ApplicationDeploymentQueue $application_deployment_queue;
 | 
				
			||||||
 | 
					    public Application $application;
 | 
				
			||||||
 | 
					    public Server $server;
 | 
				
			||||||
    public bool $is_debug_enabled = false;
 | 
					    public bool $is_debug_enabled = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function mount()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $this->application = Application::find($this->application_deployment_queue->application_id);
 | 
				
			||||||
 | 
					        $this->server = $this->application->destination->server;
 | 
				
			||||||
 | 
					        $this->is_debug_enabled = $this->application->settings->is_debug_enabled;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    public function deploymentFinished()
 | 
					    public function deploymentFinished()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $this->application_deployment_queue->refresh();
 | 
					        $this->application_deployment_queue->refresh();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    public function show_debug()
 | 
					    public function show_debug()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $application = Application::find($this->application_deployment_queue->application_id);
 | 
					        $this->application->settings->is_debug_enabled = !$this->application->settings->is_debug_enabled;
 | 
				
			||||||
        $application->settings->is_debug_enabled = !$application->settings->is_debug_enabled;
 | 
					        $this->application->settings->save();
 | 
				
			||||||
        $application->settings->save();
 | 
					        $this->is_debug_enabled = $this->application->settings->is_debug_enabled;
 | 
				
			||||||
        $this->is_debug_enabled = $application->settings->is_debug_enabled;
 | 
					 | 
				
			||||||
        $this->emit('refreshQueue');
 | 
					        $this->emit('refreshQueue');
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    public function cancel()
 | 
					    public function cancel()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
            $kill_command = "kill -9 {$this->application_deployment_queue->current_process_id}";
 | 
					            $kill_command = "kill -9 {$this->application_deployment_queue->current_process_id}";
 | 
				
			||||||
            $application = Application::find($this->application_deployment_queue->application_id);
 | 
					 | 
				
			||||||
            $server = $application->destination->server;
 | 
					 | 
				
			||||||
            if ($this->application_deployment_queue->current_process_id) {
 | 
					            if ($this->application_deployment_queue->current_process_id) {
 | 
				
			||||||
                $process = Process::run("ps -p {$this->application_deployment_queue->current_process_id} -o command --no-headers");
 | 
					                $process = Process::run("ps -p {$this->application_deployment_queue->current_process_id} -o command --no-headers");
 | 
				
			||||||
                if (Str::of($process->output())->contains([$server->ip, 'EOF-COOLIFY-SSH'])) {
 | 
					                if (Str::of($process->output())->contains([$this->server->ip, 'EOF-COOLIFY-SSH'])) {
 | 
				
			||||||
                    Process::run($kill_command);
 | 
					                    Process::run($kill_command);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                $previous_logs = json_decode($this->application_deployment_queue->logs, associative: true, flags: JSON_THROW_ON_ERROR);
 | 
					                $previous_logs = json_decode($this->application_deployment_queue->logs, associative: true, flags: JSON_THROW_ON_ERROR);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -32,7 +32,7 @@ class General extends Component
 | 
				
			|||||||
    public bool $is_force_https_enabled;
 | 
					    public bool $is_force_https_enabled;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    protected $rules = [
 | 
					    protected $rules = [
 | 
				
			||||||
        'application.name' => 'required|min:6',
 | 
					        'application.name' => 'required',
 | 
				
			||||||
        'application.fqdn' => 'nullable',
 | 
					        'application.fqdn' => 'nullable',
 | 
				
			||||||
        'application.git_repository' => 'required',
 | 
					        'application.git_repository' => 'required',
 | 
				
			||||||
        'application.git_branch' => 'required',
 | 
					        'application.git_branch' => 'required',
 | 
				
			||||||
@@ -67,6 +67,11 @@ class General extends Component
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        // @TODO: find another way - if possible
 | 
					        // @TODO: find another way - if possible
 | 
				
			||||||
        $this->application->settings->is_static = $this->is_static;
 | 
					        $this->application->settings->is_static = $this->is_static;
 | 
				
			||||||
 | 
					        if ($this->is_static) {
 | 
				
			||||||
 | 
					            $this->application->ports_exposes = 80;
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            $this->application->ports_exposes = 3000;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        $this->application->settings->is_git_submodules_enabled = $this->is_git_submodules_enabled;
 | 
					        $this->application->settings->is_git_submodules_enabled = $this->is_git_submodules_enabled;
 | 
				
			||||||
        $this->application->settings->is_git_lfs_enabled = $this->is_git_lfs_enabled;
 | 
					        $this->application->settings->is_git_lfs_enabled = $this->is_git_lfs_enabled;
 | 
				
			||||||
        $this->application->settings->is_debug_enabled = $this->is_debug_enabled;
 | 
					        $this->application->settings->is_debug_enabled = $this->is_debug_enabled;
 | 
				
			||||||
@@ -74,6 +79,7 @@ class General extends Component
 | 
				
			|||||||
        $this->application->settings->is_auto_deploy_enabled = $this->is_auto_deploy_enabled;
 | 
					        $this->application->settings->is_auto_deploy_enabled = $this->is_auto_deploy_enabled;
 | 
				
			||||||
        $this->application->settings->is_force_https_enabled = $this->is_force_https_enabled;
 | 
					        $this->application->settings->is_force_https_enabled = $this->is_force_https_enabled;
 | 
				
			||||||
        $this->application->settings->save();
 | 
					        $this->application->settings->save();
 | 
				
			||||||
 | 
					        $this->application->save();
 | 
				
			||||||
        $this->application->refresh();
 | 
					        $this->application->refresh();
 | 
				
			||||||
        $this->emit('success', 'Application settings updated!');
 | 
					        $this->emit('success', 'Application settings updated!');
 | 
				
			||||||
        $this->checkWildCardDomain();
 | 
					        $this->checkWildCardDomain();
 | 
				
			||||||
@@ -126,7 +132,12 @@ class General extends Component
 | 
				
			|||||||
            $domains = Str::of($this->application->fqdn)->trim()->explode(',')->map(function ($domain) {
 | 
					            $domains = Str::of($this->application->fqdn)->trim()->explode(',')->map(function ($domain) {
 | 
				
			||||||
                return Str::of($domain)->trim()->lower();
 | 
					                return Str::of($domain)->trim()->lower();
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
 | 
					            if ($this->application->base_directory && $this->application->base_directory !== '/') {
 | 
				
			||||||
 | 
					                $this->application->base_directory = rtrim($this->application->base_directory, '/');
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            if ($this->application->publish_directory && $this->application->publish_directory !== '/') {
 | 
				
			||||||
 | 
					                $this->application->publish_directory = rtrim($this->application->publish_directory, '/');
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
            $this->application->fqdn = $domains->implode(',');
 | 
					            $this->application->fqdn = $domains->implode(',');
 | 
				
			||||||
            $this->application->save();
 | 
					            $this->application->save();
 | 
				
			||||||
            $this->emit('success', 'Application settings updated!');
 | 
					            $this->emit('success', 'Application settings updated!');
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -12,6 +12,7 @@ class Form extends Component
 | 
				
			|||||||
    public $uptime;
 | 
					    public $uptime;
 | 
				
			||||||
    public $dockerVersion;
 | 
					    public $dockerVersion;
 | 
				
			||||||
    public string|null $wildcard_domain = null;
 | 
					    public string|null $wildcard_domain = null;
 | 
				
			||||||
 | 
					    public int $cleanup_after_percentage;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    protected $rules = [
 | 
					    protected $rules = [
 | 
				
			||||||
        'server.name' => 'required|min:6',
 | 
					        'server.name' => 'required|min:6',
 | 
				
			||||||
@@ -35,6 +36,7 @@ class Form extends Component
 | 
				
			|||||||
    public function mount()
 | 
					    public function mount()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $this->wildcard_domain = $this->server->settings->wildcard_domain;
 | 
					        $this->wildcard_domain = $this->server->settings->wildcard_domain;
 | 
				
			||||||
 | 
					        $this->cleanup_after_percentage = $this->server->settings->cleanup_after_percentage;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    public function installDocker()
 | 
					    public function installDocker()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
@@ -91,6 +93,7 @@ class Form extends Component
 | 
				
			|||||||
        //     return;
 | 
					        //     return;
 | 
				
			||||||
        // }
 | 
					        // }
 | 
				
			||||||
        $this->server->settings->wildcard_domain = $this->wildcard_domain;
 | 
					        $this->server->settings->wildcard_domain = $this->wildcard_domain;
 | 
				
			||||||
 | 
					        $this->server->settings->cleanup_after_percentage = $this->cleanup_after_percentage;
 | 
				
			||||||
        $this->server->settings->save();
 | 
					        $this->server->settings->save();
 | 
				
			||||||
        $this->server->save();
 | 
					        $this->server->save();
 | 
				
			||||||
        $this->emit('success', 'Server updated successfully.');
 | 
					        $this->emit('success', 'Server updated successfully.');
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,7 +2,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
namespace App\Http\Livewire\Settings;
 | 
					namespace App\Http\Livewire\Settings;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use App\Jobs\InstanceProxyCheckJob;
 | 
					use App\Jobs\ProxyCheckJob;
 | 
				
			||||||
use App\Models\InstanceSettings as ModelsInstanceSettings;
 | 
					use App\Models\InstanceSettings as ModelsInstanceSettings;
 | 
				
			||||||
use App\Models\Server;
 | 
					use App\Models\Server;
 | 
				
			||||||
use Livewire\Component;
 | 
					use Livewire\Component;
 | 
				
			||||||
@@ -138,7 +138,7 @@ class Configuration extends Component
 | 
				
			|||||||
        $this->server = Server::findOrFail(0);
 | 
					        $this->server = Server::findOrFail(0);
 | 
				
			||||||
        $this->setup_instance_fqdn();
 | 
					        $this->setup_instance_fqdn();
 | 
				
			||||||
        if ($this->settings->fqdn) {
 | 
					        if ($this->settings->fqdn) {
 | 
				
			||||||
            dispatch(new InstanceProxyCheckJob());
 | 
					            dispatch(new ProxyCheckJob());
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        $this->emit('success', 'Instance settings updated successfully!');
 | 
					        $this->emit('success', 'Instance settings updated successfully!');
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -19,6 +19,7 @@ use Illuminate\Foundation\Bus\Dispatchable;
 | 
				
			|||||||
use Illuminate\Queue\InteractsWithQueue;
 | 
					use Illuminate\Queue\InteractsWithQueue;
 | 
				
			||||||
use Illuminate\Queue\SerializesModels;
 | 
					use Illuminate\Queue\SerializesModels;
 | 
				
			||||||
use Illuminate\Support\Collection;
 | 
					use Illuminate\Support\Collection;
 | 
				
			||||||
 | 
					use Illuminate\Support\Facades\Storage;
 | 
				
			||||||
use Spatie\Url\Url;
 | 
					use Spatie\Url\Url;
 | 
				
			||||||
use Illuminate\Support\Str;
 | 
					use Illuminate\Support\Str;
 | 
				
			||||||
use Symfony\Component\Yaml\Yaml;
 | 
					use Symfony\Component\Yaml\Yaml;
 | 
				
			||||||
@@ -48,6 +49,7 @@ class ApplicationDeploymentJob implements ShouldQueue
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    private string $container_name;
 | 
					    private string $container_name;
 | 
				
			||||||
    private string $workdir;
 | 
					    private string $workdir;
 | 
				
			||||||
 | 
					    private string $build_workdir;
 | 
				
			||||||
    private string $build_image_name;
 | 
					    private string $build_image_name;
 | 
				
			||||||
    private string $production_image_name;
 | 
					    private string $production_image_name;
 | 
				
			||||||
    private bool $is_debug_enabled;
 | 
					    private bool $is_debug_enabled;
 | 
				
			||||||
@@ -76,6 +78,7 @@ class ApplicationDeploymentJob implements ShouldQueue
 | 
				
			|||||||
        $this->private_key_location = save_private_key_for_server($this->server);
 | 
					        $this->private_key_location = save_private_key_for_server($this->server);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->workdir = "/artifacts/{$this->deployment_uuid}";
 | 
					        $this->workdir = "/artifacts/{$this->deployment_uuid}";
 | 
				
			||||||
 | 
					        $this->build_workdir = "{$this->workdir}" . rtrim($this->application->base_directory, '/');
 | 
				
			||||||
        $this->is_debug_enabled = $this->application->settings->is_debug_enabled;
 | 
					        $this->is_debug_enabled = $this->application->settings->is_debug_enabled;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->container_name = generate_container_name($this->application->uuid, $this->pull_request_id);
 | 
					        $this->container_name = generate_container_name($this->application->uuid, $this->pull_request_id);
 | 
				
			||||||
@@ -104,6 +107,7 @@ class ApplicationDeploymentJob implements ShouldQueue
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public function handle(): void
 | 
					    public function handle(): void
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					        ray()->measure();
 | 
				
			||||||
        $this->application_deployment_queue->update([
 | 
					        $this->application_deployment_queue->update([
 | 
				
			||||||
            'status' => ApplicationDeploymentStatus::IN_PROGRESS->value,
 | 
					            'status' => ApplicationDeploymentStatus::IN_PROGRESS->value,
 | 
				
			||||||
        ]);
 | 
					        ]);
 | 
				
			||||||
@@ -116,31 +120,32 @@ class ApplicationDeploymentJob implements ShouldQueue
 | 
				
			|||||||
            $this->next(ApplicationDeploymentStatus::FINISHED->value);
 | 
					            $this->next(ApplicationDeploymentStatus::FINISHED->value);
 | 
				
			||||||
        } catch (\Exception $e) {
 | 
					        } catch (\Exception $e) {
 | 
				
			||||||
            ray($e);
 | 
					            ray($e);
 | 
				
			||||||
            $this->execute_remote_command([
 | 
					            $this->fail($e);
 | 
				
			||||||
                ["echo '\nOops something is not okay, are you okay? 😢'"],
 | 
					 | 
				
			||||||
                ["echo '\n\n{$e->getMessage()}'"]
 | 
					 | 
				
			||||||
            ]);
 | 
					 | 
				
			||||||
            $this->fail($e->getMessage());
 | 
					 | 
				
			||||||
        } finally {
 | 
					        } finally {
 | 
				
			||||||
            // if (isset($this->docker_compose)) {
 | 
					            if (isset($this->docker_compose)) {
 | 
				
			||||||
            //     Storage::disk('deployments')->put(Str::kebab($this->application->name) . '/docker-compose.yml', $this->docker_compose);
 | 
					                Storage::disk('deployments')->put(Str::kebab($this->application->name) . '/docker-compose.yml', $this->docker_compose);
 | 
				
			||||||
            // }
 | 
					            }
 | 
				
			||||||
            $this->execute_remote_command(
 | 
					            $this->execute_remote_command(
 | 
				
			||||||
                [
 | 
					                [
 | 
				
			||||||
                    "docker rm -f {$this->deployment_uuid} >/dev/null 2>&1",
 | 
					                    "docker rm -f {$this->deployment_uuid} >/dev/null 2>&1",
 | 
				
			||||||
                    "hidden" => true,
 | 
					                    "hidden" => true,
 | 
				
			||||||
                ]
 | 
					                ]
 | 
				
			||||||
            );
 | 
					            );
 | 
				
			||||||
 | 
					            ray()->measure();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    public function failed(Throwable $exception): void
 | 
					    public function failed(Throwable $exception): void
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        ray($exception);
 | 
					        $this->execute_remote_command(
 | 
				
			||||||
 | 
					            ["echo 'Oops something is not okay, are you okay? 😢'"],
 | 
				
			||||||
 | 
					            ["echo '{$exception->getMessage()}'"]
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
        $this->next(ApplicationDeploymentStatus::FAILED->value);
 | 
					        $this->next(ApplicationDeploymentStatus::FAILED->value);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    private function execute_in_builder(string $command)
 | 
					    private function execute_in_builder(string $command)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        return "docker exec {$this->deployment_uuid} bash -c '{$command} |& tee -a /proc/1/fd/1'";
 | 
					        return "docker exec {$this->deployment_uuid} bash -c '{$command}'";
 | 
				
			||||||
 | 
					        // return "docker exec {$this->deployment_uuid} bash -c '{$command} |& tee -a /proc/1/fd/1; [ \$PIPESTATUS -eq 0 ] || exit \$PIPESTATUS'";
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    private function deploy()
 | 
					    private function deploy()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
@@ -153,13 +158,18 @@ class ApplicationDeploymentJob implements ShouldQueue
 | 
				
			|||||||
        $this->prepare_builder_image();
 | 
					        $this->prepare_builder_image();
 | 
				
			||||||
        $this->clone_repository();
 | 
					        $this->clone_repository();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->build_image_name = "{$this->application->git_repository}:{$this->commit}-build";
 | 
					        $tag = Str::of("{$this->commit}-{$this->application->id}-{$this->pull_request_id}");
 | 
				
			||||||
        $this->production_image_name = "{$this->application->uuid}:{$this->commit}";
 | 
					        if (strlen($tag) > 128) {
 | 
				
			||||||
 | 
					            $tag = $tag->substr(0, 128);
 | 
				
			||||||
 | 
					        };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $this->build_image_name = "{$this->application->git_repository}:{$tag}-build";
 | 
				
			||||||
 | 
					        $this->production_image_name = "{$this->application->uuid}:{$tag}";
 | 
				
			||||||
        ray('Build Image Name: ' . $this->build_image_name . ' & Production Image Name: ' . $this->production_image_name)->green();
 | 
					        ray('Build Image Name: ' . $this->build_image_name . ' & Production Image Name: ' . $this->production_image_name)->green();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (!$this->force_rebuild) {
 | 
					        if (!$this->force_rebuild) {
 | 
				
			||||||
            $this->execute_remote_command([
 | 
					            $this->execute_remote_command([
 | 
				
			||||||
                "docker images -q {$this->application->uuid}:{$this->commit} 2>/dev/null", "hidden" => true, "save" => "local_image_found"
 | 
					                "docker images -q {$this->production_image_name} 2>/dev/null", "hidden" => true, "save" => "local_image_found"
 | 
				
			||||||
            ]);
 | 
					            ]);
 | 
				
			||||||
            if (Str::of($this->saved_outputs->get('local_image_found'))->isNotEmpty()) {
 | 
					            if (Str::of($this->saved_outputs->get('local_image_found'))->isNotEmpty()) {
 | 
				
			||||||
                $this->execute_remote_command([
 | 
					                $this->execute_remote_command([
 | 
				
			||||||
@@ -237,15 +247,34 @@ class ApplicationDeploymentJob implements ShouldQueue
 | 
				
			|||||||
                $this->execute_in_builder("docker build -f {$this->workdir}/Dockerfile {$this->build_args} --progress plain -t $this->build_image_name {$this->workdir}"), "hidden" => true
 | 
					                $this->execute_in_builder("docker build -f {$this->workdir}/Dockerfile {$this->build_args} --progress plain -t $this->build_image_name {$this->workdir}"), "hidden" => true
 | 
				
			||||||
            ]);
 | 
					            ]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            $dockerfile = "FROM {$this->application->static_image}
 | 
					            $dockerfile = base64_encode("FROM {$this->application->static_image}
 | 
				
			||||||
WORKDIR /usr/share/nginx/html/
 | 
					WORKDIR /usr/share/nginx/html/
 | 
				
			||||||
LABEL coolify.deploymentId={$this->deployment_uuid}
 | 
					LABEL coolify.deploymentId={$this->deployment_uuid}
 | 
				
			||||||
COPY --from=$this->build_image_name /app/{$this->application->publish_directory} .";
 | 
					COPY --from=$this->build_image_name /app/{$this->application->publish_directory} .
 | 
				
			||||||
            $docker_file = base64_encode($dockerfile);
 | 
					COPY ./nginx.conf /etc/nginx/conf.d/default.conf");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            $nginx_config = base64_encode("server {
 | 
				
			||||||
 | 
					                listen       80;
 | 
				
			||||||
 | 
					                listen  [::]:80;
 | 
				
			||||||
 | 
					                server_name  localhost;
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					                location / {
 | 
				
			||||||
 | 
					                    root   /usr/share/nginx/html;
 | 
				
			||||||
 | 
					                    index  index.html;
 | 
				
			||||||
 | 
					                    try_files \$uri \$uri/index.html \$uri/ /index.html =404;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					                error_page   500 502 503 504  /50x.html;
 | 
				
			||||||
 | 
					                location = /50x.html {
 | 
				
			||||||
 | 
					                    root   /usr/share/nginx/html;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }");
 | 
				
			||||||
            $this->execute_remote_command(
 | 
					            $this->execute_remote_command(
 | 
				
			||||||
                [
 | 
					                [
 | 
				
			||||||
                    $this->execute_in_builder("echo '{$docker_file}' | base64 -d > {$this->workdir}/Dockerfile-prod")
 | 
					                    $this->execute_in_builder("echo '{$dockerfile}' | base64 -d > {$this->workdir}/Dockerfile-prod")
 | 
				
			||||||
 | 
					                ],
 | 
				
			||||||
 | 
					                [
 | 
				
			||||||
 | 
					                    $this->execute_in_builder("echo '{$nginx_config}' | base64 -d > {$this->workdir}/nginx.conf")
 | 
				
			||||||
                ],
 | 
					                ],
 | 
				
			||||||
                [
 | 
					                [
 | 
				
			||||||
                    $this->execute_in_builder("docker build -f {$this->workdir}/Dockerfile-prod {$this->build_args} --progress plain -t $this->production_image_name {$this->workdir}"), "hidden" => true
 | 
					                    $this->execute_in_builder("docker build -f {$this->workdir}/Dockerfile-prod {$this->build_args} --progress plain -t $this->production_image_name {$this->workdir}"), "hidden" => true
 | 
				
			||||||
@@ -360,7 +389,6 @@ COPY --from=$this->build_image_name /app/{$this->application->publish_directory}
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
            $local_persistent_volumes[] = $volume_name . ':' . $persistentStorage->mount_path;
 | 
					            $local_persistent_volumes[] = $volume_name . ':' . $persistentStorage->mount_path;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        ray('local_persistent_volumes', $local_persistent_volumes)->green();
 | 
					 | 
				
			||||||
        return $local_persistent_volumes;
 | 
					        return $local_persistent_volumes;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    private function generate_local_persistent_volumes_only_volume_names()
 | 
					    private function generate_local_persistent_volumes_only_volume_names()
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,738 +0,0 @@
 | 
				
			|||||||
<?php
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
namespace App\Jobs;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
use App\Actions\CoolifyTask\RunRemoteProcess;
 | 
					 | 
				
			||||||
use App\Data\CoolifyTaskArgs;
 | 
					 | 
				
			||||||
use App\Enums\ActivityTypes;
 | 
					 | 
				
			||||||
use App\Enums\ProcessStatus;
 | 
					 | 
				
			||||||
use App\Models\Application;
 | 
					 | 
				
			||||||
use App\Models\ApplicationDeploymentQueue;
 | 
					 | 
				
			||||||
use App\Models\ApplicationPreview;
 | 
					 | 
				
			||||||
use App\Notifications\Notifications\Application\DeployedSuccessfullyNotification;
 | 
					 | 
				
			||||||
use App\Notifications\Notifications\Application\DeployedWithErrorNotification;
 | 
					 | 
				
			||||||
use Illuminate\Bus\Queueable;
 | 
					 | 
				
			||||||
use Illuminate\Contracts\Queue\ShouldQueue;
 | 
					 | 
				
			||||||
use Illuminate\Foundation\Bus\Dispatchable;
 | 
					 | 
				
			||||||
use Illuminate\Queue\InteractsWithQueue;
 | 
					 | 
				
			||||||
use Illuminate\Queue\SerializesModels;
 | 
					 | 
				
			||||||
use Illuminate\Support\Collection;
 | 
					 | 
				
			||||||
use Illuminate\Support\Facades\Storage;
 | 
					 | 
				
			||||||
use Spatie\Activitylog\Models\Activity;
 | 
					 | 
				
			||||||
use Symfony\Component\Yaml\Yaml;
 | 
					 | 
				
			||||||
use Illuminate\Support\Str;
 | 
					 | 
				
			||||||
use Spatie\Url\Url;
 | 
					 | 
				
			||||||
use Throwable;
 | 
					 | 
				
			||||||
use Visus\Cuid2\Cuid2;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
class ApplicationDeploymentJob implements ShouldQueue
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    private Application $application;
 | 
					 | 
				
			||||||
    private ApplicationDeploymentQueue $application_deployment_queue;
 | 
					 | 
				
			||||||
    private $destination;
 | 
					 | 
				
			||||||
    private $source;
 | 
					 | 
				
			||||||
    private Activity $activity;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    private string|null $git_commit = null;
 | 
					 | 
				
			||||||
    private string $workdir;
 | 
					 | 
				
			||||||
    private string $docker_compose;
 | 
					 | 
				
			||||||
    private $build_args;
 | 
					 | 
				
			||||||
    private $env_args;
 | 
					 | 
				
			||||||
    private string $build_image_name;
 | 
					 | 
				
			||||||
    private string $production_image_name;
 | 
					 | 
				
			||||||
    private string $container_name;
 | 
					 | 
				
			||||||
    private ApplicationPreview|null $preview = null;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public static int $batch_counter = 0;
 | 
					 | 
				
			||||||
    public $failOnTimeout = true;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public function __construct(
 | 
					 | 
				
			||||||
        public int $application_deployment_queue_id,
 | 
					 | 
				
			||||||
        public string $deployment_uuid,
 | 
					 | 
				
			||||||
        public string $application_id,
 | 
					 | 
				
			||||||
        public bool $force_rebuild = false,
 | 
					 | 
				
			||||||
        public string $rollback_commit = 'HEAD',
 | 
					 | 
				
			||||||
        public int $pull_request_id = 0,
 | 
					 | 
				
			||||||
    ) {
 | 
					 | 
				
			||||||
        $this->application_deployment_queue = ApplicationDeploymentQueue::find($this->application_deployment_queue_id);
 | 
					 | 
				
			||||||
        $this->application_deployment_queue->update([
 | 
					 | 
				
			||||||
            'status' => ProcessStatus::IN_PROGRESS->value,
 | 
					 | 
				
			||||||
        ]);
 | 
					 | 
				
			||||||
        if ($this->rollback_commit) {
 | 
					 | 
				
			||||||
            $this->git_commit = $this->rollback_commit;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $this->application = Application::find($this->application_id);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        ray('pullrequestId: ' . $this->pull_request_id);
 | 
					 | 
				
			||||||
        if ($this->pull_request_id !== 0) {
 | 
					 | 
				
			||||||
            $this->preview = ApplicationPreview::findPreviewByApplicationAndPullId($this->application->id, $this->pull_request_id);
 | 
					 | 
				
			||||||
            ray($this->preview);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $this->destination = $this->application->destination->getMorphClass()::where('id', $this->application->destination->id)->first();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $server = $this->destination->server;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $private_key_location = save_private_key_for_server($server);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $remoteProcessArgs = new CoolifyTaskArgs(
 | 
					 | 
				
			||||||
            server_ip: $server->ip,
 | 
					 | 
				
			||||||
            private_key_location: $private_key_location,
 | 
					 | 
				
			||||||
            command: 'overwritten-later',
 | 
					 | 
				
			||||||
            port: $server->port,
 | 
					 | 
				
			||||||
            user: $server->user,
 | 
					 | 
				
			||||||
            type: ActivityTypes::DEPLOYMENT->value,
 | 
					 | 
				
			||||||
            type_uuid: $this->deployment_uuid,
 | 
					 | 
				
			||||||
        );
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $this->activity = activity()
 | 
					 | 
				
			||||||
            ->performedOn($this->application)
 | 
					 | 
				
			||||||
            ->withProperties($remoteProcessArgs->toArray())
 | 
					 | 
				
			||||||
            ->event(ActivityTypes::DEPLOYMENT->value)
 | 
					 | 
				
			||||||
            ->log("[]");
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    public function handle(): void
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        try {
 | 
					 | 
				
			||||||
            if ($this->application->deploymentType() === 'source') {
 | 
					 | 
				
			||||||
                $this->source = $this->application->source->getMorphClass()::where('id', $this->application->source->id)->first();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            $this->workdir = "/artifacts/{$this->deployment_uuid}";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if ($this->pull_request_id !== 0) {
 | 
					 | 
				
			||||||
                ray('Deploying pull/' . $this->pull_request_id . '/head for application: ' . $this->application->name)->green();
 | 
					 | 
				
			||||||
                if ($this->application->fqdn) {
 | 
					 | 
				
			||||||
                    $preview_fqdn = data_get($this->preview, 'fqdn');
 | 
					 | 
				
			||||||
                    $template = $this->application->preview_url_template;
 | 
					 | 
				
			||||||
                    $url = Url::fromString($this->application->fqdn);
 | 
					 | 
				
			||||||
                    $host = $url->getHost();
 | 
					 | 
				
			||||||
                    $schema = $url->getScheme();
 | 
					 | 
				
			||||||
                    $random = new Cuid2(7);
 | 
					 | 
				
			||||||
                    $preview_fqdn = str_replace('{{random}}', $random, $template);
 | 
					 | 
				
			||||||
                    $preview_fqdn = str_replace('{{domain}}', $host, $preview_fqdn);
 | 
					 | 
				
			||||||
                    $preview_fqdn = str_replace('{{pr_id}}', $this->pull_request_id, $preview_fqdn);
 | 
					 | 
				
			||||||
                    $preview_fqdn = "$schema://$preview_fqdn";
 | 
					 | 
				
			||||||
                    $this->preview->fqdn = $preview_fqdn;
 | 
					 | 
				
			||||||
                    $this->preview->save();
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                $this->deploy_pull_request();
 | 
					 | 
				
			||||||
            } else {
 | 
					 | 
				
			||||||
                $this->deploy();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        } catch (\Exception $e) {
 | 
					 | 
				
			||||||
            $this->execute_now([
 | 
					 | 
				
			||||||
                "echo '\nOops something is not okay, are you okay? 😢'",
 | 
					 | 
				
			||||||
                "echo '\n\n{$e->getMessage()}'",
 | 
					 | 
				
			||||||
            ]);
 | 
					 | 
				
			||||||
            ray($e);
 | 
					 | 
				
			||||||
            $this->fail($e->getMessage());
 | 
					 | 
				
			||||||
        } finally {
 | 
					 | 
				
			||||||
            if (isset($this->docker_compose)) {
 | 
					 | 
				
			||||||
                Storage::disk('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);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    private function start_builder_image()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $this->execute_now([
 | 
					 | 
				
			||||||
            "echo -n 'Pulling latest version of the builder image (ghcr.io/coollabsio/coolify-builder)... '",
 | 
					 | 
				
			||||||
        ]);
 | 
					 | 
				
			||||||
        // if (isDev()) {
 | 
					 | 
				
			||||||
        //     $this->execute_now([
 | 
					 | 
				
			||||||
        //         "docker run -d --name {$this->deployment_uuid} --rm -v /var/run/docker.sock:/var/run/docker.sock coolify-builder",
 | 
					 | 
				
			||||||
        //     ], isDebuggable: true);
 | 
					 | 
				
			||||||
        // } else {
 | 
					 | 
				
			||||||
        $this->execute_now([
 | 
					 | 
				
			||||||
            "docker run --pull=always -d --name {$this->deployment_uuid} --rm -v /var/run/docker.sock:/var/run/docker.sock ghcr.io/coollabsio/coolify-builder",
 | 
					 | 
				
			||||||
        ], isDebuggable: true);
 | 
					 | 
				
			||||||
        // }
 | 
					 | 
				
			||||||
        $this->execute_now([
 | 
					 | 
				
			||||||
            "echo 'Done.'"
 | 
					 | 
				
			||||||
        ]);
 | 
					 | 
				
			||||||
        $this->execute_now([
 | 
					 | 
				
			||||||
            $this->execute_in_builder("mkdir -p {$this->workdir}"),
 | 
					 | 
				
			||||||
        ]);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    private function clone_repository()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $this->execute_now([
 | 
					 | 
				
			||||||
            "echo -n 'Importing {$this->application->git_repository}:{$this->application->git_branch} to {$this->workdir}... '"
 | 
					 | 
				
			||||||
        ]);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $this->execute_now([
 | 
					 | 
				
			||||||
            ...$this->importing_git_repository(),
 | 
					 | 
				
			||||||
        ], 'importing_git_repository');
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $this->execute_now([
 | 
					 | 
				
			||||||
            "echo 'Done.'"
 | 
					 | 
				
			||||||
        ]);
 | 
					 | 
				
			||||||
        // Get git commit
 | 
					 | 
				
			||||||
        $this->execute_now([$this->execute_in_builder("cd {$this->workdir} && git rev-parse HEAD")], 'commit_sha', hideFromOutput: true);
 | 
					 | 
				
			||||||
        $this->git_commit = $this->activity->properties->get('commit_sha');
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    private function cleanup_git()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $this->execute_now([
 | 
					 | 
				
			||||||
            $this->execute_in_builder("rm -fr {$this->workdir}/.git")
 | 
					 | 
				
			||||||
        ], hideFromOutput: true);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    private function generate_buildpack()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $this->execute_now([
 | 
					 | 
				
			||||||
            "echo -n 'Generating nixpacks configuration... '",
 | 
					 | 
				
			||||||
        ]);
 | 
					 | 
				
			||||||
        $this->execute_now([
 | 
					 | 
				
			||||||
            $this->nixpacks_build_cmd(),
 | 
					 | 
				
			||||||
            $this->execute_in_builder("cp {$this->workdir}/.nixpacks/Dockerfile {$this->workdir}/Dockerfile"),
 | 
					 | 
				
			||||||
            $this->execute_in_builder("rm -f {$this->workdir}/.nixpacks/Dockerfile"),
 | 
					 | 
				
			||||||
        ], isDebuggable: true);
 | 
					 | 
				
			||||||
        $this->execute_now([
 | 
					 | 
				
			||||||
            "echo 'Done... '",
 | 
					 | 
				
			||||||
        ]);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    private function build_image()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $this->execute_now([
 | 
					 | 
				
			||||||
            "echo -n 'Building image... '",
 | 
					 | 
				
			||||||
        ]);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if ($this->application->settings->is_static) {
 | 
					 | 
				
			||||||
            $this->execute_now([
 | 
					 | 
				
			||||||
                $this->execute_in_builder("docker build -f {$this->workdir}/Dockerfile {$this->build_args} --progress plain -t $this->build_image_name {$this->workdir}"),
 | 
					 | 
				
			||||||
            ], isDebuggable: true);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            $dockerfile = "FROM {$this->application->static_image}
 | 
					 | 
				
			||||||
WORKDIR /usr/share/nginx/html/
 | 
					 | 
				
			||||||
LABEL coolify.deploymentId={$this->deployment_uuid}
 | 
					 | 
				
			||||||
COPY --from=$this->build_image_name /app/{$this->application->publish_directory} .";
 | 
					 | 
				
			||||||
            $docker_file = base64_encode($dockerfile);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            $this->execute_now([
 | 
					 | 
				
			||||||
                $this->execute_in_builder("echo '{$docker_file}' | base64 -d > {$this->workdir}/Dockerfile-prod"),
 | 
					 | 
				
			||||||
                $this->execute_in_builder("docker build -f {$this->workdir}/Dockerfile-prod {$this->build_args} --progress plain -t $this->production_image_name {$this->workdir}"),
 | 
					 | 
				
			||||||
            ], hideFromOutput: true);
 | 
					 | 
				
			||||||
        } else {
 | 
					 | 
				
			||||||
            $this->execute_now([
 | 
					 | 
				
			||||||
                $this->execute_in_builder("docker build -f {$this->workdir}/Dockerfile {$this->build_args} --progress plain -t $this->production_image_name {$this->workdir}"),
 | 
					 | 
				
			||||||
            ], isDebuggable: true);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        $this->execute_now([
 | 
					 | 
				
			||||||
            "echo 'Done.'",
 | 
					 | 
				
			||||||
        ]);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    private function deploy_pull_request()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        dispatch(new ApplicationPullRequestUpdateJob(
 | 
					 | 
				
			||||||
            application_id: $this->application->id,
 | 
					 | 
				
			||||||
            pull_request_id: $this->pull_request_id,
 | 
					 | 
				
			||||||
            deployment_uuid: $this->deployment_uuid,
 | 
					 | 
				
			||||||
            status: 'in_progress'
 | 
					 | 
				
			||||||
        ));
 | 
					 | 
				
			||||||
        $this->build_image_name = "{$this->application->uuid}:pr-{$this->pull_request_id}-build";
 | 
					 | 
				
			||||||
        $this->production_image_name = "{$this->application->uuid}:pr-{$this->pull_request_id}";
 | 
					 | 
				
			||||||
        $this->container_name = generate_container_name($this->application->uuid, $this->pull_request_id);
 | 
					 | 
				
			||||||
        // Deploy pull request
 | 
					 | 
				
			||||||
        $this->execute_now([
 | 
					 | 
				
			||||||
            "echo 'Starting deployment of {$this->application->git_repository}:{$this->application->git_branch} PR#{$this->pull_request_id}...'",
 | 
					 | 
				
			||||||
        ]);
 | 
					 | 
				
			||||||
        $this->start_builder_image();
 | 
					 | 
				
			||||||
        $this->clone_repository();
 | 
					 | 
				
			||||||
        $this->cleanup_git();
 | 
					 | 
				
			||||||
        $this->generate_buildpack();
 | 
					 | 
				
			||||||
        $this->generate_compose_file();
 | 
					 | 
				
			||||||
        // Needs separate preview variables
 | 
					 | 
				
			||||||
        // $this->generate_build_env_variables();
 | 
					 | 
				
			||||||
        // $this->add_build_env_variables_to_dockerfile();
 | 
					 | 
				
			||||||
        $this->build_image();
 | 
					 | 
				
			||||||
        $this->stop_running_container();
 | 
					 | 
				
			||||||
        $this->start_by_compose_file();
 | 
					 | 
				
			||||||
        $this->next(ProcessStatus::FINISHED->value);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    private function deploy()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $this->container_name = generate_container_name($this->application->uuid);
 | 
					 | 
				
			||||||
        // Deploy normal commit
 | 
					 | 
				
			||||||
        $this->execute_now([
 | 
					 | 
				
			||||||
            "echo 'Starting deployment of {$this->application->git_repository}:{$this->application->git_branch}...'",
 | 
					 | 
				
			||||||
        ]);
 | 
					 | 
				
			||||||
        $this->start_builder_image();
 | 
					 | 
				
			||||||
        ray('Rollback Commit: ' . $this->rollback_commit)->green();
 | 
					 | 
				
			||||||
        if ($this->rollback_commit === 'HEAD') {
 | 
					 | 
				
			||||||
            $this->clone_repository();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        $this->build_image_name = "{$this->application->uuid}:{$this->git_commit}-build";
 | 
					 | 
				
			||||||
        $this->production_image_name = "{$this->application->uuid}:{$this->git_commit}";
 | 
					 | 
				
			||||||
        ray('Build Image Name: ' . $this->build_image_name . ' & Production Image Name:' . $this->production_image_name)->green();
 | 
					 | 
				
			||||||
        if (!$this->force_rebuild) {
 | 
					 | 
				
			||||||
            $this->execute_now([
 | 
					 | 
				
			||||||
                "docker images -q {$this->application->uuid}:{$this->git_commit} 2>/dev/null",
 | 
					 | 
				
			||||||
            ], 'local_image_found', hideFromOutput: true, ignoreErrors: true);
 | 
					 | 
				
			||||||
            $image_found = Str::of($this->activity->properties->get('local_image_found'))->trim()->isNotEmpty();
 | 
					 | 
				
			||||||
            if ($image_found) {
 | 
					 | 
				
			||||||
                $this->execute_now([
 | 
					 | 
				
			||||||
                    "echo 'Docker Image found locally with the same Git Commit SHA. Build skipped...'"
 | 
					 | 
				
			||||||
                ]);
 | 
					 | 
				
			||||||
                $this->generate_compose_file();
 | 
					 | 
				
			||||||
                $this->stop_running_container();
 | 
					 | 
				
			||||||
                $this->start_by_compose_file();
 | 
					 | 
				
			||||||
                $this->next(ProcessStatus::FINISHED->value);
 | 
					 | 
				
			||||||
                return;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        $this->cleanup_git();
 | 
					 | 
				
			||||||
        $this->generate_buildpack();
 | 
					 | 
				
			||||||
        $this->generate_compose_file();
 | 
					 | 
				
			||||||
        $this->generate_build_env_variables();
 | 
					 | 
				
			||||||
        $this->add_build_env_variables_to_dockerfile();
 | 
					 | 
				
			||||||
        $this->build_image();
 | 
					 | 
				
			||||||
        $this->stop_running_container();
 | 
					 | 
				
			||||||
        $this->start_by_compose_file();
 | 
					 | 
				
			||||||
        $this->next(ProcessStatus::FINISHED->value);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public function failed(Throwable $exception): void
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $this->next(ProcessStatus::ERROR->value);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    private function next(string $status)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        ray('Next Status: ' . $status)->green();
 | 
					 | 
				
			||||||
        $this->application_deployment_queue->update([
 | 
					 | 
				
			||||||
            'status' => $status,
 | 
					 | 
				
			||||||
        ]);
 | 
					 | 
				
			||||||
        ray($this->application_deployment_queue)->purple();
 | 
					 | 
				
			||||||
        ray($this->activity)->purple();
 | 
					 | 
				
			||||||
        $this->activity->properties = $this->activity->properties->merge([
 | 
					 | 
				
			||||||
            'status' => $status,
 | 
					 | 
				
			||||||
        ]);
 | 
					 | 
				
			||||||
        $this->activity->save();
 | 
					 | 
				
			||||||
        if ($this->pull_request_id) {
 | 
					 | 
				
			||||||
            dispatch(new ApplicationPullRequestUpdateJob(
 | 
					 | 
				
			||||||
                application_id: $this->application->id,
 | 
					 | 
				
			||||||
                pull_request_id: $this->pull_request_id,
 | 
					 | 
				
			||||||
                deployment_uuid: $this->deployment_uuid,
 | 
					 | 
				
			||||||
                status: $status
 | 
					 | 
				
			||||||
            ));
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        if ($this->application->fqdn) {
 | 
					 | 
				
			||||||
            dispatch(new InstanceProxyCheckJob());
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        queue_next_deployment($this->application);
 | 
					 | 
				
			||||||
        if ($status === ProcessStatus::FINISHED->value) {
 | 
					 | 
				
			||||||
            $this->application->environment->project->team->notify(new DeployedSuccessfullyNotification($this->application, $this->deployment_uuid, $this->preview));
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        if ($status === ProcessStatus::ERROR->value) {
 | 
					 | 
				
			||||||
            $this->application->environment->project->team->notify(new DeployedWithErrorNotification($this->application, $this->deployment_uuid, $this->preview));
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    private function execute_in_builder(string $command)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        return "docker exec {$this->deployment_uuid} bash -c '{$command} |& tee -a /proc/1/fd/1'";
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    private function generate_environment_variables($ports)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $environment_variables = collect();
 | 
					 | 
				
			||||||
        ray('Generate Environment Variables')->green();
 | 
					 | 
				
			||||||
        if ($this->pull_request_id === 0) {
 | 
					 | 
				
			||||||
            ray($this->application->runtime_environment_variables)->green();
 | 
					 | 
				
			||||||
            foreach ($this->application->runtime_environment_variables as $env) {
 | 
					 | 
				
			||||||
                $environment_variables->push("$env->key=$env->value");
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        } else {
 | 
					 | 
				
			||||||
            ray($this->application->runtime_environment_variables_preview)->green();
 | 
					 | 
				
			||||||
            foreach ($this->application->runtime_environment_variables_preview as $env) {
 | 
					 | 
				
			||||||
                $environment_variables->push("$env->key=$env->value");
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        // Add PORT if not exists, use the first port as default
 | 
					 | 
				
			||||||
        if ($environment_variables->filter(fn ($env) => Str::of($env)->contains('PORT'))->isEmpty()) {
 | 
					 | 
				
			||||||
            $environment_variables->push("PORT={$ports[0]}");
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        return $environment_variables->all();
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    private function generate_env_variables()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $this->env_args = collect([]);
 | 
					 | 
				
			||||||
        if ($this->pull_request_id === 0) {
 | 
					 | 
				
			||||||
            foreach ($this->application->nixpacks_environment_variables as $env) {
 | 
					 | 
				
			||||||
                $this->env_args->push("--env {$env->key}={$env->value}");
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        } else {
 | 
					 | 
				
			||||||
            foreach ($this->application->nixpacks_environment_variables_preview as $env) {
 | 
					 | 
				
			||||||
                $this->env_args->push("--env {$env->key}={$env->value}");
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $this->env_args = $this->env_args->implode(' ');
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    private function generate_build_env_variables()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $this->build_args = collect(["--build-arg SOURCE_COMMIT={$this->git_commit}"]);
 | 
					 | 
				
			||||||
        if ($this->pull_request_id === 0) {
 | 
					 | 
				
			||||||
            foreach ($this->application->build_environment_variables as $env) {
 | 
					 | 
				
			||||||
                $this->build_args->push("--build-arg {$env->key}={$env->value}");
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        } else {
 | 
					 | 
				
			||||||
            foreach ($this->application->build_environment_variables_preview as $env) {
 | 
					 | 
				
			||||||
                $this->build_args->push("--build-arg {$env->key}={$env->value}");
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $this->build_args = $this->build_args->implode(' ');
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    private function add_build_env_variables_to_dockerfile()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $this->execute_now([
 | 
					 | 
				
			||||||
            $this->execute_in_builder("cat {$this->workdir}/Dockerfile")
 | 
					 | 
				
			||||||
        ], propertyName: 'dockerfile', hideFromOutput: true);
 | 
					 | 
				
			||||||
        $dockerfile = collect(Str::of($this->activity->properties->get('dockerfile'))->trim()->explode("\n"));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        foreach ($this->application->build_environment_variables as $env) {
 | 
					 | 
				
			||||||
            $dockerfile->splice(1, 0, "ARG {$env->key}={$env->value}");
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        $dockerfile_base64 = base64_encode($dockerfile->implode("\n"));
 | 
					 | 
				
			||||||
        $this->execute_now([
 | 
					 | 
				
			||||||
            $this->execute_in_builder("echo '{$dockerfile_base64}' | base64 -d > {$this->workdir}/Dockerfile")
 | 
					 | 
				
			||||||
        ], hideFromOutput: true);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    private function generate_docker_compose()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $ports = $this->application->settings->is_static ? [80] : $this->application->ports_exposes_array;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $persistent_storages = $this->generate_local_persistent_volumes();
 | 
					 | 
				
			||||||
        $volume_names = $this->generate_local_persistent_volumes_only_volume_names();
 | 
					 | 
				
			||||||
        $environment_variables = $this->generate_environment_variables($ports);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $docker_compose = [
 | 
					 | 
				
			||||||
            'version' => '3.8',
 | 
					 | 
				
			||||||
            'services' => [
 | 
					 | 
				
			||||||
                $this->container_name => [
 | 
					 | 
				
			||||||
                    'image' => $this->production_image_name,
 | 
					 | 
				
			||||||
                    'container_name' => $this->container_name,
 | 
					 | 
				
			||||||
                    'restart' => 'always',
 | 
					 | 
				
			||||||
                    'environment' => $environment_variables,
 | 
					 | 
				
			||||||
                    'labels' => $this->set_labels_for_applications(),
 | 
					 | 
				
			||||||
                    'expose' => $ports,
 | 
					 | 
				
			||||||
                    'networks' => [
 | 
					 | 
				
			||||||
                        $this->destination->network,
 | 
					 | 
				
			||||||
                    ],
 | 
					 | 
				
			||||||
                    'healthcheck' => [
 | 
					 | 
				
			||||||
                        'test' => [
 | 
					 | 
				
			||||||
                            'CMD-SHELL',
 | 
					 | 
				
			||||||
                            $this->generate_healthcheck_commands()
 | 
					 | 
				
			||||||
                        ],
 | 
					 | 
				
			||||||
                        'interval' => $this->application->health_check_interval . 's',
 | 
					 | 
				
			||||||
                        'timeout' => $this->application->health_check_timeout . 's',
 | 
					 | 
				
			||||||
                        'retries' => $this->application->health_check_retries,
 | 
					 | 
				
			||||||
                        'start_period' => $this->application->health_check_start_period . 's'
 | 
					 | 
				
			||||||
                    ],
 | 
					 | 
				
			||||||
                    'mem_limit' => $this->application->limits_memory,
 | 
					 | 
				
			||||||
                    'memswap_limit' => $this->application->limits_memory_swap,
 | 
					 | 
				
			||||||
                    'mem_swappiness' => $this->application->limits_memory_swappiness,
 | 
					 | 
				
			||||||
                    'mem_reservation' => $this->application->limits_memory_reservation,
 | 
					 | 
				
			||||||
                    'cpus' => $this->application->limits_cpus,
 | 
					 | 
				
			||||||
                    'cpuset' => $this->application->limits_cpuset,
 | 
					 | 
				
			||||||
                    'cpu_shares' => $this->application->limits_cpu_shares,
 | 
					 | 
				
			||||||
                ]
 | 
					 | 
				
			||||||
            ],
 | 
					 | 
				
			||||||
            'networks' => [
 | 
					 | 
				
			||||||
                $this->destination->network => [
 | 
					 | 
				
			||||||
                    'external' => false,
 | 
					 | 
				
			||||||
                    'name' => $this->destination->network,
 | 
					 | 
				
			||||||
                    'attachable' => true,
 | 
					 | 
				
			||||||
                ]
 | 
					 | 
				
			||||||
            ]
 | 
					 | 
				
			||||||
        ];
 | 
					 | 
				
			||||||
        if (count($this->application->ports_mappings_array) > 0 && $this->pull_request_id === 0) {
 | 
					 | 
				
			||||||
            $docker_compose['services'][$this->container_name]['ports'] = $this->application->ports_mappings_array;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        if (count($persistent_storages) > 0) {
 | 
					 | 
				
			||||||
            $docker_compose['services'][$this->container_name]['volumes'] = $persistent_storages;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        if (count($volume_names) > 0) {
 | 
					 | 
				
			||||||
            $docker_compose['volumes'] = $volume_names;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        return Yaml::dump($docker_compose, 10);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    private function generate_local_persistent_volumes()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $local_persistent_volumes = [];
 | 
					 | 
				
			||||||
        foreach ($this->application->persistentStorages as $persistentStorage) {
 | 
					 | 
				
			||||||
            $volume_name = $persistentStorage->host_path ?? $persistentStorage->name;
 | 
					 | 
				
			||||||
            if ($this->pull_request_id !== 0) {
 | 
					 | 
				
			||||||
                $volume_name = $volume_name . '-pr-' . $this->pull_request_id;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            $local_persistent_volumes[] = $volume_name . ':' . $persistentStorage->mount_path;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        ray('local_persistent_volumes', $local_persistent_volumes)->green();
 | 
					 | 
				
			||||||
        return $local_persistent_volumes;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    private function generate_local_persistent_volumes_only_volume_names()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $local_persistent_volumes_names = [];
 | 
					 | 
				
			||||||
        foreach ($this->application->persistentStorages as $persistentStorage) {
 | 
					 | 
				
			||||||
            if ($persistentStorage->host_path) {
 | 
					 | 
				
			||||||
                continue;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            $name = $persistentStorage->name;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if ($this->pull_request_id !== 0) {
 | 
					 | 
				
			||||||
                $name = $name . '-pr-' . $this->pull_request_id;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            $local_persistent_volumes_names[$name] = [
 | 
					 | 
				
			||||||
                'name' => $name,
 | 
					 | 
				
			||||||
                'external' => false,
 | 
					 | 
				
			||||||
            ];
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        return $local_persistent_volumes_names;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    private function generate_healthcheck_commands()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        if (!$this->application->health_check_port) {
 | 
					 | 
				
			||||||
            $this->application->health_check_port = $this->application->ports_exposes_array[0];
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        if ($this->application->health_check_path) {
 | 
					 | 
				
			||||||
            $generated_healthchecks_commands = [
 | 
					 | 
				
			||||||
                "curl -s -X {$this->application->health_check_method} -f {$this->application->health_check_scheme}://{$this->application->health_check_host}:{$this->application->health_check_port}{$this->application->health_check_path} > /dev/null"
 | 
					 | 
				
			||||||
            ];
 | 
					 | 
				
			||||||
        } else {
 | 
					 | 
				
			||||||
            $generated_healthchecks_commands = [
 | 
					 | 
				
			||||||
                "curl -s -X {$this->application->health_check_method} -f {$this->application->health_check_scheme}://{$this->application->health_check_host}:{$this->application->health_check_port}/"
 | 
					 | 
				
			||||||
            ];
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        return implode(' ', $generated_healthchecks_commands);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    private function set_labels_for_applications()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $labels = [];
 | 
					 | 
				
			||||||
        $labels[] = 'coolify.managed=true';
 | 
					 | 
				
			||||||
        $labels[] = 'coolify.version=' . config('version');
 | 
					 | 
				
			||||||
        $labels[] = 'coolify.applicationId=' . $this->application->id;
 | 
					 | 
				
			||||||
        $labels[] = 'coolify.type=application';
 | 
					 | 
				
			||||||
        $labels[] = 'coolify.name=' . $this->application->name;
 | 
					 | 
				
			||||||
        if ($this->pull_request_id !== 0) {
 | 
					 | 
				
			||||||
            $labels[] = 'coolify.pullRequestId=' . $this->pull_request_id;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        if ($this->application->fqdn) {
 | 
					 | 
				
			||||||
            if ($this->pull_request_id !== 0) {
 | 
					 | 
				
			||||||
                $preview_fqdn = data_get($this->preview, 'fqdn');
 | 
					 | 
				
			||||||
                $template = $this->application->preview_url_template;
 | 
					 | 
				
			||||||
                $url = Url::fromString($this->application->fqdn);
 | 
					 | 
				
			||||||
                $host = $url->getHost();
 | 
					 | 
				
			||||||
                $schema = $url->getScheme();
 | 
					 | 
				
			||||||
                $random = new Cuid2(7);
 | 
					 | 
				
			||||||
                $preview_fqdn = str_replace('{{random}}', $random, $template);
 | 
					 | 
				
			||||||
                $preview_fqdn = str_replace('{{domain}}', $host, $preview_fqdn);
 | 
					 | 
				
			||||||
                $preview_fqdn = str_replace('{{pr_id}}', $this->pull_request_id, $preview_fqdn);
 | 
					 | 
				
			||||||
                $preview_fqdn = "$schema://$preview_fqdn";
 | 
					 | 
				
			||||||
                $this->preview->fqdn = $preview_fqdn;
 | 
					 | 
				
			||||||
                $this->preview->save();
 | 
					 | 
				
			||||||
                $domains = Str::of($preview_fqdn)->explode(',');
 | 
					 | 
				
			||||||
            } else {
 | 
					 | 
				
			||||||
                $domains = Str::of($this->application->fqdn)->explode(',');
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            $labels[] = 'traefik.enable=true';
 | 
					 | 
				
			||||||
            foreach ($domains as $domain) {
 | 
					 | 
				
			||||||
                $url = Url::fromString($domain);
 | 
					 | 
				
			||||||
                $host = $url->getHost();
 | 
					 | 
				
			||||||
                $path = $url->getPath();
 | 
					 | 
				
			||||||
                $schema = $url->getScheme();
 | 
					 | 
				
			||||||
                $slug = Str::slug($host . $path);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                $http_label = "{$this->application->uuid}-{$slug}-http";
 | 
					 | 
				
			||||||
                $https_label = "{$this->application->uuid}-{$slug}-https";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                if ($schema === 'https') {
 | 
					 | 
				
			||||||
                    // Set labels for https
 | 
					 | 
				
			||||||
                    $labels[] = "traefik.http.routers.{$https_label}.rule=Host(`{$host}`) && PathPrefix(`{$path}`)";
 | 
					 | 
				
			||||||
                    $labels[] = "traefik.http.routers.{$https_label}.entryPoints=https";
 | 
					 | 
				
			||||||
                    $labels[] = "traefik.http.routers.{$https_label}.middlewares=gzip";
 | 
					 | 
				
			||||||
                    if ($path !== '/') {
 | 
					 | 
				
			||||||
                        $labels[] = "traefik.http.routers.{$https_label}.middlewares={$https_label}-stripprefix";
 | 
					 | 
				
			||||||
                        $labels[] = "traefik.http.middlewares.{$https_label}-stripprefix.stripprefix.prefixes={$path}";
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                    $labels[] = "traefik.http.routers.{$https_label}.tls=true";
 | 
					 | 
				
			||||||
                    $labels[] = "traefik.http.routers.{$https_label}.tls.certresolver=letsencrypt";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                    // Set labels for http (redirect to https)
 | 
					 | 
				
			||||||
                    $labels[] = "traefik.http.routers.{$http_label}.rule=Host(`{$host}`) && PathPrefix(`{$path}`)";
 | 
					 | 
				
			||||||
                    $labels[] = "traefik.http.routers.{$http_label}.entryPoints=http";
 | 
					 | 
				
			||||||
                    if ($this->application->settings->is_force_https_enabled) {
 | 
					 | 
				
			||||||
                        $labels[] = "traefik.http.routers.{$http_label}.middlewares=redirect-to-https";
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                } else {
 | 
					 | 
				
			||||||
                    // Set labels for http
 | 
					 | 
				
			||||||
                    $labels[] = "traefik.http.routers.{$http_label}.rule=Host(`{$host}`) && PathPrefix(`{$path}`)";
 | 
					 | 
				
			||||||
                    $labels[] = "traefik.http.routers.{$http_label}.entryPoints=http";
 | 
					 | 
				
			||||||
                    $labels[] = "traefik.http.routers.{$http_label}.middlewares=gzip";
 | 
					 | 
				
			||||||
                    if ($path !== '/') {
 | 
					 | 
				
			||||||
                        $labels[] = "traefik.http.routers.{$http_label}.middlewares={$http_label}-stripprefix";
 | 
					 | 
				
			||||||
                        $labels[] = "traefik.http.middlewares.{$http_label}-stripprefix.stripprefix.prefixes={$path}";
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        return $labels;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    private function execute_now(
 | 
					 | 
				
			||||||
        array|Collection $command,
 | 
					 | 
				
			||||||
        string $propertyName = null,
 | 
					 | 
				
			||||||
        bool $isFinished = false,
 | 
					 | 
				
			||||||
        bool $hideFromOutput = false,
 | 
					 | 
				
			||||||
        bool $isDebuggable = false,
 | 
					 | 
				
			||||||
        bool $ignoreErrors = false
 | 
					 | 
				
			||||||
    ) {
 | 
					 | 
				
			||||||
        static::$batch_counter++;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if ($command instanceof Collection) {
 | 
					 | 
				
			||||||
            $commandText = $command->implode("\n");
 | 
					 | 
				
			||||||
        } else {
 | 
					 | 
				
			||||||
            $commandText = collect($command)->implode("\n");
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        ray('Executing command: ' . $commandText)->green();
 | 
					 | 
				
			||||||
        $this->activity->properties = $this->activity->properties->merge([
 | 
					 | 
				
			||||||
            'command' => $commandText,
 | 
					 | 
				
			||||||
        ]);
 | 
					 | 
				
			||||||
        $this->activity->save();
 | 
					 | 
				
			||||||
        if ($isDebuggable && !$this->application->settings->is_debug_enabled) {
 | 
					 | 
				
			||||||
            ray('Debugging is disabled for this application. Skipping command.')->green();
 | 
					 | 
				
			||||||
            $hideFromOutput = true;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        $remote_process = resolve(RunRemoteProcess::class, [
 | 
					 | 
				
			||||||
            'activity' => $this->activity,
 | 
					 | 
				
			||||||
            'hide_from_output' => $hideFromOutput,
 | 
					 | 
				
			||||||
            'is_finished' => $isFinished,
 | 
					 | 
				
			||||||
            'ingore_errors' => $ignoreErrors,
 | 
					 | 
				
			||||||
        ]);
 | 
					 | 
				
			||||||
        $result = $remote_process();
 | 
					 | 
				
			||||||
        if ($propertyName) {
 | 
					 | 
				
			||||||
            $this->activity->properties = $this->activity->properties->merge([
 | 
					 | 
				
			||||||
                $propertyName => trim($result->output()),
 | 
					 | 
				
			||||||
            ]);
 | 
					 | 
				
			||||||
            $this->activity->save();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if ($result->exitCode() != 0 && $result->errorOutput() && !$ignoreErrors) {
 | 
					 | 
				
			||||||
            throw new \RuntimeException($result->errorOutput());
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    private function set_git_import_settings($git_clone_command)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        if ($this->application->git_commit_sha !== 'HEAD') {
 | 
					 | 
				
			||||||
            $git_clone_command = "{$git_clone_command} && cd {$this->workdir} && git -c advice.detachedHead=false checkout {$this->application->git_commit_sha} >/dev/null 2>&1";
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        if ($this->application->settings->is_git_submodules_enabled) {
 | 
					 | 
				
			||||||
            $git_clone_command = "{$git_clone_command} && cd {$this->workdir} && git submodule update --init --recursive";
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        if ($this->application->settings->is_git_lfs_enabled) {
 | 
					 | 
				
			||||||
            $git_clone_command = "{$git_clone_command} && cd {$this->workdir} && git lfs pull";
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        return $git_clone_command;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    private function importing_git_repository()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $git_clone_command = "git clone -q -b {$this->application->git_branch}";
 | 
					 | 
				
			||||||
        if ($this->pull_request_id !== 0) {
 | 
					 | 
				
			||||||
            $pr_branch_name = "pr-{$this->pull_request_id}-coolify";
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if ($this->application->deploymentType() === 'source') {
 | 
					 | 
				
			||||||
            $source_html_url = data_get($this->application, 'source.html_url');
 | 
					 | 
				
			||||||
            $url = parse_url(filter_var($source_html_url, FILTER_SANITIZE_URL));
 | 
					 | 
				
			||||||
            $source_html_url_host = $url['host'];
 | 
					 | 
				
			||||||
            $source_html_url_scheme = $url['scheme'];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if ($this->source->getMorphClass() == 'App\Models\GithubApp') {
 | 
					 | 
				
			||||||
                if ($this->source->is_public) {
 | 
					 | 
				
			||||||
                    $git_clone_command = "{$git_clone_command} {$this->source->html_url}/{$this->application->git_repository} {$this->workdir}";
 | 
					 | 
				
			||||||
                    $git_clone_command = $this->set_git_import_settings($git_clone_command);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                    $commands = [$this->execute_in_builder($git_clone_command)];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                    if ($this->pull_request_id !== 0) {
 | 
					 | 
				
			||||||
                        $commands[] = $this->execute_in_builder("cd {$this->workdir} && git fetch origin pull/{$this->pull_request_id}/head:$pr_branch_name >/dev/null 2>&1 && git checkout $pr_branch_name >/dev/null 2>&1");
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                    return $commands;
 | 
					 | 
				
			||||||
                } else {
 | 
					 | 
				
			||||||
                    $github_access_token = generate_github_installation_token($this->source);
 | 
					 | 
				
			||||||
                    $commands = [
 | 
					 | 
				
			||||||
                        $this->execute_in_builder("git clone -q -b {$this->application->git_branch} $source_html_url_scheme://x-access-token:$github_access_token@$source_html_url_host/{$this->application->git_repository}.git {$this->workdir}")
 | 
					 | 
				
			||||||
                    ];
 | 
					 | 
				
			||||||
                    if ($this->pull_request_id !== 0) {
 | 
					 | 
				
			||||||
                        $commands[] = $this->execute_in_builder("cd {$this->workdir} && git fetch origin pull/{$this->pull_request_id}/head:$pr_branch_name && git checkout $pr_branch_name");
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                    return $commands;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        if ($this->application->deploymentType() === 'deploy_key') {
 | 
					 | 
				
			||||||
            $private_key = base64_encode($this->application->private_key->private_key);
 | 
					 | 
				
			||||||
            $git_clone_command = "GIT_SSH_COMMAND=\"ssh -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /root/.ssh/id_rsa\" {$git_clone_command} {$this->application->git_full_url} {$this->workdir}";
 | 
					 | 
				
			||||||
            $git_clone_command = $this->set_git_import_settings($git_clone_command);
 | 
					 | 
				
			||||||
            return [
 | 
					 | 
				
			||||||
                $this->execute_in_builder("mkdir -p /root/.ssh"),
 | 
					 | 
				
			||||||
                $this->execute_in_builder("echo '{$private_key}' | base64 -d > /root/.ssh/id_rsa"),
 | 
					 | 
				
			||||||
                $this->execute_in_builder("chmod 600 /root/.ssh/id_rsa"),
 | 
					 | 
				
			||||||
                $this->execute_in_builder($git_clone_command)
 | 
					 | 
				
			||||||
            ];
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    private function nixpacks_build_cmd()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $this->generate_env_variables();
 | 
					 | 
				
			||||||
        $nixpacks_command = "nixpacks build -o {$this->workdir} {$this->env_args} --no-error-without-start";
 | 
					 | 
				
			||||||
        if ($this->application->build_command) {
 | 
					 | 
				
			||||||
            $nixpacks_command .= " --build-cmd \"{$this->application->build_command}\"";
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        if ($this->application->start_command) {
 | 
					 | 
				
			||||||
            $nixpacks_command .= " --start-cmd \"{$this->application->start_command}\"";
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        if ($this->application->install_command) {
 | 
					 | 
				
			||||||
            $nixpacks_command .= " --install-cmd \"{$this->application->install_command}\"";
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        $nixpacks_command .= " {$this->workdir}";
 | 
					 | 
				
			||||||
        return $this->execute_in_builder($nixpacks_command);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    private function stop_running_container()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $this->execute_now([
 | 
					 | 
				
			||||||
            "echo -n 'Removing old instance... '",
 | 
					 | 
				
			||||||
            $this->execute_in_builder("docker rm -f $this->container_name >/dev/null 2>&1"),
 | 
					 | 
				
			||||||
            "echo 'Done.'",
 | 
					 | 
				
			||||||
        ]);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    private function start_by_compose_file()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $this->execute_now([
 | 
					 | 
				
			||||||
            "echo -n 'Starting your application... '",
 | 
					 | 
				
			||||||
        ]);
 | 
					 | 
				
			||||||
        $this->execute_now([
 | 
					 | 
				
			||||||
            $this->execute_in_builder("docker compose --project-directory {$this->workdir} up -d >/dev/null"),
 | 
					 | 
				
			||||||
        ], isDebuggable: true);
 | 
					 | 
				
			||||||
        $this->execute_now([
 | 
					 | 
				
			||||||
            "echo 'Done. 🎉'",
 | 
					 | 
				
			||||||
        ], isFinished: true);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    private function generate_compose_file()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $this->docker_compose = $this->generate_docker_compose();
 | 
					 | 
				
			||||||
        $docker_compose_base64 = base64_encode($this->docker_compose);
 | 
					 | 
				
			||||||
        $this->execute_now([
 | 
					 | 
				
			||||||
            $this->execute_in_builder("echo '{$docker_compose_base64}' | base64 -d > {$this->workdir}/docker-compose.yml")
 | 
					 | 
				
			||||||
        ], hideFromOutput: true);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
							
								
								
									
										51
									
								
								app/Jobs/DockerCleanupJob.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										51
									
								
								app/Jobs/DockerCleanupJob.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,51 @@
 | 
				
			|||||||
 | 
					<?php
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace App\Jobs;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					use App\Models\Server;
 | 
				
			||||||
 | 
					use Illuminate\Bus\Queueable;
 | 
				
			||||||
 | 
					use Illuminate\Contracts\Queue\ShouldQueue;
 | 
				
			||||||
 | 
					use Illuminate\Foundation\Bus\Dispatchable;
 | 
				
			||||||
 | 
					use Illuminate\Queue\InteractsWithQueue;
 | 
				
			||||||
 | 
					use Illuminate\Queue\SerializesModels;
 | 
				
			||||||
 | 
					use Illuminate\Support\Facades\Log;
 | 
				
			||||||
 | 
					use Illuminate\Support\Str;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class DockerCleanupJob implements ShouldQueue
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
 | 
				
			||||||
 | 
					    public $timeout = 500;
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Create a new job instance.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public function __construct()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        //
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Execute the job.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public function handle(): void
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            $servers = Server::all();
 | 
				
			||||||
 | 
					            foreach ($servers as $server) {
 | 
				
			||||||
 | 
					                if (isDev()) {
 | 
				
			||||||
 | 
					                    $docker_root_filesystem = "/";
 | 
				
			||||||
 | 
					                } else {
 | 
				
			||||||
 | 
					                    $docker_root_filesystem = instant_remote_process(['stat --printf=%m $(docker info --format "{{json .DockerRootDir}}" |sed \'s/"//g\')'], $server);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                $disk_usage = json_decode(instant_remote_process(['df -hP | awk \'BEGIN {printf"{\"disks\":["}{if($1=="Filesystem")next;if(a)printf",";printf"{\"mount\":\""$6"\",\"size\":\""$2"\",\"used\":\""$3"\",\"avail\":\""$4"\",\"use%\":\""$5"\"}";a++;}END{print"]}";}\''], $server), true);
 | 
				
			||||||
 | 
					                $mount_point = collect(data_get($disk_usage, 'disks'))->where('mount', $docker_root_filesystem)->first();
 | 
				
			||||||
 | 
					                if (Str::of(data_get($mount_point, 'use%'))->trim()->replace('%', '')->value() >= $server->settings->cleanup_after_percentage) {
 | 
				
			||||||
 | 
					                    instant_remote_process(['docker image prune -af'], $server);
 | 
				
			||||||
 | 
					                    instant_remote_process(['docker container prune -f --filter "label=coolify.managed=true"'], $server);
 | 
				
			||||||
 | 
					                    instant_remote_process(['docker builder prune -af'], $server);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        } catch (\Exception $e) {
 | 
				
			||||||
 | 
					            Log::error($e->getMessage());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -1,39 +0,0 @@
 | 
				
			|||||||
<?php
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
namespace App\Jobs;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
use App\Models\Server;
 | 
					 | 
				
			||||||
use Illuminate\Bus\Queueable;
 | 
					 | 
				
			||||||
use Illuminate\Contracts\Queue\ShouldQueue;
 | 
					 | 
				
			||||||
use Illuminate\Foundation\Bus\Dispatchable;
 | 
					 | 
				
			||||||
use Illuminate\Queue\InteractsWithQueue;
 | 
					 | 
				
			||||||
use Illuminate\Queue\SerializesModels;
 | 
					 | 
				
			||||||
use Illuminate\Support\Facades\Log;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
class InstanceDockerCleanupJob implements ShouldQueue
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
 | 
					 | 
				
			||||||
    public $timeout = 500;
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * Create a new job instance.
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    public function __construct()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        //
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * Execute the job.
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    public function handle(): void
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        try {
 | 
					 | 
				
			||||||
            $servers = Server::all();
 | 
					 | 
				
			||||||
            foreach ($servers as $server) {
 | 
					 | 
				
			||||||
                instant_remote_process(['docker image prune -f'], $server);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        } catch (\Exception $e) {
 | 
					 | 
				
			||||||
            Log::error($e->getMessage());
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@@ -11,7 +11,7 @@ use Illuminate\Foundation\Bus\Dispatchable;
 | 
				
			|||||||
use Illuminate\Queue\InteractsWithQueue;
 | 
					use Illuminate\Queue\InteractsWithQueue;
 | 
				
			||||||
use Illuminate\Queue\SerializesModels;
 | 
					use Illuminate\Queue\SerializesModels;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class InstanceProxyCheckJob implements ShouldQueue
 | 
					class ProxyCheckJob implements ShouldQueue
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
 | 
					    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -195,6 +195,9 @@ class Application extends BaseModel
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
    public function deploymentType()
 | 
					    public function deploymentType()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					        if (data_get($this, 'private_key_id')) {
 | 
				
			||||||
 | 
					            return 'deploy_key';
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        if (data_get($this, 'source')) {
 | 
					        if (data_get($this, 'source')) {
 | 
				
			||||||
            return 'source';
 | 
					            return 'source';
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -56,6 +56,8 @@ function getProxyConfiguration(Server $server)
 | 
				
			|||||||
                    "--api.insecure=true",
 | 
					                    "--api.insecure=true",
 | 
				
			||||||
                    "--entrypoints.http.address=:80",
 | 
					                    "--entrypoints.http.address=:80",
 | 
				
			||||||
                    "--entrypoints.https.address=:443",
 | 
					                    "--entrypoints.https.address=:443",
 | 
				
			||||||
 | 
					                    "--entrypoints.http.http.encodequerysemicolons=true",
 | 
				
			||||||
 | 
					                    "--entrypoints.https.http.encodequerysemicolons=true",
 | 
				
			||||||
                    "--providers.docker=true",
 | 
					                    "--providers.docker=true",
 | 
				
			||||||
                    "--providers.docker.exposedbydefault=false",
 | 
					                    "--providers.docker.exposedbydefault=false",
 | 
				
			||||||
                    "--providers.file.directory=/traefik/dynamic/",
 | 
					                    "--providers.file.directory=/traefik/dynamic/",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,3 +1,3 @@
 | 
				
			|||||||
<?php
 | 
					<?php
 | 
				
			||||||
 | 
					
 | 
				
			||||||
return '4.0.0-beta.16';
 | 
					return '4.0.0-beta.17';
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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('server_settings', function (Blueprint $table) {
 | 
				
			||||||
 | 
					            $table->integer('cleanup_after_percentage')->default(80);
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Reverse the migrations.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public function down(): void
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        Schema::table('server_settings', function (Blueprint $table) {
 | 
				
			||||||
 | 
					            $table->dropColumn('cleanup_after_percentage');
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
@@ -14,6 +14,7 @@ class ServerSettingSeeder extends Seeder
 | 
				
			|||||||
    public function run(): void
 | 
					    public function run(): void
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $server_2 = Server::find(0)->load(['settings']);
 | 
					        $server_2 = Server::find(0)->load(['settings']);
 | 
				
			||||||
 | 
					        $server_2->settings->wildcard_domain = 'http://127.0.0.1.sslip.io';
 | 
				
			||||||
        $server_2->settings->is_build_server = true;
 | 
					        $server_2->settings->is_build_server = true;
 | 
				
			||||||
        $server_2->settings->is_reachable = true;
 | 
					        $server_2->settings->is_reachable = true;
 | 
				
			||||||
        $server_2->settings->save();
 | 
					        $server_2->settings->save();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,32 +3,32 @@
 | 
				
			|||||||
@tailwind utilities;
 | 
					@tailwind utilities;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
.scrollbar {
 | 
					.scrollbar {
 | 
				
			||||||
    @apply scrollbar-thumb-coollabs-100 scrollbar-track-coolgray-200 scrollbar-w-1;
 | 
					    @apply scrollbar-thumb-coollabs-100 scrollbar-track-coolgray-200 scrollbar-w-2;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
html {
 | 
					html {
 | 
				
			||||||
    @apply text-neutral-400;
 | 
					    @apply text-neutral-400;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
body {
 | 
					body {
 | 
				
			||||||
    @apply scrollbar antialiased text-sm;
 | 
					    @apply text-sm antialiased scrollbar;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
.main {
 | 
					.main {
 | 
				
			||||||
    @apply pl-24 pr-10 mx-auto max-w-screen-xl pt-4;
 | 
					    @apply max-w-screen-xl pt-4 pl-24 pr-10 mx-auto;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
input {
 | 
					input {
 | 
				
			||||||
    @apply input input-sm h-7 outline-none placeholder:text-neutral-700 text-white rounded bg-coolgray-200 w-full read-only:bg-coolgray-200/50 read-only:text-opacity-25;
 | 
					    @apply w-full text-white rounded outline-none input input-sm h-7 placeholder:text-neutral-700 bg-coolgray-200 read-only:bg-coolgray-200/50 read-only:text-opacity-25;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
input:not(input[type="checkbox"]) {
 | 
					input:not(input[type="checkbox"]) {
 | 
				
			||||||
    @apply border-none disabled:border-none;
 | 
					    @apply border-none disabled:border-none;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
input[type="checkbox"] {
 | 
					input[type="checkbox"] {
 | 
				
			||||||
    @apply toggle toggle-warning toggle-xs rounded disabled:toggle-warning;
 | 
					    @apply rounded toggle toggle-warning toggle-xs disabled:toggle-warning;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
textarea {
 | 
					textarea {
 | 
				
			||||||
    @apply textarea read-only:bg-coolgray-200/50 disabled:border-none read-only:text-opacity-25 placeholder:text-neutral-700 text-white rounded scrollbar bg-coolgray-200 leading-5 text-xs;
 | 
					    @apply text-xs leading-5 text-white rounded textarea read-only:bg-coolgray-200/50 disabled:border-none read-only:text-opacity-25 placeholder:text-neutral-700 scrollbar bg-coolgray-200;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
select {
 | 
					select {
 | 
				
			||||||
    @apply h-7 select select-xs disabled:bg-coolgray-200 border-none disabled:opacity-50 font-normal placeholder:text-neutral-700 text-white rounded bg-coolgray-200;
 | 
					    @apply font-normal text-white border-none rounded h-7 select select-xs disabled:bg-coolgray-200 disabled:opacity-50 placeholder:text-neutral-700 bg-coolgray-200;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
.label-text,
 | 
					.label-text,
 | 
				
			||||||
label {
 | 
					label {
 | 
				
			||||||
@@ -43,7 +43,7 @@ button[isWarning] {
 | 
				
			|||||||
    @apply bg-red-600 hover:bg-red-500;
 | 
					    @apply bg-red-600 hover:bg-red-500;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
button[isHighlighted] {
 | 
					button[isHighlighted] {
 | 
				
			||||||
    @apply btn-primary text-white;
 | 
					    @apply text-white btn-primary;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
h1 {
 | 
					h1 {
 | 
				
			||||||
    @apply text-3xl font-bold text-white;
 | 
					    @apply text-3xl font-bold text-white;
 | 
				
			||||||
@@ -70,7 +70,7 @@ a {
 | 
				
			|||||||
    @apply text-white;
 | 
					    @apply text-white;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
.box {
 | 
					.box {
 | 
				
			||||||
    @apply flex items-center justify-center rounded min-h-12 bg-coolgray-200 hover:bg-coollabs-100 hover:text-white p-2 hover:no-underline transition-colors;
 | 
					    @apply flex items-center justify-center p-2 transition-colors rounded min-h-12 bg-coolgray-200 hover:bg-coollabs-100 hover:text-white hover:no-underline;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
.lds-heart {
 | 
					.lds-heart {
 | 
				
			||||||
@@ -124,5 +124,5 @@ tr td {
 | 
				
			|||||||
    @apply px-3 py-4 whitespace-nowrap;
 | 
					    @apply px-3 py-4 whitespace-nowrap;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
tr td:first-child {
 | 
					tr td:first-child {
 | 
				
			||||||
    @apply pl-4 pr-3 sm:pl-6 font-bold;
 | 
					    @apply pl-4 pr-3 font-bold sm:pl-6;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,7 +1,7 @@
 | 
				
			|||||||
@auth
 | 
					@auth
 | 
				
			||||||
    <nav class="fixed h-full overflow-hidden pt-14">
 | 
					<nav class="fixed h-full overflow-hidden overflow-y-auto pt-14 scrollbar">
 | 
				
			||||||
        <ul class="gap-4 menu">
 | 
					    <ul class="flex flex-col h-full gap-4 menu flex-nowrap">
 | 
				
			||||||
            <li>
 | 
					        <li title="Dashboard">
 | 
				
			||||||
            <a class="hover:bg-transparent" @if (!request()->is('/')) href="/" @endif>
 | 
					            <a class="hover:bg-transparent" @if (!request()->is('/')) href="/" @endif>
 | 
				
			||||||
                <svg xmlns="http://www.w3.org/2000/svg" class="{{ request()->is('/') ? 'text-warning icon' : 'icon' }}"
 | 
					                <svg xmlns="http://www.w3.org/2000/svg" class="{{ request()->is('/') ? 'text-warning icon' : 'icon' }}"
 | 
				
			||||||
                    fill="none" viewBox="0 0 24 24" stroke="currentColor">
 | 
					                    fill="none" viewBox="0 0 24 24" stroke="currentColor">
 | 
				
			||||||
@@ -10,13 +10,11 @@
 | 
				
			|||||||
                </svg>
 | 
					                </svg>
 | 
				
			||||||
            </a>
 | 
					            </a>
 | 
				
			||||||
        </li>
 | 
					        </li>
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        <li title="Projects">
 | 
					        <li title="Projects">
 | 
				
			||||||
            <a class="hover:bg-transparent" @if (!request()->is('projects')) href="/projects" @endif>
 | 
					            <a class="hover:bg-transparent" @if (!request()->is('projects')) href="/projects" @endif>
 | 
				
			||||||
                <svg xmlns="http://www.w3.org/2000/svg"
 | 
					                <svg xmlns="http://www.w3.org/2000/svg"
 | 
				
			||||||
                        class="{{ request()->is('project/*') || request()->is('projects') ? 'text-warning icon' : 'icon' }}"viewBox="0 0 24 24"
 | 
					                    class="{{ request()->is('project/*') || request()->is('projects') ? 'text-warning icon' : 'icon' }}"
 | 
				
			||||||
                        stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round"
 | 
					                    viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round"
 | 
				
			||||||
                    stroke-linejoin="round">
 | 
					                    stroke-linejoin="round">
 | 
				
			||||||
                    <path stroke="none" d="M0 0h24v24H0z" fill="none" />
 | 
					                    <path stroke="none" d="M0 0h24v24H0z" fill="none" />
 | 
				
			||||||
                    <path d="M12 4l-8 4l8 4l8 -4l-8 -4" />
 | 
					                    <path d="M12 4l-8 4l8 4l8 -4l-8 -4" />
 | 
				
			||||||
@@ -46,65 +44,29 @@
 | 
				
			|||||||
            <a class="hover:bg-transparent" @if (!request()->is('command-center')) href="/command-center" @endif>
 | 
					            <a class="hover:bg-transparent" @if (!request()->is('command-center')) href="/command-center" @endif>
 | 
				
			||||||
                <svg xmlns="http://www.w3.org/2000/svg"
 | 
					                <svg xmlns="http://www.w3.org/2000/svg"
 | 
				
			||||||
                    class="{{ request()->is('command-center') ? 'text-warning icon' : 'icon' }}" viewBox="0 0 24 24"
 | 
					                    class="{{ request()->is('command-center') ? 'text-warning icon' : 'icon' }}" viewBox="0 0 24 24"
 | 
				
			||||||
                            stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round"
 | 
					                    stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
 | 
				
			||||||
                            stroke-linejoin="round">
 | 
					 | 
				
			||||||
                    <path stroke="none" d="M0 0h24v24H0z" fill="none" />
 | 
					                    <path stroke="none" d="M0 0h24v24H0z" fill="none" />
 | 
				
			||||||
                    <path d="M5 7l5 5l-5 5" />
 | 
					                    <path d="M5 7l5 5l-5 5" />
 | 
				
			||||||
                    <path d="M12 19l7 0" />
 | 
					                    <path d="M12 19l7 0" />
 | 
				
			||||||
                </svg>
 | 
					                </svg>
 | 
				
			||||||
            </a>
 | 
					            </a>
 | 
				
			||||||
        </li>
 | 
					        </li>
 | 
				
			||||||
                <li title="Settings">
 | 
					
 | 
				
			||||||
                    <a class="hover:bg-transparent" @if (!request()->is('settings')) href="/settings" @endif>
 | 
					        <li title="Profile">
 | 
				
			||||||
                        <svg xmlns="http://www.w3.org/2000/svg"
 | 
					            <a class="hover:bg-transparent" @if (!request()->is('profile')) href="/profile" @endif>
 | 
				
			||||||
                            class="{{ request()->is('settings*') ? 'text-warning icon' : 'icon' }}" viewBox="0 0 24 24"
 | 
					                <svg xmlns="http://www.w3.org/2000/svg" class="icon" viewBox="0 0 24 24" stroke-width="1.5"
 | 
				
			||||||
                            stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round"
 | 
					 | 
				
			||||||
                            stroke-linejoin="round">
 | 
					 | 
				
			||||||
                            <path stroke="none" d="M0 0h24v24H0z" fill="none" />
 | 
					 | 
				
			||||||
                            <path
 | 
					 | 
				
			||||||
                                d="M10.325 4.317c.426 -1.756 2.924 -1.756 3.35 0a1.724 1.724 0 0 0 2.573 1.066c1.543 -.94 3.31 .826 2.37 2.37a1.724 1.724 0 0 0 1.065 2.572c1.756 .426 1.756 2.924 0 3.35a1.724 1.724 0 0 0 -1.066 2.573c.94 1.543 -.826 3.31 -2.37 2.37a1.724 1.724 0 0 0 -2.572 1.065c-.426 1.756 -2.924 1.756 -3.35 0a1.724 1.724 0 0 0 -2.573 -1.066c-1.543 .94 -3.31 -.826 -2.37 -2.37a1.724 1.724 0 0 0 -1.065 -2.572c-1.756 -.426 -1.756 -2.924 0 -3.35a1.724 1.724 0 0 0 1.066 -2.573c-.94 -1.543 .826 -3.31 2.37 -2.37c1 .608 2.296 .07 2.572 -1.065z" />
 | 
					 | 
				
			||||||
                            <path d="M9 12a3 3 0 1 0 6 0a3 3 0 0 0 -6 0" />
 | 
					 | 
				
			||||||
                        </svg>
 | 
					 | 
				
			||||||
                    </a>
 | 
					 | 
				
			||||||
                </li>
 | 
					 | 
				
			||||||
                <livewire:upgrade />
 | 
					 | 
				
			||||||
            @endif
 | 
					 | 
				
			||||||
        </ul>
 | 
					 | 
				
			||||||
    </nav>
 | 
					 | 
				
			||||||
    <div class="fixed right-0 p-2 top-1">
 | 
					 | 
				
			||||||
        <div class="group">
 | 
					 | 
				
			||||||
            <label tabindex="0"
 | 
					 | 
				
			||||||
                class="absolute top-0 right-0 p-2 m-2 my-1 cursor-pointer hover:bg-transparent hover:text-warning">
 | 
					 | 
				
			||||||
                <div class="flex items-center justify-center gap-2 placeholder">
 | 
					 | 
				
			||||||
                    <svg xmlns="http://www.w3.org/2000/svg" class="w-6 h-6" viewBox="0 0 24 24" stroke-width="1.5"
 | 
					 | 
				
			||||||
                    stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
 | 
					                    stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
 | 
				
			||||||
                    <path stroke="none" d="M0 0h24v24H0z" fill="none" />
 | 
					                    <path stroke="none" d="M0 0h24v24H0z" fill="none" />
 | 
				
			||||||
                        <path d="M4 6l16 0" />
 | 
					 | 
				
			||||||
                        <path d="M4 12l16 0" />
 | 
					 | 
				
			||||||
                        <path d="M4 18l16 0" />
 | 
					 | 
				
			||||||
                    </svg>
 | 
					 | 
				
			||||||
                </div>
 | 
					 | 
				
			||||||
            </label>
 | 
					 | 
				
			||||||
            <div class="hidden p-4 px-8 group-hover:block">
 | 
					 | 
				
			||||||
                <ul tabindex="0" class="p-2 mt-3 rounded shadow menu menu-compact dropdown-content bg-coolgray-200 w-52">
 | 
					 | 
				
			||||||
                    <li>
 | 
					 | 
				
			||||||
                        <a class="text-white rounded-none hover:no-underline hover:bg-coollabs" href="/profile">
 | 
					 | 
				
			||||||
                            <svg xmlns="http://www.w3.org/2000/svg" class="icon" viewBox="0 0 24 24"
 | 
					 | 
				
			||||||
                                stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round"
 | 
					 | 
				
			||||||
                                stroke-linejoin="round">
 | 
					 | 
				
			||||||
                                <path stroke="none" d="M0 0h24v24H0z" fill="none" />
 | 
					 | 
				
			||||||
                    <path d="M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0" />
 | 
					                    <path d="M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0" />
 | 
				
			||||||
                    <path d="M12 10m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0" />
 | 
					                    <path d="M12 10m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0" />
 | 
				
			||||||
                    <path d="M6.168 18.849a4 4 0 0 1 3.832 -2.849h4a4 4 0 0 1 3.834 2.855" />
 | 
					                    <path d="M6.168 18.849a4 4 0 0 1 3.832 -2.849h4a4 4 0 0 1 3.834 2.855" />
 | 
				
			||||||
                            </svg> Profile
 | 
					                </svg>
 | 
				
			||||||
            </a>
 | 
					            </a>
 | 
				
			||||||
        </li>
 | 
					        </li>
 | 
				
			||||||
                    <li>
 | 
					        <li title="Teams">
 | 
				
			||||||
                        <a class="text-white rounded-none hover:no-underline hover:bg-coollabs"
 | 
					            <a class="hover:bg-transparent" href="{{ route('team.show') }}">
 | 
				
			||||||
                            href="{{ route('team.show') }}">
 | 
					                <svg xmlns="http://www.w3.org/2000/svg" class="icon" viewBox="0 0 24 24" stroke-width="1.5"
 | 
				
			||||||
                            <svg xmlns="http://www.w3.org/2000/svg" class="icon" viewBox="0 0 24 24"
 | 
					                    stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
 | 
				
			||||||
                                stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round"
 | 
					 | 
				
			||||||
                                stroke-linejoin="round">
 | 
					 | 
				
			||||||
                    <path stroke="none" d="M0 0h24v24H0z" fill="none" />
 | 
					                    <path stroke="none" d="M0 0h24v24H0z" fill="none" />
 | 
				
			||||||
                    <path d="M10 13a2 2 0 1 0 4 0a2 2 0 0 0 -4 0" />
 | 
					                    <path d="M10 13a2 2 0 1 0 4 0a2 2 0 0 0 -4 0" />
 | 
				
			||||||
                    <path d="M8 21v-1a2 2 0 0 1 2 -2h4a2 2 0 0 1 2 2v1" />
 | 
					                    <path d="M8 21v-1a2 2 0 0 1 2 -2h4a2 2 0 0 1 2 2v1" />
 | 
				
			||||||
@@ -112,26 +74,37 @@
 | 
				
			|||||||
                    <path d="M17 10h2a2 2 0 0 1 2 2v1" />
 | 
					                    <path d="M17 10h2a2 2 0 0 1 2 2v1" />
 | 
				
			||||||
                    <path d="M5 5a2 2 0 1 0 4 0a2 2 0 0 0 -4 0" />
 | 
					                    <path d="M5 5a2 2 0 1 0 4 0a2 2 0 0 0 -4 0" />
 | 
				
			||||||
                    <path d="M3 13v-1a2 2 0 0 1 2 -2h2" />
 | 
					                    <path d="M3 13v-1a2 2 0 0 1 2 -2h2" />
 | 
				
			||||||
                            </svg> Team
 | 
					                </svg>
 | 
				
			||||||
            </a>
 | 
					            </a>
 | 
				
			||||||
        </li>
 | 
					        </li>
 | 
				
			||||||
                    <form action="/logout" method="POST">
 | 
					        <livewire:upgrade />
 | 
				
			||||||
                        <li>
 | 
					        <li title="Settings" class="mt-auto">
 | 
				
			||||||
 | 
					            <a class="hover:bg-transparent" @if (!request()->is('settings')) href="/settings" @endif>
 | 
				
			||||||
 | 
					                <svg xmlns="http://www.w3.org/2000/svg"
 | 
				
			||||||
 | 
					                    class="{{ request()->is('settings*') ? 'text-warning icon' : 'icon' }}" viewBox="0 0 24 24"
 | 
				
			||||||
 | 
					                    stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
 | 
				
			||||||
 | 
					                    <path stroke="none" d="M0 0h24v24H0z" fill="none" />
 | 
				
			||||||
 | 
					                    <path
 | 
				
			||||||
 | 
					                        d="M10.325 4.317c.426 -1.756 2.924 -1.756 3.35 0a1.724 1.724 0 0 0 2.573 1.066c1.543 -.94 3.31 .826 2.37 2.37a1.724 1.724 0 0 0 1.065 2.572c1.756 .426 1.756 2.924 0 3.35a1.724 1.724 0 0 0 -1.066 2.573c.94 1.543 -.826 3.31 -2.37 2.37a1.724 1.724 0 0 0 -2.572 1.065c-.426 1.756 -2.924 1.756 -3.35 0a1.724 1.724 0 0 0 -2.573 -1.066c-1.543 .94 -3.31 -.826 -2.37 -2.37a1.724 1.724 0 0 0 -1.065 -2.572c-1.756 -.426 -1.756 -2.924 0 -3.35a1.724 1.724 0 0 0 1.066 -2.573c-.94 -1.543 .826 -3.31 2.37 -2.37c1 .608 2.296 .07 2.572 -1.065z" />
 | 
				
			||||||
 | 
					                    <path d="M9 12a3 3 0 1 0 6 0a3 3 0 0 0 -6 0" />
 | 
				
			||||||
 | 
					                </svg>
 | 
				
			||||||
 | 
					            </a>
 | 
				
			||||||
 | 
					        </li>
 | 
				
			||||||
 | 
					        <li class="pb-6" title="Logout">
 | 
				
			||||||
 | 
					            <form action="/logout" method="POST" class=" hover:bg-transparent">
 | 
				
			||||||
                @csrf
 | 
					                @csrf
 | 
				
			||||||
                            <button class="text-white rounded-none  hover:bg-coollabs"> <svg
 | 
					                <button class="rounded-none hover:text-white hover:bg-transparent"> <svg
 | 
				
			||||||
                                    xmlns="http://www.w3.org/2000/svg" class="icon" viewBox="0 0 24 24"
 | 
					                        xmlns="http://www.w3.org/2000/svg" class="icon" viewBox="0 0 24 24" stroke-width="1.5"
 | 
				
			||||||
                                    stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round"
 | 
					                        stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
 | 
				
			||||||
                                    stroke-linejoin="round">
 | 
					 | 
				
			||||||
                        <path stroke="none" d="M0 0h24v24H0z" fill="none" />
 | 
					                        <path stroke="none" d="M0 0h24v24H0z" fill="none" />
 | 
				
			||||||
                        <path d="M13 12v.01" />
 | 
					                        <path d="M13 12v.01" />
 | 
				
			||||||
                        <path d="M3 21h18" />
 | 
					                        <path d="M3 21h18" />
 | 
				
			||||||
                        <path d="M5 21v-16a2 2 0 0 1 2 -2h7.5m2.5 10.5v7.5" />
 | 
					                        <path d="M5 21v-16a2 2 0 0 1 2 -2h7.5m2.5 10.5v7.5" />
 | 
				
			||||||
                        <path d="M14 7h7m-3 -3l3 3l-3 3" />
 | 
					                        <path d="M14 7h7m-3 -3l3 3l-3 3" />
 | 
				
			||||||
                                </svg>Logout</button>
 | 
					                    </svg></button>
 | 
				
			||||||
                        </li>
 | 
					 | 
				
			||||||
            </form>
 | 
					            </form>
 | 
				
			||||||
 | 
					        </li>
 | 
				
			||||||
 | 
					        @endif
 | 
				
			||||||
    </ul>
 | 
					    </ul>
 | 
				
			||||||
            </div>
 | 
					</nav>
 | 
				
			||||||
        </div>
 | 
					 | 
				
			||||||
    </div>
 | 
					 | 
				
			||||||
@endauth
 | 
					@endauth
 | 
				
			||||||
@@ -44,7 +44,7 @@
 | 
				
			|||||||
            </div>
 | 
					            </div>
 | 
				
			||||||
            <div class="flex flex-col gap-2 xl:flex-row">
 | 
					            <div class="flex flex-col gap-2 xl:flex-row">
 | 
				
			||||||
                <x-forms.input placeholder="/" id="application.base_directory" label="Base Directory"
 | 
					                <x-forms.input placeholder="/" id="application.base_directory" label="Base Directory"
 | 
				
			||||||
                    helper="Directory to use as root. Useful for monorepos." />
 | 
					                    helper="Directory to use as root. Useful for monorepos. WIP" disabled />
 | 
				
			||||||
                @if ($application->settings->is_static)
 | 
					                @if ($application->settings->is_static)
 | 
				
			||||||
                    <x-forms.input placeholder="/dist" id="application.publish_directory" label="Publish Directory"
 | 
					                    <x-forms.input placeholder="/dist" id="application.publish_directory" label="Publish Directory"
 | 
				
			||||||
                        required />
 | 
					                        required />
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -33,6 +33,10 @@
 | 
				
			|||||||
                </div>
 | 
					                </div>
 | 
				
			||||||
            </div>
 | 
					            </div>
 | 
				
			||||||
        </div>
 | 
					        </div>
 | 
				
			||||||
 | 
					        <h3 class="py-4">Settings</h3>
 | 
				
			||||||
 | 
					        <div class="flex items-center w-64 gap-2">
 | 
				
			||||||
 | 
					            <x-forms.input id="cleanup_after_percentage" label="Disk Cleanup threshold (%)" required helper="Disk cleanup job will be executed if disk usage is more than this number."/>
 | 
				
			||||||
 | 
					        </div>
 | 
				
			||||||
        <h3 class="py-4">Actions</h3>
 | 
					        <h3 class="py-4">Actions</h3>
 | 
				
			||||||
        @if ($server->settings->is_reachable)
 | 
					        @if ($server->settings->is_reachable)
 | 
				
			||||||
            <div class="flex items-center gap-2">
 | 
					            <div class="flex items-center gap-2">
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -32,6 +32,11 @@
 | 
				
			|||||||
        </div>
 | 
					        </div>
 | 
				
			||||||
        <div class="pt-2 pb-10 ">Your Private GitHub App for private repositories.</div>
 | 
					        <div class="pt-2 pb-10 ">Your Private GitHub App for private repositories.</div>
 | 
				
			||||||
        @if ($github_app->app_id)
 | 
					        @if ($github_app->app_id)
 | 
				
			||||||
 | 
					            <div class="w-48">
 | 
				
			||||||
 | 
					                <x-forms.checkbox noDirty label="System Wide?"
 | 
				
			||||||
 | 
					                    helper="If checked, this GitHub App will be available for everyone in this Coolify instance."
 | 
				
			||||||
 | 
					                    instantSave id="is_system_wide" />
 | 
				
			||||||
 | 
					            </div>
 | 
				
			||||||
            <div class="flex gap-2">
 | 
					            <div class="flex gap-2">
 | 
				
			||||||
                <x-forms.input id="github_app.name" label="App Name" disabled />
 | 
					                <x-forms.input id="github_app.name" label="App Name" disabled />
 | 
				
			||||||
                <x-forms.input id="github_app.organization" label="Organization" disabled
 | 
					                <x-forms.input id="github_app.organization" label="Organization" disabled
 | 
				
			||||||
@@ -59,9 +64,6 @@
 | 
				
			|||||||
                <x-forms.input id="github_app.client_secret" label="Client Secret" type="password" />
 | 
					                <x-forms.input id="github_app.client_secret" label="Client Secret" type="password" />
 | 
				
			||||||
                <x-forms.input id="github_app.webhook_secret" label="Webhook Secret" type="password" />
 | 
					                <x-forms.input id="github_app.webhook_secret" label="Webhook Secret" type="password" />
 | 
				
			||||||
            </div>
 | 
					            </div>
 | 
				
			||||||
            <x-forms.checkbox noDirty label="System Wide?"
 | 
					 | 
				
			||||||
                helper="If checked, this GitHub App will be available for everyone in this Coolify instance."
 | 
					 | 
				
			||||||
                instantSave id="is_system_wide" />
 | 
					 | 
				
			||||||
        @else
 | 
					        @else
 | 
				
			||||||
            <form class="flex gap-4">
 | 
					            <form class="flex gap-4">
 | 
				
			||||||
                <div class="flex items-end gap-2">
 | 
					                <div class="flex items-end gap-2">
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,6 @@
 | 
				
			|||||||
<li title="New version available" x-init="$wire.checkUpdate" x-data>
 | 
					<li @if($isUpgradeAvailable) title="New version available" @else title="No upgrade available" @endif x-init="$wire.checkUpdate" x-data>
 | 
				
			||||||
    @if ($isUpgradeAvailable)
 | 
					    @if ($isUpgradeAvailable)
 | 
				
			||||||
        <button wire:click='upgrade' class="hover:bg-transparent focus:bg-transparent" x-on:click="upgrade">
 | 
					        <button wire:key="upgrade" wire:click='upgrade' class="hover:bg-transparent focus:bg-transparent" x-on:click="upgrade">
 | 
				
			||||||
            @if ($showProgress)
 | 
					            @if ($showProgress)
 | 
				
			||||||
                <svg xmlns="http://www.w3.org/2000/svg"
 | 
					                <svg xmlns="http://www.w3.org/2000/svg"
 | 
				
			||||||
                    class="w-6 h-6 text-pink-500 transition-colors hover:text-pink-300 lds-heart" viewBox="0 0 24 24"
 | 
					                    class="w-6 h-6 text-pink-500 transition-colors hover:text-pink-300 lds-heart" viewBox="0 0 24 24"
 | 
				
			||||||
@@ -22,6 +22,18 @@
 | 
				
			|||||||
                </svg>
 | 
					                </svg>
 | 
				
			||||||
            @endif
 | 
					            @endif
 | 
				
			||||||
        </button>
 | 
					        </button>
 | 
				
			||||||
        </div>
 | 
					    @else
 | 
				
			||||||
 | 
					      <button class="hover:bg-transparent">
 | 
				
			||||||
 | 
					                <svg xmlns="http://www.w3.org/2000/svg"
 | 
				
			||||||
 | 
					                    class="w-6 h-6 transition-colors text-neutral-700" viewBox="0 0 24 24"
 | 
				
			||||||
 | 
					                    stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round"
 | 
				
			||||||
 | 
					                    stroke-linejoin="round">
 | 
				
			||||||
 | 
					                    <path stroke="none" d="M0 0h24v24H0z" fill="none" />
 | 
				
			||||||
 | 
					                    <path
 | 
				
			||||||
 | 
					                        d="M9 12h-3.586a1 1 0 0 1 -.707 -1.707l6.586 -6.586a1 1 0 0 1 1.414 0l6.586 6.586a1 1 0 0 1 -.707 1.707h-3.586v3h-6v-3z" />
 | 
				
			||||||
 | 
					                    <path d="M9 21h6" />
 | 
				
			||||||
 | 
					                    <path d="M9 18h6" />
 | 
				
			||||||
 | 
					                </svg>
 | 
				
			||||||
 | 
					        </button>
 | 
				
			||||||
    @endif
 | 
					    @endif
 | 
				
			||||||
</li>
 | 
					</li>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -116,7 +116,7 @@ Route::middleware(['auth'])->group(function () {
 | 
				
			|||||||
        ]);
 | 
					        ]);
 | 
				
			||||||
    })->name('source.all');
 | 
					    })->name('source.all');
 | 
				
			||||||
    Route::get('/source/github/{github_app_uuid}', function (Request $request) {
 | 
					    Route::get('/source/github/{github_app_uuid}', function (Request $request) {
 | 
				
			||||||
        $github_app = GithubApp::where('uuid', request()->github_app_uuid)->first();
 | 
					        $github_app = GithubApp::where('uuid', request()->github_app_uuid)->first()->makeVisible('client_secret')->makeVisible('webhook_secret');
 | 
				
			||||||
        $settings = InstanceSettings::get();
 | 
					        $settings = InstanceSettings::get();
 | 
				
			||||||
        $name = Str::of(Str::kebab($github_app->name));
 | 
					        $name = Str::of(Str::kebab($github_app->name));
 | 
				
			||||||
        if ($settings->public_ipv4) {
 | 
					        if ($settings->public_ipv4) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -20,6 +20,13 @@ function help {
 | 
				
			|||||||
    compgen -A function | cat -n
 | 
					    compgen -A function | cat -n
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function sync:v3 {
 | 
				
			||||||
 | 
					    if [ -z "$1" ]; then
 | 
				
			||||||
 | 
					        echo -e "Please provide a version.\n\nExample: run sync:v3 3.12.32"
 | 
				
			||||||
 | 
					        exit 1
 | 
				
			||||||
 | 
					    fi
 | 
				
			||||||
 | 
					    skopeo copy --all docker://ghcr.io/coollabsio/coolify:$1 docker://coollabsio/coolify:$1
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
function sync:bunny {
 | 
					function sync:bunny {
 | 
				
			||||||
    php artisan sync:bunny --env=secrets
 | 
					    php artisan sync:bunny --env=secrets
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,7 +4,7 @@
 | 
				
			|||||||
            "version": "3.12.32"
 | 
					            "version": "3.12.32"
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        "v4": {
 | 
					        "v4": {
 | 
				
			||||||
            "version": "4.0.0-beta.16"
 | 
					            "version": "4.0.0-beta.17"
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user