Skip to content

Commit 356e7b5

Browse files
committed
improvement: add basedir + compose file in new compose based apps
1 parent 4ee1f1a commit 356e7b5

File tree

6 files changed

+88
-9
lines changed

6 files changed

+88
-9
lines changed

app/Livewire/Project/New/GithubPrivateRepository.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ class GithubPrivateRepository extends Component
5353

5454
public ?string $publish_directory = null;
5555

56+
// In case of docker compose
57+
public ?string $base_directory = null;
58+
59+
public ?string $docker_compose_location = '/docker-compose.yaml';
60+
// End of docker compose
61+
5662
protected int $page = 1;
5763

5864
public $build_pack = 'nixpacks';
@@ -68,6 +74,16 @@ public function mount()
6874
$this->github_apps = GithubApp::private();
6975
}
7076

77+
public function updatedBaseDirectory()
78+
{
79+
if ($this->base_directory) {
80+
$this->base_directory = rtrim($this->base_directory, '/');
81+
if (! str($this->base_directory)->startsWith('/')) {
82+
$this->base_directory = '/'.$this->base_directory;
83+
}
84+
}
85+
}
86+
7187
public function updatedBuildPack()
7288
{
7389
if ($this->build_pack === 'nixpacks') {
@@ -184,6 +200,10 @@ public function submit()
184200
if ($this->build_pack === 'dockerfile' || $this->build_pack === 'dockerimage') {
185201
$application->health_check_enabled = false;
186202
}
203+
if ($this->build_pack === 'dockercompose') {
204+
$application['docker_compose_location'] = $this->docker_compose_location;
205+
$application['base_directory'] = $this->base_directory;
206+
}
187207
$fqdn = generateFqdn($destination->server, $application->uuid);
188208
$application->fqdn = $fqdn;
189209

app/Livewire/Project/New/GithubPrivateRepositoryDeployKey.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ class GithubPrivateRepositoryDeployKey extends Component
3333

3434
public ?string $publish_directory = null;
3535

36+
// In case of docker compose
37+
public ?string $base_directory = null;
38+
39+
public ?string $docker_compose_location = '/docker-compose.yaml';
40+
// End of docker compose
41+
3642
public string $repository_url;
3743

3844
public string $branch;
@@ -163,6 +169,10 @@ public function submit()
163169
if ($this->build_pack === 'dockerfile' || $this->build_pack === 'dockerimage') {
164170
$application_init['health_check_enabled'] = false;
165171
}
172+
if ($this->build_pack === 'dockercompose') {
173+
$application_init['docker_compose_location'] = $this->docker_compose_location;
174+
$application_init['base_directory'] = $this->base_directory;
175+
}
166176
$application = Application::create($application_init);
167177
$application->settings->is_static = $this->is_static;
168178
$application->settings->save();

app/Livewire/Project/New/PublicGitRepository.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ class PublicGitRepository extends Component
3333

3434
public ?string $publish_directory = null;
3535

36+
// In case of docker compose
37+
public ?string $base_directory = null;
38+
39+
public ?string $docker_compose_location = '/docker-compose.yaml';
40+
// End of docker compose
41+
3642
public string $git_branch = 'main';
3743

3844
public int $rate_limit_remaining = 0;
@@ -59,6 +65,8 @@ class PublicGitRepository extends Component
5965
'is_static' => 'required|boolean',
6066
'publish_directory' => 'nullable|string',
6167
'build_pack' => 'required|string',
68+
'base_directory' => 'nullable|string',
69+
'docker_compose_location' => 'nullable|string',
6270
];
6371

6472
protected $validationAttributes = [
@@ -67,6 +75,8 @@ class PublicGitRepository extends Component
6775
'is_static' => 'static',
6876
'publish_directory' => 'publish directory',
6977
'build_pack' => 'build pack',
78+
'base_directory' => 'base directory',
79+
'docker_compose_location' => 'docker compose location',
7080
];
7181

7282
public function mount()
@@ -79,6 +89,16 @@ public function mount()
7989
$this->query = request()->query();
8090
}
8191

