From df5a4a9667d0b70b35038ccaf42e3bbcb4e7f271 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 6 Oct 2023 11:16:29 +0200 Subject: [PATCH 1/8] fix: contact details in emails fix: pricing plans --- config/sentry.php | 2 +- config/version.php | 2 +- .../views/components/emails/footer.blade.php | 2 +- .../views/components/pricing-plans.blade.php | 17 +++++++++++++---- versions.json | 2 +- 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/config/sentry.php b/config/sentry.php index 25eda3bcb4..337e904e10 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.68', + 'release' => '4.0.0-beta.69', // 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 9877f77ef2..0dafd3ed99 100644 --- a/config/version.php +++ b/config/version.php @@ -1,3 +1,3 @@ {{ config('app.name') ?? 'Coolify' }} -{{ Illuminate\Mail\Markdown::parse('[Contact Support](https://docs.coollabs.io/contact)') }} +{{ Illuminate\Mail\Markdown::parse('[Contact Support](https://coolify.io/docs/contact)') }} diff --git a/resources/views/components/pricing-plans.blade.php b/resources/views/components/pricing-plans.blade.php index 9b1070e2d4..5c2b80f94c 100644 --- a/resources/views/components/pricing-plans.blade.php +++ b/resources/views/components/pricing-plans.blade.php @@ -81,7 +81,7 @@ class="grid max-w-sm grid-cols-1 -mt-16 divide-y divide-coolgray-500 isolate gap d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z" clip-rule="evenodd" /> - 1 server + 1 server
  • - Basic Support + Included Email System +
  • +
  • + + Email Support
  • - 10 servers + 10 servers
  • - ? servers + ? servers
  • diff --git a/versions.json b/versions.json index e8c451510b..040f086869 100644 --- a/versions.json +++ b/versions.json @@ -4,7 +4,7 @@ "version": "3.12.36" }, "v4": { - "version": "4.0.0-beta.68" + "version": "4.0.0-beta.69" } } } From 9eaa13a08ac08dcc6161073f64e5c43c8ea7b21c Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 6 Oct 2023 11:17:35 +0200 Subject: [PATCH 2/8] update --- resources/views/components/pricing-plans.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/components/pricing-plans.blade.php b/resources/views/components/pricing-plans.blade.php index 5c2b80f94c..c80a2353ec 100644 --- a/resources/views/components/pricing-plans.blade.php +++ b/resources/views/components/pricing-plans.blade.php @@ -166,7 +166,7 @@ class="grid max-w-sm grid-cols-1 -mt-16 divide-y divide-coolgray-500 isolate gap d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z" clip-rule="evenodd" /> - Email Support + Priority Email Support
  • Date: Fri, 6 Oct 2023 12:32:38 +0200 Subject: [PATCH 3/8] fix: set smtp notifications on by default --- ...111818_set_notifications_on_by_default.php | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 database/migrations/2023_09_23_111818_set_notifications_on_by_default.php diff --git a/database/migrations/2023_09_23_111818_set_notifications_on_by_default.php b/database/migrations/2023_09_23_111818_set_notifications_on_by_default.php new file mode 100644 index 0000000000..a7edc7860a --- /dev/null +++ b/database/migrations/2023_09_23_111818_set_notifications_on_by_default.php @@ -0,0 +1,30 @@ +boolean('smtp_notifications_deployments')->default(true)->change(); + $table->boolean('smtp_notifications_status_changes')->default(true)->change(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('teams', function (Blueprint $table) { + $table->boolean('smtp_notifications_deployments')->default(false)->change(); + $table->boolean('smtp_notifications_status_changes')->default(false)->change(); + }); + } +}; From 5b56c50f03670675e862fe8faeaba774da1540b7 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 6 Oct 2023 13:46:42 +0200 Subject: [PATCH 4/8] feat: init version of any git deployment --- .../Livewire/Project/Application/Previews.php | 2 +- .../Project/New/PublicGitRepository.php | 70 ++++++++++++------- app/Jobs/ApplicationDeploymentJob.php | 17 ++++- app/Jobs/ApplicationPullRequestUpdateJob.php | 4 +- app/Models/Application.php | 7 ++ bootstrap/helpers/github.php | 2 +- docker/coolify-helper/Dockerfile | 4 +- .../project/application/general.blade.php | 36 ++++++---- .../project/application/source.blade.php | 2 +- 9 files changed, 94 insertions(+), 50 deletions(-) diff --git a/app/Http/Livewire/Project/Application/Previews.php b/app/Http/Livewire/Project/Application/Previews.php index a5459a7bbf..1c96740111 100644 --- a/app/Http/Livewire/Project/Application/Previews.php +++ b/app/Http/Livewire/Project/Application/Previews.php @@ -25,7 +25,7 @@ public function mount() public function load_prs() { try { - ['rate_limit_remaining' => $rate_limit_remaining, 'data' => $data] = git_api(source: $this->application->source, endpoint: "/repos/{$this->application->git_repository}/pulls"); + ['rate_limit_remaining' => $rate_limit_remaining, 'data' => $data] = githubApi(source: $this->application->source, endpoint: "/repos/{$this->application->git_repository}/pulls"); $this->rate_limit_remaining = $rate_limit_remaining; $this->pull_requests = $data->sortBy('number')->values(); } catch (\Throwable $e) { diff --git a/app/Http/Livewire/Project/New/PublicGitRepository.php b/app/Http/Livewire/Project/New/PublicGitRepository.php index 837c32abef..b725e231d3 100644 --- a/app/Http/Livewire/Project/New/PublicGitRepository.php +++ b/app/Http/Livewire/Project/New/PublicGitRepository.php @@ -27,9 +27,10 @@ class PublicGitRepository extends Component public int $rate_limit_remaining = 0; public $rate_limit_reset = 0; private object $repository_url_parsed; - public GithubApp|GitlabApp|null $git_source = null; + public GithubApp|GitlabApp|string $git_source = 'other'; public string $git_host; public string $git_repository; + protected $rules = [ 'repository_url' => 'required|url', 'port' => 'required|numeric', @@ -64,7 +65,10 @@ public function instantSave() } $this->emit('success', 'Application settings updated!'); } - + public function load_any_git() + { + $this->branch_found = true; + } public function load_branch() { try { @@ -99,21 +103,22 @@ private function get_git_source() if ($this->git_host == 'github.com') { $this->git_source = GithubApp::where('name', 'Public GitHub')->first(); - } elseif ($this->git_host == 'gitlab.com') { - $this->git_source = GitlabApp::where('name', 'Public GitLab')->first(); - } elseif ($this->git_host == 'bitbucket.org') { - // Not supported yet - } - if (is_null($this->git_source)) { - throw new \Exception('Git source not found. What?!'); } + $this->git_repository = $this->repository_url; + $this->git_source = 'other'; } private function get_branch() { - ['rate_limit_remaining' => $this->rate_limit_remaining, 'rate_limit_reset' => $this->rate_limit_reset] = git_api(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; + if ($this->git_source === 'other') { + $this->branch_found = 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; + } } public function submit() @@ -136,19 +141,34 @@ public function submit() $project = Project::where('uuid', $project_uuid)->first(); $environment = $project->load(['environments'])->environments->where('name', $environment_name)->first(); - $application_init = [ - 'name' => generate_application_name($this->git_repository, $this->git_branch), - 'git_repository' => $this->git_repository, - 'git_branch' => $this->git_branch, - 'build_pack' => 'nixpacks', - 'ports_exposes' => $this->port, - 'publish_directory' => $this->publish_directory, - 'environment_id' => $environment->id, - 'destination_id' => $destination->id, - 'destination_type' => $destination_class, - 'source_id' => $this->git_source->id, - 'source_type' => $this->git_source->getMorphClass() - ]; + if ($this->git_source === 'other') { + $application_init = [ + 'name' => generate_application_name($this->git_repository, $this->git_branch), + 'git_repository' => $this->git_repository, + 'git_branch' => $this->git_branch, + 'build_pack' => 'nixpacks', + 'ports_exposes' => $this->port, + 'publish_directory' => $this->publish_directory, + 'environment_id' => $environment->id, + 'destination_id' => $destination->id, + 'destination_type' => $destination_class, + ]; + } else { + $application_init = [ + 'name' => generate_application_name($this->git_repository, $this->git_branch), + 'git_repository' => $this->git_repository, + 'git_branch' => $this->git_branch, + 'build_pack' => 'nixpacks', + 'ports_exposes' => $this->port, + 'publish_directory' => $this->publish_directory, + 'environment_id' => $environment->id, + 'destination_id' => $destination->id, + 'destination_type' => $destination_class, + 'source_id' => $this->git_source->id, + 'source_type' => $this->git_source->getMorphClass() + ]; + } + $application = Application::create($application_init); diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php index f05739379e..9988c97283 100644 --- a/app/Jobs/ApplicationDeploymentJob.php +++ b/app/Jobs/ApplicationDeploymentJob.php @@ -45,7 +45,7 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted private string $commit; private bool $force_rebuild; - private GithubApp|GitlabApp $source; + private GithubApp|GitlabApp|string $source = 'other'; private StandaloneDocker|SwarmDocker $destination; private Server $server; private ApplicationPreview|null $preview = null; @@ -80,7 +80,10 @@ public function __construct(int $application_deployment_queue_id) $this->commit = $this->application_deployment_queue->commit; $this->force_rebuild = $this->application_deployment_queue->force_rebuild; - $this->source = $this->application->source->getMorphClass()::where('id', $this->application->source->id)->first(); + $source = data_get($this->application, 'source'); + if ($source) { + $this->source = $source->getMorphClass()::where('id', $this->application->source->id)->first(); + } $this->destination = $this->application->destination->getMorphClass()::where('id', $this->application->destination->id)->first(); $this->server = $this->destination->server; @@ -89,7 +92,7 @@ public function __construct(int $application_deployment_queue_id) $this->configuration_dir = application_configuration_dir() . "/{$this->application->uuid}"; $this->is_debug_enabled = $this->application->settings->is_debug_enabled; - ray($this->basedir,$this->workdir); + ray($this->basedir, $this->workdir); $this->container_name = generateApplicationContainerName($this->application, $this->pull_request_id); savePrivateKeyToFs($this->server); $this->saved_outputs = collect(); @@ -425,6 +428,7 @@ private function importing_git_repository() $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)); @@ -459,6 +463,13 @@ private function importing_git_repository() ]); return $commands->implode(' && '); } + if ($this->application->deploymentType() === 'other') { + $git_clone_command = "{$git_clone_command} {$this->application->git_repository} {$this->basedir}"; + $git_clone_command = $this->set_git_import_settings($git_clone_command); + $commands->push(executeInDocker($this->deployment_uuid, $git_clone_command)); + ray($commands); + return $commands->implode(' && '); + } } private function set_git_import_settings($git_clone_command) diff --git a/app/Jobs/ApplicationPullRequestUpdateJob.php b/app/Jobs/ApplicationPullRequestUpdateJob.php index 851c04169d..dbe0ff81c0 100755 --- a/app/Jobs/ApplicationPullRequestUpdateJob.php +++ b/app/Jobs/ApplicationPullRequestUpdateJob.php @@ -66,7 +66,7 @@ public function handle() private function update_comment() { - ['data' => $data] = git_api(source: $this->application->source, endpoint: "/repos/{$this->application->git_repository}/issues/comments/{$this->preview->pull_request_issue_comment_id}", method: 'patch', data: [ + ['data' => $data] = githubApi(source: $this->application->source, endpoint: "/repos/{$this->application->git_repository}/issues/comments/{$this->preview->pull_request_issue_comment_id}", method: 'patch', data: [ 'body' => $this->body, ], throwError: false); if (data_get($data, 'message') === 'Not Found') { @@ -77,7 +77,7 @@ private function update_comment() private function create_comment() { - ['data' => $data] = git_api(source: $this->application->source, endpoint: "/repos/{$this->application->git_repository}/issues/{$this->pull_request_id}/comments", method: 'post', data: [ + ['data' => $data] = githubApi(source: $this->application->source, endpoint: "/repos/{$this->application->git_repository}/issues/{$this->pull_request_id}/comments", method: 'post', data: [ 'body' => $this->body, ]); $this->preview->pull_request_issue_comment_id = $data['id']; diff --git a/app/Models/Application.php b/app/Models/Application.php index af2db98ee1..3d23a57091 100644 --- a/app/Models/Application.php +++ b/app/Models/Application.php @@ -68,6 +68,7 @@ public function gitBranchLocation(): Attribute if (!is_null($this->source?->html_url) && !is_null($this->git_repository) && !is_null($this->git_branch)) { return "{$this->source->html_url}/{$this->git_repository}/tree/{$this->git_branch}"; } + return $this->git_repository; } ); @@ -80,6 +81,7 @@ public function gitCommits(): Attribute if (!is_null($this->source?->html_url) && !is_null($this->git_repository) && !is_null($this->git_branch)) { return "{$this->source->html_url}/{$this->git_repository}/commits/{$this->git_branch}"; } + return $this->git_repository; } ); } @@ -224,6 +226,8 @@ public function deploymentType() return 'deploy_key'; } else if (data_get($this, 'source')) { return 'source'; + } else { + return 'other'; } throw new \Exception('No deployment type found'); } @@ -239,6 +243,9 @@ public function git_based(): bool if ($this->dockerfile) { return false; } + if (is_null($this->source)) { + return false; + } return true; } public function isHealthcheckDisabled(): bool diff --git a/bootstrap/helpers/github.php b/bootstrap/helpers/github.php index 5c36f091da..16ac3671a3 100644 --- a/bootstrap/helpers/github.php +++ b/bootstrap/helpers/github.php @@ -50,7 +50,7 @@ function generate_github_jwt_token(GithubApp $source) return $issuedToken; } -function git_api(GithubApp|GitlabApp $source, string $endpoint, string $method = 'get', array|null $data = null, bool $throwError = true) +function githubApi(GithubApp|GitlabApp $source, string $endpoint, string $method = 'get', array|null $data = null, bool $throwError = true) { if ($source->getMorphClass() == 'App\Models\GithubApp') { if ($source->is_public) { diff --git a/docker/coolify-helper/Dockerfile b/docker/coolify-helper/Dockerfile index 5ff46888bb..0202991898 100644 --- a/docker/coolify-helper/Dockerfile +++ b/docker/coolify-helper/Dockerfile @@ -8,9 +8,9 @@ ARG DOCKER_COMPOSE_VERSION=2.21.0 # https://github.com/docker/buildx/releases ARG DOCKER_BUILDX_VERSION=0.11.2 # https://github.com/buildpacks/pack/releases -ARG PACK_VERSION=0.30.0 +ARG PACK_VERSION=0.31.0 # https://github.com/railwayapp/nixpacks/releases -ARG NIXPACKS_VERSION=1.16.0 +ARG NIXPACKS_VERSION=1.17.0 USER root WORKDIR /artifacts diff --git a/resources/views/livewire/project/application/general.blade.php b/resources/views/livewire/project/application/general.blade.php index b6fda01ab3..112021dace 100644 --- a/resources/views/livewire/project/application/general.blade.php +++ b/resources/views/livewire/project/application/general.blade.php @@ -19,19 +19,28 @@ @if (!$application->dockerfile) -
    - - - - +
    +
    + + + + + @if ($application->settings->is_static) + + + + + @endif +
    + @if ($application->could_set_build_commands()) +
    + +
    + @endif
    @endif - @if ($application->settings->is_static) - - - - - @endif + @if ($application->could_set_build_commands())

    Build

    @@ -69,10 +78,7 @@

    Advanced

    - @if ($application->could_set_build_commands()) - - @endif + diff --git a/resources/views/livewire/project/application/source.blade.php b/resources/views/livewire/project/application/source.blade.php index 143260e76a..f600be0351 100644 --- a/resources/views/livewire/project/application/source.blade.php +++ b/resources/views/livewire/project/application/source.blade.php @@ -9,7 +9,7 @@ - @if (!$application->source->is_public) + @if (data_get($application, 'source.is_public') === false) Open Git App From e443fc394a48c8955864edfd912113f63df14a84 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 6 Oct 2023 13:52:15 +0200 Subject: [PATCH 5/8] fix: select branch on other git --- app/Http/Livewire/Project/New/PublicGitRepository.php | 1 + lang/en.json | 4 ++-- .../livewire/project/new/public-git-repository.blade.php | 9 +++++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/Http/Livewire/Project/New/PublicGitRepository.php b/app/Http/Livewire/Project/New/PublicGitRepository.php index b725e231d3..7a206fae43 100644 --- a/app/Http/Livewire/Project/New/PublicGitRepository.php +++ b/app/Http/Livewire/Project/New/PublicGitRepository.php @@ -103,6 +103,7 @@ private function get_git_source() if ($this->git_host == 'github.com') { $this->git_source = GithubApp::where('name', 'Public GitHub')->first(); + return; } $this->git_repository = $this->repository_url; $this->git_source = 'other'; diff --git a/lang/en.json b/lang/en.json index 6908255fd6..a0a62155f5 100644 --- a/lang/en.json +++ b/lang/en.json @@ -20,5 +20,5 @@ "input.code": "One-time code", "input.recovery_code": "Recovery code", "button.save": "Save", - "repository.url": "Examples
    https://github.com/coollabsio/coolify-examples main branch will be selected

    https://github.com/coollabsio/coolify-examples/tree/nodejs-fastify nodejs-fastify branch will be selected" -} \ No newline at end of file + "repository.url": "Examples
    https://github.com/coollabsio/coolify-examples main branch will be selected

    https://github.com/coollabsio/coolify-examples/tree/nodejs-fastify nodejs-fastify branch will be selected.

    https://gitea.com/sedlav/expressjs.git main branch will be selected.

    https://gitlab.com/andrasbacsai/nodejs-example.git main branch will be selected." +} 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 2b9ee568c2..78f7742c9b 100644 --- a/resources/views/livewire/project/new/public-git-repository.blade.php +++ b/resources/views/livewire/project/new/public-git-repository.blade.php @@ -22,8 +22,13 @@

    Details

    - + @if ($git_source === 'other') + + @else + + @endif @if ($is_static) From 2f4d7c0e430fea4ee6eaea580a986d71fb61dbd5 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 6 Oct 2023 14:39:30 +0200 Subject: [PATCH 6/8] feat: deploy private repo with ssh key --- .../New/GithubPrivateRepositoryDeployKey.php | 70 ++++++++++++------- app/Jobs/ApplicationDeploymentJob.php | 13 ++-- app/Models/Application.php | 4 +- .../livewire/project/new/select.blade.php | 2 +- 4 files changed, 53 insertions(+), 36 deletions(-) diff --git a/app/Http/Livewire/Project/New/GithubPrivateRepositoryDeployKey.php b/app/Http/Livewire/Project/New/GithubPrivateRepositoryDeployKey.php index cf8f56642a..0397b822fb 100644 --- a/app/Http/Livewire/Project/New/GithubPrivateRepositoryDeployKey.php +++ b/app/Http/Livewire/Project/New/GithubPrivateRepositoryDeployKey.php @@ -11,6 +11,7 @@ use App\Models\SwarmDocker; use Livewire\Component; use Spatie\Url\Url; +use Illuminate\Support\Str; class GithubPrivateRepositoryDeployKey extends Component { @@ -29,7 +30,7 @@ class GithubPrivateRepositoryDeployKey extends Component public string $repository_url; public string $branch; protected $rules = [ - 'repository_url' => 'required|url', + 'repository_url' => 'required', 'branch' => 'required|string', 'port' => 'required|numeric', 'is_static' => 'required|boolean', @@ -43,8 +44,8 @@ class GithubPrivateRepositoryDeployKey extends Component 'publish_directory' => 'Publish directory', ]; private object $repository_url_parsed; - private GithubApp|GitlabApp|null $git_source = null; - private string $git_host; + private GithubApp|GitlabApp|string $git_source = 'other'; + private ?string $git_host = null; private string $git_repository; public function mount() @@ -92,21 +93,38 @@ public function submit() $project = Project::where('uuid', $this->parameters['project_uuid'])->first(); $environment = $project->load(['environments'])->environments->where('name', $this->parameters['environment_name'])->first(); - $application_init = [ - 'name' => generate_random_name(), - 'git_repository' => $this->git_repository, - 'git_branch' => $this->branch, - 'git_full_url' => "git@$this->git_host:$this->git_repository.git", - 'build_pack' => 'nixpacks', - 'ports_exposes' => $this->port, - 'publish_directory' => $this->publish_directory, - 'environment_id' => $environment->id, - 'destination_id' => $destination->id, - 'destination_type' => $destination_class, - 'private_key_id' => $this->private_key_id, - 'source_id' => $this->git_source->id, - 'source_type' => $this->git_source->getMorphClass() - ]; + if ($this->git_source === 'other') { + $application_init = [ + 'name' => generate_random_name(), + 'git_repository' => $this->git_repository, + 'git_branch' => $this->branch, + 'git_full_url' => $this->git_repository, + 'build_pack' => 'nixpacks', + 'ports_exposes' => $this->port, + 'publish_directory' => $this->publish_directory, + 'environment_id' => $environment->id, + 'destination_id' => $destination->id, + 'destination_type' => $destination_class, + 'private_key_id' => $this->private_key_id, + ]; + } else { + $application_init = [ + 'name' => generate_random_name(), + 'git_repository' => $this->git_repository, + 'git_branch' => $this->branch, + 'git_full_url' => "git@$this->git_host:$this->git_repository.git", + 'build_pack' => 'nixpacks', + 'ports_exposes' => $this->port, + 'publish_directory' => $this->publish_directory, + 'environment_id' => $environment->id, + 'destination_id' => $destination->id, + 'destination_type' => $destination_class, + 'private_key_id' => $this->private_key_id, + 'source_id' => $this->git_source->id, + 'source_type' => $this->git_source->getMorphClass() + ]; + } + $application = Application::create($application_init); $application->settings->is_static = $this->is_static; $application->settings->save(); @@ -128,16 +146,18 @@ public function submit() private function get_git_source() { - $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); + if (Str::of($this->repository_url)->startsWith('http')) { + $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); + } else { + $this->git_repository = $this->repository_url; + } if ($this->git_host == 'github.com') { $this->git_source = GithubApp::where('name', 'Public GitHub')->first(); - } elseif ($this->git_host == 'gitlab.com') { - $this->git_source = GitlabApp::where('name', 'Public GitLab')->first(); - } elseif ($this->git_host == 'bitbucket.org') { - // Not supported yet + return; } + $this->git_source = 'other'; } } diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php index 9988c97283..fc0387357c 100644 --- a/app/Jobs/ApplicationDeploymentJob.php +++ b/app/Jobs/ApplicationDeploymentJob.php @@ -165,12 +165,12 @@ public function handle(): void ] ); } - // $this->execute_remote_command( - // [ - // "docker rm -f {$this->deployment_uuid} >/dev/null 2>&1", - // "hidden" => true, - // ] - // ); + $this->execute_remote_command( + [ + "docker rm -f {$this->deployment_uuid} >/dev/null 2>&1", + "hidden" => true, + ] + ); } } private function deploy_docker_compose() @@ -428,7 +428,6 @@ private function importing_git_repository() $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)); diff --git a/app/Models/Application.php b/app/Models/Application.php index 3d23a57091..3f5eb54d59 100644 --- a/app/Models/Application.php +++ b/app/Models/Application.php @@ -243,9 +243,7 @@ public function git_based(): bool if ($this->dockerfile) { return false; } - if (is_null($this->source)) { - return false; - } + return true; } public function isHealthcheckDisabled(): bool diff --git a/resources/views/livewire/project/new/select.blade.php b/resources/views/livewire/project/new/select.blade.php index 8e4b9d54c4..3bda859b3c 100644 --- a/resources/views/livewire/project/new/select.blade.php +++ b/resources/views/livewire/project/new/select.blade.php @@ -23,7 +23,7 @@
    - Private Repository + Private Repository (with GitHub App)
    You can deploy public & private repositories through your GitHub Apps. From 4e94b4a0c1ef9de9964de9f5f52d9c228f177dc4 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 6 Oct 2023 14:50:49 +0200 Subject: [PATCH 7/8] fix: private repository --- .../New/GithubPrivateRepositoryDeployKey.php | 15 ++++++++------- lang/en.json | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/app/Http/Livewire/Project/New/GithubPrivateRepositoryDeployKey.php b/app/Http/Livewire/Project/New/GithubPrivateRepositoryDeployKey.php index 0397b822fb..522eb8845e 100644 --- a/app/Http/Livewire/Project/New/GithubPrivateRepositoryDeployKey.php +++ b/app/Http/Livewire/Project/New/GithubPrivateRepositoryDeployKey.php @@ -146,18 +146,19 @@ public function submit() private function get_git_source() { - if (Str::of($this->repository_url)->startsWith('http')) { - $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); - } else { - $this->git_repository = $this->repository_url; - } + $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); if ($this->git_host == 'github.com') { $this->git_source = GithubApp::where('name', 'Public GitHub')->first(); return; } + if (Str::of($this->repository_url)->startsWith('http')) { + $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_repository = Str::finish("git@$this->git_host:$this->git_repository", '.git'); + } $this->git_source = 'other'; } } diff --git a/lang/en.json b/lang/en.json index a0a62155f5..1f4fbdb745 100644 --- a/lang/en.json +++ b/lang/en.json @@ -20,5 +20,5 @@ "input.code": "One-time code", "input.recovery_code": "Recovery code", "button.save": "Save", - "repository.url": "Examples
    https://github.com/coollabsio/coolify-examples main branch will be selected

    https://github.com/coollabsio/coolify-examples/tree/nodejs-fastify nodejs-fastify branch will be selected.

    https://gitea.com/sedlav/expressjs.git main branch will be selected.

    https://gitlab.com/andrasbacsai/nodejs-example.git main branch will be selected." + "repository.url": "Examples
    For Public repositories, use https://....
    For Private repositories, use git@....

    https://github.com/coollabsio/coolify-examples main branch will be selected
    https://github.com/coollabsio/coolify-examples/tree/nodejs-fastify nodejs-fastify branch will be selected.
    https://gitea.com/sedlav/expressjs.git main branch will be selected.
    https://gitlab.com/andrasbacsai/nodejs-example.git main branch will be selected." } From fe9c501c1d4bbceb3aa8a47bb791ed1386b083f9 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 6 Oct 2023 14:51:50 +0200 Subject: [PATCH 8/8] ui --- resources/views/livewire/project/new/select.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/livewire/project/new/select.blade.php b/resources/views/livewire/project/new/select.blade.php index 3bda859b3c..21e6abc96b 100644 --- a/resources/views/livewire/project/new/select.blade.php +++ b/resources/views/livewire/project/new/select.blade.php @@ -36,7 +36,7 @@ Private Repository (with deploy key)
    - You can deploy public & private repositories with a simple deploy key. + You can deploy public & private repositories with a simple deploy key (SSH key).