improvement: add basedir + compose file in new compose based apps

This commit is contained in:
Andras Bacsai
2024-07-15 16:39:22 +02:00
parent 4ee1f1a507
commit 356e7b57d2
6 changed files with 88 additions and 9 deletions

View File

@@ -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 @@ class GithubPrivateRepository extends Component
$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 @@ class GithubPrivateRepository extends Component
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;

View File

@@ -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 @@ class GithubPrivateRepositoryDeployKey extends Component
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();

View File

@@ -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 @@ class PublicGitRepository extends Component
$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 @@ class PublicGitRepository extends Component
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;