92+
public function updatedBaseDirectory()
93+
{
94+
if ($this->base_directory) {
95+
$this->base_directory = rtrim($this->base_directory, '/');
96+
if (! str($this->base_directory)->startsWith('/')) {
97+
$this->base_directory = '/'.$this->base_directory;
98+
}
99+
}
100+
}
101+
82102
public function updatedBuildPack()
83103
{
84104
if ($this->build_pack === 'nixpacks') {
@@ -261,6 +281,10 @@ public function submit()
261281
if ($this->build_pack === 'dockerfile' || $this->build_pack === 'dockerimage') {
262282
$application_init['health_check_enabled'] = false;
263283
}
284+
if ($this->build_pack === 'dockercompose') {
285+
$application_init['docker_compose_location'] = $this->docker_compose_location;
286+
$application_init['base_directory'] = $this->base_directory;
287+
}
264288
$application = Application::create($application_init);
265289

266290
$application->settings->is_static = $this->is_static;

resources/views/livewire/project/new/github-private-repository-deploy-key.blade.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,15 @@ class="loading loading-xs dark:text-warning loading-spinner"></span>
6262
<x-forms.input id="publish_directory" required label="Publish Directory" />
6363
@endif
6464
</div>
65+
@if ($build_pack === 'dockercompose')
66+
<x-forms.input placeholder="/" wire:model.blur="base_directory" label="Base Directory"
67+
helper="Directory to use as root. Useful for monorepos." />
68+
<x-forms.input placeholder="/docker-compose.yaml" id="docker_compose_location"
69+
label="Docker Compose Location"
70+
helper="It is calculated together with the Base Directory:<br><span class='dark:text-warning'>{{ Str::start($base_directory . $docker_compose_location, '/') }}</span>" />
71+
Compose file location in your repository:<span
72+
class='dark:text-warning'>{{ Str::start($base_directory . $docker_compose_location, '/') }}</span>
73+
@endif
6574
@if ($show_is_static)
6675
<x-forms.input type="number" required id="port" label="Port" :readonly="$is_static || $build_pack === 'static'" />
6776
<div class="w-52">

resources/views/livewire/project/new/github-private-repository.blade.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
@endif
1515
</div>
1616
<div class="pb-4">Deploy any public or private Git repositories through a GitHub App.</div>
17-
1817
@if ($github_apps->count() !== 0)
1918
<h2 class="pt-4 pb-4">Select a Github App</h2>
2019
<div class="flex flex-col gap-2">
@@ -92,6 +91,16 @@
9291
helper="If there is a build process involved (like Svelte, React, Next, etc..), please specify the output directory for the build assets." />
9392
@endif
9493
</div>
94+
@if ($build_pack === 'dockercompose')
95+
<x-forms.input placeholder="/" wire:model.blur="base_directory"
96+
label="Base Directory"
97+
helper="Directory to use as root. Useful for monorepos." />
98+
<x-forms.input placeholder="/docker-compose.yaml" id="docker_compose_location"
99+
label="Docker Compose Location"
100+
helper="It is calculated together with the Base Directory:<br><span class='dark:text-warning'>{{ Str::start($base_directory . $docker_compose_location, '/') }}</span>" />
101+
Compose file location in your repository:<span
102+
class='dark:text-warning'>{{ Str::start($base_directory . $docker_compose_location, '/') }}</span>
103+
@endif
95104
@if ($show_is_static)
96105
<x-forms.input type="number" id="port" label="Port" :readonly="$is_static || $build_pack === 'static'"
97106
helper="The port your application listens on." />

resources/views/livewire/project/new/public-git-repository.blade.php

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@
1313
</div>
1414
@if (!$branch_found)
1515
<div class="px-2 pt-4">
16-
<div class="flex flex-col pb-4">
17-
<div>Preselect branch (eg: main):</div>
18-
<div class='text-helper'>https://github.com/coollabsio/coolify-examples/tree/main</div>
19-
</div>
2016
<div>
2117
For example application deployments, checkout <a class="underline dark:text-white"
2218
href="https://github.com/coollabsio/coolify-examples/" target="_blank">Coolify
@@ -51,6 +47,15 @@
5147
helper="If there is a build process involved (like Svelte, React, Next, etc..), please specify the output directory for the build assets." />
5248
@endif
5349
</div>
50+
@if ($build_pack === 'dockercompose')
51+
<x-forms.input placeholder="/" wire:model.blur="base_directory" label="Base Directory"
52+
helper="Directory to use as root. Useful for monorepos." />
53+
<x-forms.input placeholder="/docker-compose.yaml" id="docker_compose_location"
54+
label="Docker Compose Location"
55+
helper="It is calculated together with the Base Directory:<br><span class='dark:text-warning'>{{ Str::start($base_directory . $docker_compose_location, '/') }}</span>" />
56+
Compose file location in your repository:<span
57+
class='dark:text-warning'>{{ Str::start($base_directory . $docker_compose_location, '/') }}</span>
58+
@endif
5459
@if ($show_is_static)
5560
<x-forms.input type="number" id="port" label="Port" :readonly="$is_static || $build_pack === 'static'"
5661
helper="The port your application listens on." />
@@ -59,10 +64,12 @@
5964
helper="If your application is a static site or the final build assets should be served as a static site, enable this." />
6065
</div>
6166
@endif
62-
@if ($build_pack === 'dockercompose' && isDev())
63-
<div class="dark:text-warning">If you choose Docker Compose based deployments, you cannot change it afterwards.</div>
64-
<x-forms.checkbox instantSave label="New Compose Services (only in dev mode)" id="new_compose_services"></x-forms.checkbox>
65-
@endif
67+
{{-- @if ($build_pack === 'dockercompose' && isDev())
68+
<div class="dark:text-warning">If you choose Docker Compose based deployments, you cannot
69+
change it afterwards.</div>
70+
<x-forms.checkbox instantSave label="New Compose Services (only in dev mode)"
71+
id="new_compose_services"></x-forms.checkbox>
72+
@endif --}}
6673
</div>
6774
<x-forms.button wire:click.prevent='submit'>
6875
Continue

0 commit comments

Comments
 (0)