From 356e7b57d2c14a2c9d8caba1263b8aa66c102ed8 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Mon, 15 Jul 2024 16:39:22 +0200 Subject: [PATCH] improvement: add basedir + compose file in new compose based apps --- .../Project/New/GithubPrivateRepository.php | 20 ++++++++++++++++ .../New/GithubPrivateRepositoryDeployKey.php | 10 ++++++++ .../Project/New/PublicGitRepository.php | 24 +++++++++++++++++++ ...ub-private-repository-deploy-key.blade.php | 9 +++++++ .../new/github-private-repository.blade.php | 11 ++++++++- .../new/public-git-repository.blade.php | 23 +++++++++++------- 6 files changed, 88 insertions(+), 9 deletions(-) diff --git a/app/Livewire/Project/New/GithubPrivateRepository.php b/app/Livewire/Project/New/GithubPrivateRepository.php index 76b337c01..fbeb5601f 100644 --- a/app/Livewire/Project/New/GithubPrivateRepository.php +++ b/app/Livewire/Project/New/GithubPrivateRepository.php @@ -53,6 +53,12 @@ class GithubPrivateRepository extends Component public ?string $publish_directory = null; + // In case of docker compose + public ?string $base_directory = null; + + public ?string $docker_compose_location = '/docker-compose.yaml'; + // End of docker compose + protected int $page = 1; public $build_pack = 'nixpacks'; @@ -68,6 +74,16 @@ public function mount() $this->github_apps = GithubApp::private(); } + public function updatedBaseDirectory() + { + if ($this->base_directory) { + $this->base_directory = rtrim($this->base_directory, '/'); + if (! str($this->base_directory)->startsWith('/')) { + $this->base_directory = '/'.$this->base_directory; + } + } + } + public function updatedBuildPack() { if ($this->build_pack === 'nixpacks') { @@ -184,6 +200,10 @@ public function submit() if ($this->build_pack === 'dockerfile' || $this->build_pack === 'dockerimage') { $application->health_check_enabled = false; } + if ($this->build_pack === 'dockercompose') { + $application['docker_compose_location'] = $this->docker_compose_location; + $application['base_directory'] = $this->base_directory; + } $fqdn = generateFqdn($destination->server, $application->uuid); $application->fqdn = $fqdn; diff --git a/app/Livewire/Project/New/GithubPrivateRepositoryDeployKey.php b/app/Livewire/Project/New/GithubPrivateRepositoryDeployKey.php index a35a92516..0edafd040 100644 --- a/app/Livewire/Project/New/GithubPrivateRepositoryDeployKey.php +++ b/app/Livewire/Project/New/GithubPrivateRepositoryDeployKey.php @@ -33,6 +33,12 @@ class GithubPrivateRepositoryDeployKey extends Component public ?string $publish_directory = null; + // In case of docker compose + public ?string $base_directory = null; + + public ?string $docker_compose_location = '/docker-compose.yaml'; + // End of docker compose + public string $repository_url; public string $branch; @@ -163,6 +169,10 @@ public function submit() if ($this->build_pack === 'dockerfile' || $this->build_pack === 'dockerimage') { $application_init['health_check_enabled'] = false; } + if ($this->build_pack === 'dockercompose') { + $application_init['docker_compose_location'] = $this->docker_compose_location; + $application_init['base_directory'] = $this->base_directory; + } $application = Application::create($application_init); $application->settings->is_static = $this->is_static; $application->settings->save(); diff --git a/app/Livewire/Project/New/PublicGitRepository.php b/app/Livewire/Project/New/PublicGitRepository.php index 7ac7883dc..867d398df 100644 --- a/app/Livewire/Project/New/PublicGitRepository.php +++ b/app/Livewire/Project/New/PublicGitRepository.php @@ -33,6 +33,12 @@ class PublicGitRepository extends Component public ?string $publish_directory = null; + // In case of docker compose + public ?string $base_directory = null; + + public ?string $docker_compose_location = '/docker-compose.yaml'; + // End of docker compose + public string $git_branch = 'main'; public int $rate_limit_remaining = 0; @@ -59,6 +65,8 @@ class PublicGitRepository extends Component 'is_static' => 'required|boolean', 'publish_directory' => 'nullable|string', 'build_pack' => 'required|string', + 'base_directory' => 'nullable|string', + 'docker_compose_location' => 'nullable|string', ]; protected $validationAttributes = [ @@ -67,6 +75,8 @@ class PublicGitRepository extends Component 'is_static' => 'static', 'publish_directory' => 'publish directory', 'build_pack' => 'build pack', + 'base_directory' => 'base directory', + 'docker_compose_location' => 'docker compose location', ]; public function mount() @@ -79,6 +89,16 @@ public function mount() $this->query = request()->query(); } + public function updatedBaseDirectory() + { + if ($this->base_directory) { + $this->base_directory = rtrim($this->base_directory, '/'); + if (! str($this->base_directory)->startsWith('/')) { + $this->base_directory = '/'.$this->base_directory; + } + } + } + public function updatedBuildPack() { if ($this->build_pack === 'nixpacks') { @@ -261,6 +281,10 @@ public function submit() if ($this->build_pack === 'dockerfile' || $this->build_pack === 'dockerimage') { $application_init['health_check_enabled'] = false; } + if ($this->build_pack === 'dockercompose') { + $application_init['docker_compose_location'] = $this->docker_compose_location; + $application_init['base_directory'] = $this->base_directory; + } $application = Application::create($application_init); $application->settings->is_static = $this->is_static; 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 7635d3cec..e395d186e 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 @@ -62,6 +62,15 @@ class="loading loading-xs dark:text-warning loading-spinner"> @endif + @if ($build_pack === 'dockercompose') + + + Compose file location in your repository:{{ Str::start($base_directory . $docker_compose_location, '/') }} + @endif @if ($show_is_static)
diff --git a/resources/views/livewire/project/new/github-private-repository.blade.php b/resources/views/livewire/project/new/github-private-repository.blade.php index 0f4815bdb..b4ef1bdb1 100644 --- a/resources/views/livewire/project/new/github-private-repository.blade.php +++ b/resources/views/livewire/project/new/github-private-repository.blade.php @@ -14,7 +14,6 @@ @endif
Deploy any public or private Git repositories through a GitHub App.
- @if ($github_apps->count() !== 0)

Select a Github App

@@ -92,6 +91,16 @@ helper="If there is a build process involved (like Svelte, React, Next, etc..), please specify the output directory for the build assets." /> @endif
+ @if ($build_pack === 'dockercompose') + + + Compose file location in your repository:{{ Str::start($base_directory . $docker_compose_location, '/') }} + @endif @if ($show_is_static) 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 1bfe7c054..b9803d24f 100644 --- a/resources/views/livewire/project/new/public-git-repository.blade.php +++ b/resources/views/livewire/project/new/public-git-repository.blade.php @@ -13,10 +13,6 @@ @if (!$branch_found) @endif - @if ($build_pack === 'dockercompose' && isDev()) -
If you choose Docker Compose based deployments, you cannot change it afterwards.
- - @endif + {{-- @if ($build_pack === 'dockercompose' && isDev()) +
If you choose Docker Compose based deployments, you cannot + change it afterwards.
+ + @endif --}} Continue