diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 3b320366f..1d20b7606 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -3,8 +3,8 @@ namespace App\Console; use App\Jobs\InstanceAutoUpdateJob; -use App\Jobs\InstanceProxyCheckJob; -use App\Jobs\InstanceDockerCleanupJob; +use App\Jobs\ProxyCheckJob; +use App\Jobs\DockerCleanupJob; use Illuminate\Console\Scheduling\Schedule; use Illuminate\Foundation\Console\Kernel as ConsoleKernel; @@ -14,12 +14,12 @@ class Kernel extends ConsoleKernel { if (isDev()) { $schedule->command('horizon:snapshot')->everyMinute(); - // $schedule->job(new InstanceDockerCleanupJob)->everyMinute(); + // $schedule->job(new DockerCleanupJob)->everyOddHour(); // $schedule->job(new InstanceAutoUpdateJob(true))->everyMinute(); } else { $schedule->command('horizon:snapshot')->everyFiveMinutes(); - $schedule->job(new InstanceDockerCleanupJob)->everyFiveMinutes(); - $schedule->job(new InstanceProxyCheckJob)->everyFiveMinutes(); + $schedule->job(new DockerCleanupJob)->everyTenMinutes(); + $schedule->job(new ProxyCheckJob)->everyFiveMinutes(); $schedule->job(new InstanceAutoUpdateJob)->everyTenMinutes(); } } @@ -29,4 +29,4 @@ class Kernel extends ConsoleKernel require base_path('routes/console.php'); } -} +} \ No newline at end of file diff --git a/app/Http/Livewire/Project/Application/DeploymentNavbar.php b/app/Http/Livewire/Project/Application/DeploymentNavbar.php index 5daa2f84f..412f15956 100644 --- a/app/Http/Livewire/Project/Application/DeploymentNavbar.php +++ b/app/Http/Livewire/Project/Application/DeploymentNavbar.php @@ -5,6 +5,7 @@ namespace App\Http\Livewire\Project\Application; use App\Enums\ApplicationDeploymentStatus; use App\Models\Application; use App\Models\ApplicationDeploymentQueue; +use App\Models\Server; use Illuminate\Support\Carbon; use Illuminate\Support\Facades\Process; use Livewire\Component; @@ -15,29 +16,34 @@ class DeploymentNavbar extends Component protected $listeners = ['deploymentFinished']; public ApplicationDeploymentQueue $application_deployment_queue; + public Application $application; + public Server $server; 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() { $this->application_deployment_queue->refresh(); } public function show_debug() { - $application = Application::find($this->application_deployment_queue->application_id); - $application->settings->is_debug_enabled = !$application->settings->is_debug_enabled; - $application->settings->save(); - $this->is_debug_enabled = $application->settings->is_debug_enabled; + $this->application->settings->is_debug_enabled = !$this->application->settings->is_debug_enabled; + $this->application->settings->save(); + $this->is_debug_enabled = $this->application->settings->is_debug_enabled; $this->emit('refreshQueue'); } public function cancel() { try { $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) { $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); } $previous_logs = json_decode($this->application_deployment_queue->logs, associative: true, flags: JSON_THROW_ON_ERROR); @@ -60,4 +66,4 @@ class DeploymentNavbar extends Component return general_error_handler(err: $e, that: $this); } } -} +} \ No newline at end of file diff --git a/app/Http/Livewire/Project/Application/General.php b/app/Http/Livewire/Project/Application/General.php index c7f84258d..f632a4431 100644 --- a/app/Http/Livewire/Project/Application/General.php +++ b/app/Http/Livewire/Project/Application/General.php @@ -32,7 +32,7 @@ class General extends Component public bool $is_force_https_enabled; protected $rules = [ - 'application.name' => 'required|min:6', + 'application.name' => 'required', 'application.fqdn' => 'nullable', 'application.git_repository' => 'required', 'application.git_branch' => 'required', @@ -67,6 +67,11 @@ class General extends Component { // @TODO: find another way - if possible $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_lfs_enabled = $this->is_git_lfs_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_force_https_enabled = $this->is_force_https_enabled; $this->application->settings->save(); + $this->application->save(); $this->application->refresh(); $this->emit('success', 'Application settings updated!'); $this->checkWildCardDomain(); @@ -126,7 +132,12 @@ class General extends Component $domains = Str::of($this->application->fqdn)->trim()->explode(',')->map(function ($domain) { 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->save(); $this->emit('success', 'Application settings updated!'); diff --git a/app/Http/Livewire/Server/Form.php b/app/Http/Livewire/Server/Form.php index 72d32243f..fc98c05bf 100644 --- a/app/Http/Livewire/Server/Form.php +++ b/app/Http/Livewire/Server/Form.php @@ -12,6 +12,7 @@ class Form extends Component public $uptime; public $dockerVersion; public string|null $wildcard_domain = null; + public int $cleanup_after_percentage; protected $rules = [ 'server.name' => 'required|min:6', @@ -35,6 +36,7 @@ class Form extends Component public function mount() { $this->wildcard_domain = $this->server->settings->wildcard_domain; + $this->cleanup_after_percentage = $this->server->settings->cleanup_after_percentage; } public function installDocker() { @@ -91,8 +93,9 @@ class Form extends Component // return; // } $this->server->settings->wildcard_domain = $this->wildcard_domain; + $this->server->settings->cleanup_after_percentage = $this->cleanup_after_percentage; $this->server->settings->save(); $this->server->save(); $this->emit('success', 'Server updated successfully.'); } -} +} \ No newline at end of file diff --git a/app/Http/Livewire/Settings/Configuration.php b/app/Http/Livewire/Settings/Configuration.php index d0ce9435e..41eae45fd 100644 --- a/app/Http/Livewire/Settings/Configuration.php +++ b/app/Http/Livewire/Settings/Configuration.php @@ -2,7 +2,7 @@ namespace App\Http\Livewire\Settings; -use App\Jobs\InstanceProxyCheckJob; +use App\Jobs\ProxyCheckJob; use App\Models\InstanceSettings as ModelsInstanceSettings; use App\Models\Server; use Livewire\Component; @@ -138,7 +138,7 @@ class Configuration extends Component $this->server = Server::findOrFail(0); $this->setup_instance_fqdn(); if ($this->settings->fqdn) { - dispatch(new InstanceProxyCheckJob()); + dispatch(new ProxyCheckJob()); } $this->emit('success', 'Instance settings updated successfully!'); } diff --git a/app/Http/Livewire/Upgrade.php b/app/Http/Livewire/Upgrade.php index 5b6b5db3f..8bd647f1d 100644 --- a/app/Http/Livewire/Upgrade.php +++ b/app/Http/Livewire/Upgrade.php @@ -40,4 +40,4 @@ class Upgrade extends Component return general_error_handler(err: $e, that: $this); } } -} +} \ No newline at end of file diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php index 18b7dc6d1..36a08fa03 100644 --- a/app/Jobs/ApplicationDeploymentJob.php +++ b/app/Jobs/ApplicationDeploymentJob.php @@ -19,6 +19,7 @@ use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; use Illuminate\Support\Collection; +use Illuminate\Support\Facades\Storage; use Spatie\Url\Url; use Illuminate\Support\Str; use Symfony\Component\Yaml\Yaml; @@ -48,6 +49,7 @@ class ApplicationDeploymentJob implements ShouldQueue private string $container_name; private string $workdir; + private string $build_workdir; private string $build_image_name; private string $production_image_name; 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->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->container_name = generate_container_name($this->application->uuid, $this->pull_request_id); @@ -104,6 +107,7 @@ class ApplicationDeploymentJob implements ShouldQueue public function handle(): void { + ray()->measure(); $this->application_deployment_queue->update([ 'status' => ApplicationDeploymentStatus::IN_PROGRESS->value, ]); @@ -116,31 +120,32 @@ class ApplicationDeploymentJob implements ShouldQueue $this->next(ApplicationDeploymentStatus::FINISHED->value); } catch (\Exception $e) { ray($e); - $this->execute_remote_command([ - ["echo '\nOops something is not okay, are you okay? 😢'"], - ["echo '\n\n{$e->getMessage()}'"] - ]); - $this->fail($e->getMessage()); + $this->fail($e); } finally { - // if (isset($this->docker_compose)) { - // Storage::disk('deployments')->put(Str::kebab($this->application->name) . '/docker-compose.yml', $this->docker_compose); - // } + if (isset($this->docker_compose)) { + Storage::disk('deployments')->put(Str::kebab($this->application->name) . '/docker-compose.yml', $this->docker_compose); + } $this->execute_remote_command( [ "docker rm -f {$this->deployment_uuid} >/dev/null 2>&1", "hidden" => true, ] ); + ray()->measure(); } } 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); } 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() { @@ -153,13 +158,18 @@ class ApplicationDeploymentJob implements ShouldQueue $this->prepare_builder_image(); $this->clone_repository(); - $this->build_image_name = "{$this->application->git_repository}:{$this->commit}-build"; - $this->production_image_name = "{$this->application->uuid}:{$this->commit}"; + $tag = Str::of("{$this->commit}-{$this->application->id}-{$this->pull_request_id}"); + 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(); if (!$this->force_rebuild) { $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()) { $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 ]); - $dockerfile = "FROM {$this->application->static_image} + $dockerfile = base64_encode("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); +COPY --from=$this->build_image_name /app/{$this->application->publish_directory} . +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_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 @@ -360,7 +389,6 @@ COPY --from=$this->build_image_name /app/{$this->application->publish_directory} } $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() diff --git a/app/Jobs/ApplicationDeploymentJobOld.php b/app/Jobs/ApplicationDeploymentJobOld.php deleted file mode 100644 index 87fca814c..000000000 --- a/app/Jobs/ApplicationDeploymentJobOld.php +++ /dev/null @@ -1,738 +0,0 @@ -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); - } -} diff --git a/app/Jobs/DockerCleanupJob.php b/app/Jobs/DockerCleanupJob.php new file mode 100644 index 000000000..117a9bd8a --- /dev/null +++ b/app/Jobs/DockerCleanupJob.php @@ -0,0 +1,51 @@ +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()); + } + } +} \ No newline at end of file diff --git a/app/Jobs/InstanceDockerCleanupJob.php b/app/Jobs/InstanceDockerCleanupJob.php deleted file mode 100644 index 418ac6786..000000000 --- a/app/Jobs/InstanceDockerCleanupJob.php +++ /dev/null @@ -1,39 +0,0 @@ -getMessage()); - } - } -} diff --git a/app/Jobs/InstanceProxyCheckJob.php b/app/Jobs/ProxyCheckJob.php similarity index 95% rename from app/Jobs/InstanceProxyCheckJob.php rename to app/Jobs/ProxyCheckJob.php index 6d90f1be3..bdc38b875 100755 --- a/app/Jobs/InstanceProxyCheckJob.php +++ b/app/Jobs/ProxyCheckJob.php @@ -11,7 +11,7 @@ use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; -class InstanceProxyCheckJob implements ShouldQueue +class ProxyCheckJob implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; diff --git a/app/Models/Application.php b/app/Models/Application.php index 77bf0a5fb..f56a55f79 100644 --- a/app/Models/Application.php +++ b/app/Models/Application.php @@ -195,6 +195,9 @@ class Application extends BaseModel } public function deploymentType() { + if (data_get($this, 'private_key_id')) { + return 'deploy_key'; + } if (data_get($this, 'source')) { return 'source'; } @@ -203,4 +206,4 @@ class Application extends BaseModel } throw new \Exception('No deployment type found'); } -} +} \ No newline at end of file diff --git a/bootstrap/helpers/proxy.php b/bootstrap/helpers/proxy.php index 0a3865bdb..10ecc10d8 100644 --- a/bootstrap/helpers/proxy.php +++ b/bootstrap/helpers/proxy.php @@ -56,6 +56,8 @@ function getProxyConfiguration(Server $server) "--api.insecure=true", "--entrypoints.http.address=:80", "--entrypoints.https.address=:443", + "--entrypoints.http.http.encodequerysemicolons=true", + "--entrypoints.https.http.encodequerysemicolons=true", "--providers.docker=true", "--providers.docker.exposedbydefault=false", "--providers.file.directory=/traefik/dynamic/", diff --git a/config/version.php b/config/version.php index 8de13f6e7..3a9c12a30 100644 --- a/config/version.php +++ b/config/version.php @@ -1,3 +1,3 @@ dropColumn('current_process_id'); }); } -}; +}; \ No newline at end of file diff --git a/database/migrations/2023_06_23_114134_add_disk_usage_percentage_to_servers.php b/database/migrations/2023_06_23_114134_add_disk_usage_percentage_to_servers.php new file mode 100644 index 000000000..d2b0f892c --- /dev/null +++ b/database/migrations/2023_06_23_114134_add_disk_usage_percentage_to_servers.php @@ -0,0 +1,28 @@ +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'); + }); + } +}; \ No newline at end of file diff --git a/database/seeders/ServerSeeder.php b/database/seeders/ServerSeeder.php index 10a4a9c1d..927cee11c 100644 --- a/database/seeders/ServerSeeder.php +++ b/database/seeders/ServerSeeder.php @@ -38,4 +38,4 @@ class ServerSeeder extends Seeder 'private_key_id' => $private_key_1->id ]); } -} +} \ No newline at end of file diff --git a/database/seeders/ServerSettingSeeder.php b/database/seeders/ServerSettingSeeder.php index a4c0ac2ad..f2d8c9b49 100644 --- a/database/seeders/ServerSettingSeeder.php +++ b/database/seeders/ServerSettingSeeder.php @@ -14,6 +14,7 @@ class ServerSettingSeeder extends Seeder public function run(): void { $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_reachable = true; $server_2->settings->save(); @@ -23,4 +24,4 @@ class ServerSettingSeeder extends Seeder $server_3->settings->is_reachable = false; $server_3->settings->save(); } -} +} \ No newline at end of file diff --git a/resources/css/app.css b/resources/css/app.css index 1ed610d1c..b788c6e6d 100644 --- a/resources/css/app.css +++ b/resources/css/app.css @@ -3,32 +3,32 @@ @tailwind utilities; .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 { @apply text-neutral-400; } body { - @apply scrollbar antialiased text-sm; + @apply text-sm antialiased scrollbar; } .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 { - @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"]) { @apply border-none disabled:border-none; } input[type="checkbox"] { - @apply toggle toggle-warning toggle-xs rounded disabled:toggle-warning; + @apply rounded toggle toggle-warning toggle-xs disabled:toggle-warning; } 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 { - @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 { @@ -43,7 +43,7 @@ button[isWarning] { @apply bg-red-600 hover:bg-red-500; } button[isHighlighted] { - @apply btn-primary text-white; + @apply text-white btn-primary; } h1 { @apply text-3xl font-bold text-white; @@ -61,7 +61,7 @@ a { @apply text-neutral-400 hover:text-white link link-hover hover:bg-transparent; } .kbd-custom { - @apply px-2 text-xs border border-dashed rounded border-neutral-700 text-warning; + @apply px-2 text-xs border border-dashed rounded border-neutral-700 text-warning; } .icon { @apply w-6 h-6; @@ -70,7 +70,7 @@ a { @apply text-white; } .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 { @@ -124,5 +124,5 @@ tr td { @apply px-3 py-4 whitespace-nowrap; } tr td:first-child { - @apply pl-4 pr-3 sm:pl-6 font-bold; + @apply pl-4 pr-3 font-bold sm:pl-6; } diff --git a/resources/views/components/layout.blade.php b/resources/views/components/layout.blade.php index 5d6f10796..36668c6a2 100644 --- a/resources/views/components/layout.blade.php +++ b/resources/views/components/layout.blade.php @@ -17,9 +17,9 @@ @vite(['resources/js/app.js', 'resources/css/app.css']) @livewireStyles @@ -27,107 +27,107 @@ @livewireScripts @auth - - -
- -
-
- {{ $slot }} -
- - + function copyToClipboard(text) { + navigator.clipboard.writeText(text); + Livewire.emit('message', 'Copied to clipboard.'); + } + Livewire.on('reloadWindow', () => { + window.location.reload(); + }) + Livewire.on('info', (message) => { + if (message) Toaster.info(message) + }) + Livewire.on('error', (message) => { + if (message) Toaster.error(message) + }) + Livewire.on('warning', (message) => { + if (message) Toaster.warning(message) + }) + Livewire.on('success', (message) => { + if (message) Toaster.success(message) + }) + @endauth @guest - {{ $slot }} + {{ $slot }} @endguest - + \ No newline at end of file diff --git a/resources/views/components/navbar.blade.php b/resources/views/components/navbar.blade.php index 257589db7..3848599c0 100644 --- a/resources/views/components/navbar.blade.php +++ b/resources/views/components/navbar.blade.php @@ -1,137 +1,110 @@ @auth - +@endauth \ No newline at end of file diff --git a/resources/views/livewire/project/application/general.blade.php b/resources/views/livewire/project/application/general.blade.php index 72f64b58a..76bb140b2 100644 --- a/resources/views/livewire/project/application/general.blade.php +++ b/resources/views/livewire/project/application/general.blade.php @@ -44,7 +44,7 @@
+ helper="Directory to use as root. Useful for monorepos. WIP" disabled /> @if ($application->settings->is_static) diff --git a/resources/views/livewire/server/form.blade.php b/resources/views/livewire/server/form.blade.php index 4a88910ac..ce7720fc6 100644 --- a/resources/views/livewire/server/form.blade.php +++ b/resources/views/livewire/server/form.blade.php @@ -33,6 +33,10 @@
+

Settings

+
+ +

Actions

@if ($server->settings->is_reachable)
diff --git a/resources/views/livewire/source/github/change.blade.php b/resources/views/livewire/source/github/change.blade.php index c896e9a90..3cea34698 100644 --- a/resources/views/livewire/source/github/change.blade.php +++ b/resources/views/livewire/source/github/change.blade.php @@ -32,6 +32,11 @@
Your Private GitHub App for private repositories.
@if ($github_app->app_id) +
+ +
- @else
diff --git a/resources/views/livewire/upgrade.blade.php b/resources/views/livewire/upgrade.blade.php index 3d9b76d9c..657bfe52c 100644 --- a/resources/views/livewire/upgrade.blade.php +++ b/resources/views/livewire/upgrade.blade.php @@ -1,6 +1,6 @@ -
  • +
  • @if ($isUpgradeAvailable) - -
  • + @else + @endif diff --git a/routes/web.php b/routes/web.php index ade352398..18f09484e 100644 --- a/routes/web.php +++ b/routes/web.php @@ -116,7 +116,7 @@ Route::middleware(['auth'])->group(function () { ]); })->name('source.all'); 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(); $name = Str::of(Str::kebab($github_app->name)); if ($settings->public_ipv4) { diff --git a/scripts/run b/scripts/run index 8b7d40000..5535014f1 100755 --- a/scripts/run +++ b/scripts/run @@ -20,6 +20,13 @@ function help { 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 { php artisan sync:bunny --env=secrets } diff --git a/versions.json b/versions.json index 684123a62..6c8e94817 100644 --- a/versions.json +++ b/versions.json @@ -4,7 +4,7 @@ "version": "3.12.32" }, "v4": { - "version": "4.0.0-beta.16" + "version": "4.0.0-beta.17" } } } \ No newline at end of file