From 548c4a4c642277d11c66d6a701256be7e245a8e0 Mon Sep 17 00:00:00 2001 From: Pjort Date: Mon, 15 Jul 2024 17:47:35 +0200 Subject: [PATCH 01/21] Update supabase.yaml Fixes problem related to emails sent for invite and forgotten password, that then doesn't actually use the external URL instead uses the hardcoded: http://supabase-kong:8000 --- templates/compose/supabase.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/compose/supabase.yaml b/templates/compose/supabase.yaml index 14a8e36a0..8ae617d9c 100644 --- a/templates/compose/supabase.yaml +++ b/templates/compose/supabase.yaml @@ -301,7 +301,7 @@ services: - DEFAULT_ORGANIZATION_NAME=${STUDIO_DEFAULT_ORGANIZATION:-Default Organization} - DEFAULT_PROJECT_NAME=${STUDIO_DEFAULT_PROJECT:-Default Project} - - SUPABASE_URL=http://supabase-kong:8000 + - SUPABASE_URL=${SERVICE_FQDN_SUPABASEKONG:-http://supabase-kong:8000} - SUPABASE_PUBLIC_URL=${SERVICE_FQDN_SUPABASEKONG} - SUPABASE_ANON_KEY=${SERVICE_SUPABASEANON_KEY} - SUPABASE_SERVICE_KEY=${SERVICE_SUPABASESERVICE_KEY} @@ -1182,7 +1182,7 @@ services: retries: 3 environment: - JWT_SECRET=${SERVICE_PASSWORD_JWT} - - SUPABASE_URL=http://supabase-kong:8000 + - SUPABASE_URL=${SERVICE_FQDN_SUPABASEKONG:-http://supabase-kong:8000} - SUPABASE_ANON_KEY=${SERVICE_SUPABASEANON_KEY} - SUPABASE_SERVICE_ROLE_KEY=${SERVICE_SUPABASESERVICE_KEY} - SUPABASE_DB_URL=postgresql://postgres:${SERVICE_PASSWORD_POSTGRES}@${POSTGRES_HOSTNAME:-supabase-db}:${POSTGRES_PORT:-5432}/${POSTGRES_DB:-postgres} From 85e1cbad53e628f34c0f0e3f064e20778671bf2b Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 17 Jul 2024 09:17:02 +0200 Subject: [PATCH 02/21] chore: Update version to 4.0.0-beta.316 --- config/sentry.php | 2 +- config/version.php | 2 +- versions.json | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/config/sentry.php b/config/sentry.php index 33c7a4795..f65c89760 100644 --- a/config/sentry.php +++ b/config/sentry.php @@ -7,7 +7,7 @@ // The release version of your application // Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD')) - 'release' => '4.0.0-beta.315', + 'release' => '4.0.0-beta.316', // When left empty or `null` the Laravel environment will be used 'environment' => config('app.env'), diff --git a/config/version.php b/config/version.php index 76a71a716..8821278c1 100644 --- a/config/version.php +++ b/config/version.php @@ -1,3 +1,3 @@ Date: Wed, 17 Jul 2024 14:52:40 +0200 Subject: [PATCH 03/21] feat: add readonly labels --- .../Api/ApplicationsController.php | 36 ++++++++++++------- app/Jobs/ApplicationDeploymentJob.php | 4 ++- app/Livewire/Project/Application/General.php | 9 +++-- app/Models/Service.php | 1 + ...23828_add_is_container_labels_readonly.php | 28 +++++++++++++++ .../project/application/general.blade.php | 8 ++++- .../project/service/edit-compose.blade.php | 11 +++--- 7 files changed, 76 insertions(+), 21 deletions(-) create mode 100644 database/migrations/2024_07_17_123828_add_is_container_labels_readonly.php diff --git a/app/Http/Controllers/Api/ApplicationsController.php b/app/Http/Controllers/Api/ApplicationsController.php index d8175ffe9..bb8c44050 100644 --- a/app/Http/Controllers/Api/ApplicationsController.php +++ b/app/Http/Controllers/Api/ApplicationsController.php @@ -732,8 +732,10 @@ private function create_application(Request $request, $type) $application->environment_id = $environment->id; $application->save(); $application->refresh(); - $application->custom_labels = str(implode('|coolify|', generateLabelsApplication($application)))->replace('|coolify|', "\n"); - $application->save(); + if (! $application->settings->is_container_label_readonly_enabled) { + $application->custom_labels = str(implode('|coolify|', generateLabelsApplication($application)))->replace('|coolify|', "\n"); + $application->save(); + } $application->isConfigurationChanged(true); if ($instantDeploy) { @@ -826,8 +828,10 @@ private function create_application(Request $request, $type) $application->source_id = $githubApp->id; $application->save(); $application->refresh(); - $application->custom_labels = str(implode('|coolify|', generateLabelsApplication($application)))->replace('|coolify|', "\n"); - $application->save(); + if (! $application->settings->is_container_label_readonly_enabled) { + $application->custom_labels = str(implode('|coolify|', generateLabelsApplication($application)))->replace('|coolify|', "\n"); + $application->save(); + } $application->isConfigurationChanged(true); if ($instantDeploy) { @@ -916,8 +920,10 @@ private function create_application(Request $request, $type) $application->environment_id = $environment->id; $application->save(); $application->refresh(); - $application->custom_labels = str(implode('|coolify|', generateLabelsApplication($application)))->replace('|coolify|', "\n"); - $application->save(); + if (! $application->settings->is_container_label_readonly_enabled) { + $application->custom_labels = str(implode('|coolify|', generateLabelsApplication($application)))->replace('|coolify|', "\n"); + $application->save(); + } $application->isConfigurationChanged(true); if ($instantDeploy) { @@ -996,8 +1002,10 @@ private function create_application(Request $request, $type) $application->git_branch = 'main'; $application->save(); $application->refresh(); - $application->custom_labels = str(implode('|coolify|', generateLabelsApplication($application)))->replace('|coolify|', "\n"); - $application->save(); + if (! $application->settings->is_container_label_readonly_enabled) { + $application->custom_labels = str(implode('|coolify|', generateLabelsApplication($application)))->replace('|coolify|', "\n"); + $application->save(); + } $application->isConfigurationChanged(true); if ($instantDeploy) { @@ -1052,8 +1060,10 @@ private function create_application(Request $request, $type) $application->git_branch = 'main'; $application->save(); $application->refresh(); - $application->custom_labels = str(implode('|coolify|', generateLabelsApplication($application)))->replace('|coolify|', "\n"); - $application->save(); + if (! $application->settings->is_container_label_readonly_enabled) { + $application->custom_labels = str(implode('|coolify|', generateLabelsApplication($application)))->replace('|coolify|', "\n"); + $application->save(); + } $application->isConfigurationChanged(true); if ($instantDeploy) { @@ -1494,8 +1504,10 @@ public function update_by_uuid(Request $request) $fqdn = str($fqdn)->replaceEnd(',', '')->trim(); $fqdn = str($fqdn)->replaceStart(',', '')->trim(); $application->fqdn = $fqdn; - $customLabels = str(implode('|coolify|', generateLabelsApplication($application)))->replace('|coolify|', "\n"); - $application->custom_labels = base64_encode($customLabels); + if (! $application->settings->is_container_label_readonly_enabled) { + $customLabels = str(implode('|coolify|', generateLabelsApplication($application)))->replace('|coolify|', "\n"); + $application->custom_labels = base64_encode($customLabels); + } $request->offsetUnset('domains'); } diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php index ac48945f5..ba9eb005e 100644 --- a/app/Jobs/ApplicationDeploymentJob.php +++ b/app/Jobs/ApplicationDeploymentJob.php @@ -1523,7 +1523,9 @@ private function generate_compose_file() $this->application->custom_labels = base64_encode($labels->implode("\n")); $this->application->save(); } else { - $labels = collect(generateLabelsApplication($this->application, $this->preview)); + if (! $this->application->settings->is_container_label_readonly_enabled) { + $labels = collect(generateLabelsApplication($this->application, $this->preview)); + } } if ($this->pull_request_id !== 0) { $labels = collect(generateLabelsApplication($this->application, $this->preview)); diff --git a/app/Livewire/Project/Application/General.php b/app/Livewire/Project/Application/General.php index 91828d42c..ac603f331 100644 --- a/app/Livewire/Project/Application/General.php +++ b/app/Livewire/Project/Application/General.php @@ -84,6 +84,7 @@ class General extends Component 'application.settings.is_static' => 'boolean|required', 'application.settings.is_build_server_enabled' => 'boolean|required', 'application.settings.is_container_label_escape_enabled' => 'boolean|required', + 'application.settings.is_container_label_readonly_enabled' => 'boolean|required', 'application.watch_paths' => 'nullable', 'application.redirect' => 'string|required', ]; @@ -119,6 +120,7 @@ class General extends Component 'application.settings.is_static' => 'Is static', 'application.settings.is_build_server_enabled' => 'Is build server enabled', 'application.settings.is_container_label_escape_enabled' => 'Is container label escape enabled', + 'application.settings.is_container_label_readonly_enabled' => 'Is container label readonly', 'application.watch_paths' => 'Watch paths', 'application.redirect' => 'Redirect', ]; @@ -143,7 +145,7 @@ public function mount() $this->ports_exposes = $this->application->ports_exposes; $this->is_container_label_escape_enabled = $this->application->settings->is_container_label_escape_enabled; $this->customLabels = $this->application->parseContainerLabels(); - if (! $this->customLabels && $this->application->destination->server->proxyType() !== 'NONE') { + if (! $this->customLabels && $this->application->destination->server->proxyType() !== 'NONE' && ! $this->application->settings->is_container_label_readonly_enabled) { $this->customLabels = str(implode('|coolify|', generateLabelsApplication($this->application)))->replace('|coolify|', "\n"); $this->application->custom_labels = base64_encode($this->customLabels); $this->application->save(); @@ -290,6 +292,9 @@ public function getWildcardDomain() public function resetDefaultLabels() { + if ($this->application->settings->is_container_label_readonly_enabled) { + return; + } $this->customLabels = str(implode('|coolify|', generateLabelsApplication($this->application)))->replace('|coolify|', "\n"); $this->ports_exposes = $this->application->ports_exposes; $this->is_container_label_escape_enabled = $this->application->settings->is_container_label_escape_enabled; @@ -350,7 +355,7 @@ public function submit($showToaster = true) $this->checkFqdns(); $this->application->save(); - if (! $this->customLabels && $this->application->destination->server->proxyType() !== 'NONE') { + if (! $this->customLabels && $this->application->destination->server->proxyType() !== 'NONE' && ! $this->application->settings->is_container_label_readonly_enabled) { $this->customLabels = str(implode('|coolify|', generateLabelsApplication($this->application)))->replace('|coolify|', "\n"); $this->application->custom_labels = base64_encode($this->customLabels); $this->application->save(); diff --git a/app/Models/Service.php b/app/Models/Service.php index 2fc0778e6..8336b90c8 100644 --- a/app/Models/Service.php +++ b/app/Models/Service.php @@ -24,6 +24,7 @@ 'destination_id' => ['type' => 'integer', 'description' => 'The unique identifier of the destination where the service is running.'], 'connect_to_docker_network' => ['type' => 'boolean', 'description' => 'The flag to connect the service to the predefined Docker network.'], 'is_container_label_escape_enabled' => ['type' => 'boolean', 'description' => 'The flag to enable the container label escape.'], + 'is_container_label_readonly_enabled' => ['type' => 'boolean', 'description' => 'The flag to enable the container label readonly.'], 'config_hash' => ['type' => 'string', 'description' => 'The hash of the service configuration.'], 'service_type' => ['type' => 'string', 'description' => 'The type of the service.'], 'created_at' => ['type' => 'string', 'description' => 'The date and time when the service was created.'], diff --git a/database/migrations/2024_07_17_123828_add_is_container_labels_readonly.php b/database/migrations/2024_07_17_123828_add_is_container_labels_readonly.php new file mode 100644 index 000000000..eb36946a4 --- /dev/null +++ b/database/migrations/2024_07_17_123828_add_is_container_labels_readonly.php @@ -0,0 +1,28 @@ +boolean('is_container_label_readonly_enabled')->default(false); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('application_settings', function (Blueprint $table) { + $table->dropColumn('is_container_label_readonly_enabled'); + }); + } +}; diff --git a/resources/views/livewire/project/application/general.blade.php b/resources/views/livewire/project/application/general.blade.php index 42742a863..86c23a1d5 100644 --- a/resources/views/livewire/project/application/general.blade.php +++ b/resources/views/livewire/project/application/general.blade.php @@ -239,6 +239,9 @@ class="underline" href="https://coolify.io/docs/knowledge-base/docker/registry" + @endif @@ -264,10 +267,13 @@ class="underline" href="https://coolify.io/docs/knowledge-base/docker/registry" -
+
+
diff --git a/resources/views/livewire/project/service/edit-compose.blade.php b/resources/views/livewire/project/service/edit-compose.blade.php index 2632fc0ea..3b1e1a3bc 100644 --- a/resources/views/livewire/project/service/edit-compose.blade.php +++ b/resources/views/livewire/project/service/edit-compose.blade.php @@ -3,11 +3,7 @@ prevent name collision.
To see the actual volume names, check the Deployable Compose file, or go to Storage menu.
-
- -
+
@@ -17,6 +13,11 @@
+
+ +
From 4c031a7c0588fd74205eb5f9e53975273ee3f85b Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 18 Jul 2024 12:03:48 +0200 Subject: [PATCH 04/21] fix: handle / in preselecting branches --- .../Project/New/PublicGitRepository.php | 52 +++++++++---------- .../new/public-git-repository.blade.php | 12 ++--- 2 files changed, 31 insertions(+), 33 deletions(-) diff --git a/app/Livewire/Project/New/PublicGitRepository.php b/app/Livewire/Project/New/PublicGitRepository.php index 867d398df..bf6324c64 100644 --- a/app/Livewire/Project/New/PublicGitRepository.php +++ b/app/Livewire/Project/New/PublicGitRepository.php @@ -25,11 +25,11 @@ class PublicGitRepository extends Component public $query; - public bool $branch_found = false; + public bool $branchFound = false; - public string $selected_branch = 'main'; + public string $selectedBranch = 'main'; - public bool $is_static = false; + public bool $isStatic = false; public ?string $publish_directory = null; @@ -62,7 +62,7 @@ class PublicGitRepository extends Component protected $rules = [ 'repository_url' => 'required|url', 'port' => 'required|numeric', - 'is_static' => 'required|boolean', + 'isStatic' => 'required|boolean', 'publish_directory' => 'nullable|string', 'build_pack' => 'required|string', 'base_directory' => 'nullable|string', @@ -72,7 +72,7 @@ class PublicGitRepository extends Component protected $validationAttributes = [ 'repository_url' => 'repository', 'port' => 'port', - 'is_static' => 'static', + 'isStatic' => 'static', 'publish_directory' => 'publish directory', 'build_pack' => 'build pack', 'base_directory' => 'base directory', @@ -106,17 +106,17 @@ public function updatedBuildPack() $this->port = 3000; } elseif ($this->build_pack === 'static') { $this->show_is_static = false; - $this->is_static = false; + $this->isStatic = false; $this->port = 80; } else { $this->show_is_static = false; - $this->is_static = false; + $this->isStatic = false; } } public function instantSave() { - if ($this->is_static) { + if ($this->isStatic) { $this->port = 80; $this->publish_directory = '/dist'; } else { @@ -126,12 +126,7 @@ public function instantSave() $this->dispatch('success', 'Application settings updated!'); } - public function load_any_git() - { - $this->branch_found = true; - } - - public function load_branch() + public function loadBranch() { try { if (str($this->repository_url)->startsWith('git@')) { @@ -155,15 +150,15 @@ public function load_branch() return handleError($e, $this); } try { - $this->branch_found = false; - $this->get_git_source(); - $this->get_branch(); - $this->selected_branch = $this->git_branch; + $this->branchFound = false; + $this->getGitSource(); + $this->getBranch(); + $this->selectedBranch = $this->git_branch; } catch (\Throwable $e) { - if (! $this->branch_found && $this->git_branch == 'main') { + if (! $this->branchFound && $this->git_branch == 'main') { try { $this->git_branch = 'master'; - $this->get_branch(); + $this->getBranch(); } catch (\Throwable $e) { return handleError($e, $this); } @@ -173,13 +168,16 @@ public function load_branch() } } - private function get_git_source() + private function getGitSource() { $this->repository_url_parsed = Url::fromString($this->repository_url); $this->git_host = $this->repository_url_parsed->getHost(); $this->git_repository = $this->repository_url_parsed->getSegment(1).'/'.$this->repository_url_parsed->getSegment(2); - $this->git_branch = $this->repository_url_parsed->getSegment(4) ?? 'main'; - + if ($this->repository_url_parsed->getSegment(3) === 'tree') { + $this->git_branch = str($this->repository_url_parsed->getPath())->after('tree/')->value(); + } else { + $this->git_branch = 'main'; + } if ($this->git_host == 'github.com') { $this->git_source = GithubApp::where('name', 'Public GitHub')->first(); @@ -189,17 +187,17 @@ private function get_git_source() $this->git_source = 'other'; } - private function get_branch() + private function getBranch() { if ($this->git_source === 'other') { - $this->branch_found = true; + $this->branchFound = true; return; } if ($this->git_source->getMorphClass() === 'App\Models\GithubApp') { ['rate_limit_remaining' => $this->rate_limit_remaining, 'rate_limit_reset' => $this->rate_limit_reset] = githubApi(source: $this->git_source, endpoint: "/repos/{$this->git_repository}/branches/{$this->git_branch}"); $this->rate_limit_reset = Carbon::parse((int) $this->rate_limit_reset)->format('Y-M-d H:i:s'); - $this->branch_found = true; + $this->branchFound = true; } } @@ -287,7 +285,7 @@ public function submit() } $application = Application::create($application_init); - $application->settings->is_static = $this->is_static; + $application->settings->is_static = $this->isStatic; $application->settings->save(); $fqdn = generateFqdn($destination->server, $application->uuid); diff --git a/resources/views/livewire/project/new/public-git-repository.blade.php b/resources/views/livewire/project/new/public-git-repository.blade.php index b9803d24f..17ef0a188 100644 --- a/resources/views/livewire/project/new/public-git-repository.blade.php +++ b/resources/views/livewire/project/new/public-git-repository.blade.php @@ -1,7 +1,7 @@

Create a new Application

Deploy any public Git repositories.
-
+
@@ -11,7 +11,7 @@ Check repository
- @if (!$branch_found) + @if (!$branchFound)
For example application deployments, checkout .
@endif - @if ($branch_found) + @if ($branchFound) @if ($rate_limit_remaining && $rate_limit_reset)
Rate Limit
@@ -42,7 +42,7 @@ - @if ($is_static) + @if ($isStatic) @endif @@ -57,10 +57,10 @@ class='dark:text-warning'>{{ Str::start($base_directory . $docker_compose_location, '/') }} @endif @if ($show_is_static) -
-
@endif From b4b6a4294aec56398cd5acd4d1896920bad14497 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 18 Jul 2024 12:07:44 +0200 Subject: [PATCH 05/21] chore: Update bug report template Update the bug report template to include a checkbox for indicating whether the user is using the cloud version of Coolify. --- .github/ISSUE_TEMPLATE/BUG_REPORT.yml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/BUG_REPORT.yml b/.github/ISSUE_TEMPLATE/BUG_REPORT.yml index 5ee5c3970..ff8f8d3ad 100644 --- a/.github/ISSUE_TEMPLATE/BUG_REPORT.yml +++ b/.github/ISSUE_TEMPLATE/BUG_REPORT.yml @@ -1,6 +1,6 @@ name: Bug report -description: 'Create a new bug report.' -title: '[Bug]: ' +description: "Create a new bug report." +title: "[Bug]: " body: - type: markdown attributes: @@ -35,3 +35,12 @@ body: description: Coolify's version (see top of your screen). validations: required: true + - type: checkboxes + attributes: + label: Cloud? + description: "Are you using the cloud version of Coolify?" + options: + - label: Yes + required: true + - label: No + required: true From 1c4eb31d5946bd58fb750b4626d0e7ad44f27ab8 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 18 Jul 2024 12:10:59 +0200 Subject: [PATCH 06/21] fix: handle custom_internal_name check in ApplicationDeploymentJob.php --- app/Jobs/ApplicationDeploymentJob.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php index ba9eb005e..532b1ae27 100644 --- a/app/Jobs/ApplicationDeploymentJob.php +++ b/app/Jobs/ApplicationDeploymentJob.php @@ -1007,7 +1007,7 @@ private function rolling_update() if ((bool) $this->application->settings->is_consistent_container_name_enabled) { $this->application_deployment_queue->addLogEntry('Consistent container name feature enabled, rolling update is not supported.'); } - if (isset($this->application->settings->custom_internal_name)) { + if (str($this->application->settings->custom_internal_name)->isNotEmpty()) { $this->application_deployment_queue->addLogEntry('Custom internal name is set, rolling update is not supported.'); } if ($this->pull_request_id !== 0) { From 7e11698c555d2fe0bf0960cf65c41fd78890dc69 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 18 Jul 2024 12:13:23 +0200 Subject: [PATCH 07/21] chore: Update repository form with simplified URL input field --- .../project/new/github-private-repository-deploy-key.blade.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/resources/views/livewire/project/new/github-private-repository-deploy-key.blade.php b/resources/views/livewire/project/new/github-private-repository-deploy-key.blade.php index e395d186e..d1f5d1bef 100644 --- a/resources/views/livewire/project/new/github-private-repository-deploy-key.blade.php +++ b/resources/views/livewire/project/new/github-private-repository-deploy-key.blade.php @@ -48,8 +48,7 @@ class="loading loading-xs dark:text-warning loading-spinner"> @if ($current_step === 'repository')

Select a repository

- +
From 1c7034ff78ecdef59a7e0b14f85c782435e68b82 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 18 Jul 2024 12:30:45 +0200 Subject: [PATCH 08/21] fix: if git limit reached, ignore it and continue with a default selection --- app/Livewire/Project/New/PublicGitRepository.php | 7 +++++++ .../project/new/public-git-repository.blade.php | 13 +++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/app/Livewire/Project/New/PublicGitRepository.php b/app/Livewire/Project/New/PublicGitRepository.php index bf6324c64..5759e335e 100644 --- a/app/Livewire/Project/New/PublicGitRepository.php +++ b/app/Livewire/Project/New/PublicGitRepository.php @@ -155,6 +155,13 @@ public function loadBranch() $this->getBranch(); $this->selectedBranch = $this->git_branch; } catch (\Throwable $e) { + if ($this->rate_limit_remaining == 0) { + $this->selectedBranch = $this->git_branch; + $this->branchFound = true; + + return; + } + ray($this->branchFound, $this->git_branch, $this->rate_limit_remaining); if (! $this->branchFound && $this->git_branch == 'main') { try { $this->git_branch = 'master'; diff --git a/resources/views/livewire/project/new/public-git-repository.blade.php b/resources/views/livewire/project/new/public-git-repository.blade.php index 17ef0a188..01cd67575 100644 --- a/resources/views/livewire/project/new/public-git-repository.blade.php +++ b/resources/views/livewire/project/new/public-git-repository.blade.php @@ -11,14 +11,11 @@ Check repository
- @if (!$branchFound) -
- - @endif +
+ For example application deployments, checkout Coolify + Examples. +
@if ($branchFound) @if ($rate_limit_remaining && $rate_limit_reset)
From 0a6826af58cb96ffeb08094a276e6cffd91f9cb8 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 18 Jul 2024 12:32:33 +0200 Subject: [PATCH 09/21] remove ray --- app/Livewire/Project/New/PublicGitRepository.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/Livewire/Project/New/PublicGitRepository.php b/app/Livewire/Project/New/PublicGitRepository.php index 5759e335e..b29fe8cab 100644 --- a/app/Livewire/Project/New/PublicGitRepository.php +++ b/app/Livewire/Project/New/PublicGitRepository.php @@ -161,7 +161,6 @@ public function loadBranch() return; } - ray($this->branchFound, $this->git_branch, $this->rate_limit_remaining); if (! $this->branchFound && $this->git_branch == 'main') { try { $this->git_branch = 'master'; From b33fb6c39a2c572f5b78e72f86edc201a5117776 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 18 Jul 2024 12:39:49 +0200 Subject: [PATCH 10/21] chore: Update width of container in general.blade.php --- resources/views/livewire/project/application/general.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/livewire/project/application/general.blade.php b/resources/views/livewire/project/application/general.blade.php index 86c23a1d5..2f9957313 100644 --- a/resources/views/livewire/project/application/general.blade.php +++ b/resources/views/livewire/project/application/general.blade.php @@ -235,7 +235,7 @@ class="underline" href="https://coolify.io/docs/knowledge-base/docker/registry" label="Docker Compose Content" helper="You need to modify the docker compose file." monacoEditorLanguage="yaml" useMonacoEditor /> @endif -
+
From 1b6114036a0b6b811f1647a315f5ce4c292ecaf9 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 18 Jul 2024 12:40:17 +0200 Subject: [PATCH 11/21] chore: Update checkbox labels in general.blade.php --- .../views/livewire/project/application/general.blade.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/views/livewire/project/application/general.blade.php b/resources/views/livewire/project/application/general.blade.php index 2f9957313..3b6c30039 100644 --- a/resources/views/livewire/project/application/general.blade.php +++ b/resources/views/livewire/project/application/general.blade.php @@ -239,7 +239,7 @@ class="underline" href="https://coolify.io/docs/knowledge-base/docker/registry" -
@@ -271,7 +271,7 @@ class="underline" href="https://coolify.io/docs/knowledge-base/docker/registry" -
From 2529496594a445b97581d5a3ab34db7c6d7de64e Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 18 Jul 2024 13:14:07 +0200 Subject: [PATCH 12/21] feat: preserve git repository --- app/Jobs/ApplicationDeploymentJob.php | 41 +++++++++++++++---- app/Livewire/Project/Application/General.php | 2 + ...ettings_is_preserve_repository_enabled.php | 28 +++++++++++++ .../project/application/advanced.blade.php | 3 +- .../project/application/general.blade.php | 5 +++ 5 files changed, 71 insertions(+), 8 deletions(-) create mode 100644 database/migrations/2024_07_18_110424_create_application_settings_is_preserve_repository_enabled.php diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php index 532b1ae27..3024bf393 100644 --- a/app/Jobs/ApplicationDeploymentJob.php +++ b/app/Jobs/ApplicationDeploymentJob.php @@ -157,6 +157,8 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue private ?string $coolify_variables = null; + private bool $preserveRepository = true; + public $tries = 1; public function __construct(int $application_deployment_queue_id) @@ -187,6 +189,7 @@ public function __construct(int $application_deployment_queue_id) $this->server = $this->mainServer = $this->destination->server; $this->serverUser = $this->server->user; $this->is_this_additional_server = $this->application->additional_servers()->wherePivot('server_id', $this->server->id)->count() > 0; + $this->preserveRepository = $this->application->settings->is_preserve_repository_enabled; $this->basedir = $this->application->generateBaseDir($this->deployment_uuid); $this->workdir = "{$this->basedir}".rtrim($this->application->base_directory, '/'); @@ -296,13 +299,13 @@ public function handle(): void } else { $this->write_deployment_configurations(); } - $this->execute_remote_command( - [ - "docker rm -f {$this->deployment_uuid} >/dev/null 2>&1", - 'hidden' => true, - 'ignore_errors' => true, - ] - ); + // $this->execute_remote_command( + // [ + // "docker rm -f {$this->deployment_uuid} >/dev/null 2>&1", + // 'hidden' => true, + // 'ignore_errors' => true, + // ] + // ); // $this->execute_remote_command( // [ @@ -517,6 +520,8 @@ private function deploy_docker_compose_buildpack() $command .= " --env-file {$this->workdir}/{$this->env_filename}"; } $command .= " --project-name {$this->application->uuid} --project-directory {$this->workdir} -f {$this->workdir}{$this->docker_compose_location} up -d"; + ray($command); + $this->execute_remote_command( [executeInDocker($this->deployment_uuid, $command), 'hidden' => true], ); @@ -605,6 +610,28 @@ private function deploy_static_buildpack() private function write_deployment_configurations() { + if ($this->preserveRepository) { + if ($this->use_build_server) { + $this->server = $this->original_server; + } + if (str($this->configuration_dir)->isNotEmpty()) { + ray("docker cp {$this->deployment_uuid}:{$this->workdir} {$this->configuration_dir}"); + $this->execute_remote_command( + [ + "mkdir -p $this->configuration_dir", + ], + [ + "rm -rf $this->configuration_dir/{*,.*}", + ], + [ + "docker cp {$this->deployment_uuid}:{$this->workdir}/. {$this->configuration_dir}", + ], + ); + } + if ($this->use_build_server) { + $this->server = $this->build_server; + } + } if (isset($this->docker_compose_base64)) { if ($this->use_build_server) { $this->server = $this->original_server; diff --git a/app/Livewire/Project/Application/General.php b/app/Livewire/Project/Application/General.php index ac603f331..7dfd9bad4 100644 --- a/app/Livewire/Project/Application/General.php +++ b/app/Livewire/Project/Application/General.php @@ -85,6 +85,7 @@ class General extends Component 'application.settings.is_build_server_enabled' => 'boolean|required', 'application.settings.is_container_label_escape_enabled' => 'boolean|required', 'application.settings.is_container_label_readonly_enabled' => 'boolean|required', + 'application.settings.is_preserve_repository_enabled' => 'boolean|required', 'application.watch_paths' => 'nullable', 'application.redirect' => 'string|required', ]; @@ -121,6 +122,7 @@ class General extends Component 'application.settings.is_build_server_enabled' => 'Is build server enabled', 'application.settings.is_container_label_escape_enabled' => 'Is container label escape enabled', 'application.settings.is_container_label_readonly_enabled' => 'Is container label readonly', + 'application.settings.is_preserve_repository_enabled' => 'Is preserve repository enabled', 'application.watch_paths' => 'Watch paths', 'application.redirect' => 'Redirect', ]; diff --git a/database/migrations/2024_07_18_110424_create_application_settings_is_preserve_repository_enabled.php b/database/migrations/2024_07_18_110424_create_application_settings_is_preserve_repository_enabled.php new file mode 100644 index 000000000..25dd0ef16 --- /dev/null +++ b/database/migrations/2024_07_18_110424_create_application_settings_is_preserve_repository_enabled.php @@ -0,0 +1,28 @@ +boolean('is_preserve_repository_enabled')->default(false); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('application_settings', function (Blueprint $table) { + $table->dropColumn('is_preserve_repository_enabled'); + }); + } +}; diff --git a/resources/views/livewire/project/application/advanced.blade.php b/resources/views/livewire/project/application/advanced.blade.php index 19cb64a05..dc3f135db 100644 --- a/resources/views/livewire/project/application/advanced.blade.php +++ b/resources/views/livewire/project/application/advanced.blade.php @@ -16,12 +16,13 @@ - @if ($application->build_pack === 'dockercompose') +

Docker Compose

diff --git a/resources/views/livewire/project/application/general.blade.php b/resources/views/livewire/project/application/general.blade.php index 3b6c30039..4f68b6d8e 100644 --- a/resources/views/livewire/project/application/general.blade.php +++ b/resources/views/livewire/project/application/general.blade.php @@ -166,6 +166,11 @@ class="underline" href="https://coolify.io/docs/knowledge-base/docker/registry" id="application.docker_compose_location" label="Docker Compose Location" helper="It is calculated together with the Base Directory:
{{ Str::start($application->base_directory . $application->docker_compose_location, '/') }}" />
+
+ +
The following commands are for advanced use cases. Only modify them if you know what are you doing.
From d98c742aff79e22596b3aa8c7b075c7340c47cc8 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 18 Jul 2024 14:20:22 +0200 Subject: [PATCH 13/21] chore: update general page of apps --- .../project/application/general.blade.php | 243 +++++++++++------- .../livewire/source/github/create.blade.php | 2 +- 2 files changed, 144 insertions(+), 101 deletions(-) diff --git a/resources/views/livewire/project/application/general.blade.php b/resources/views/livewire/project/application/general.blade.php index 4f68b6d8e..232900a5d 100644 --- a/resources/views/livewire/project/application/general.blade.php +++ b/resources/views/livewire/project/application/general.blade.php @@ -30,13 +30,7 @@ @endif
- @if ($application->could_set_build_commands()) -
- -
- @endif + @if ($application->build_pack === 'dockercompose') @if ( !is_null($parsedServices) && @@ -57,6 +51,7 @@ @endforeach @endif @endif +
@endif @if ($application->build_pack !== 'dockercompose') @@ -129,104 +124,152 @@ class="underline" href="https://coolify.io/docs/knowledge-base/docker/registry" @endif
@endif - - @if ($application->build_pack !== 'dockerimage') -

Build

- @if ($application->build_pack !== 'dockercompose') -
- -
- @endif - @if ($application->could_set_build_commands()) - @if ($application->build_pack === 'nixpacks') -
- - - -
-
Nixpacks will detect the required configuration automatically. - Framework - Specific Docs -
- @endif - @endif - @if ($application->build_pack === 'dockercompose') -
-
- - -
-
- -
-
The following commands are for advanced use cases. Only modify them if you - know what are - you doing.
-
- - -
-
- @else -
- - @if ($application->build_pack === 'dockerfile' && !$application->dockerfile) - - @endif - - @if ($application->build_pack === 'dockerfile') - - @endif - @if ($application->could_set_build_commands()) - @if ($application->settings->is_static) - - @else - - @endif - @endif - -
- @if ($this->application->is_github_based() && !$this->application->is_public_repository()) -
- -
- @endif +
+

Build

+ @if ($application->build_pack === 'dockerimage') + @else + @if ($application->could_set_build_commands()) + @if ($application->build_pack === 'nixpacks') +
+ + + +
+
Nixpacks will detect the required configuration + automatically. + Framework + Specific Docs +
+ @endif + @endif +
+
+ +
+
+ @if ($application->build_pack === 'dockercompose') +
+
+ + +
+
+ +
+
The following commands are for advanced use cases. Only + modify them if you + know what are + you doing.
+
+ + +
+
+ @else +
+ + @if ($application->build_pack === 'dockerfile' && !$application->dockerfile) + + @endif + + @if ($application->build_pack === 'dockerfile') + + @endif + @if ($application->could_set_build_commands()) + @if ($application->settings->is_static) + + @else + + @endif + @endif + +
+ @if ($this->application->is_github_based() && !$this->application->is_public_repository()) +
+ +
+ @endif + + + @if ($application->build_pack !== 'dockercompose') +
+ +
+ @endif + @if ($application->could_set_build_commands()) +
+ +
+ @endif + @endif +
+
+
+
@endif - @else - - @endif +
@if ($application->build_pack === 'dockercompose') Reload Compose File diff --git a/resources/views/livewire/source/github/create.blade.php b/resources/views/livewire/source/github/create.blade.php index 97942fbdb..e93b23b78 100644 --- a/resources/views/livewire/source/github/create.blade.php +++ b/resources/views/livewire/source/github/create.blade.php @@ -13,7 +13,7 @@ this.activeAccordion = (this.activeAccordion == id) ? '' : id } }" class="relative w-full py-2 mx-auto overflow-hidden text-sm font-normal rounded-md"> -
+