updates
This commit is contained in:
@@ -21,7 +21,7 @@ class Deploy extends Component
|
||||
protected $source;
|
||||
|
||||
protected $listeners = [
|
||||
'applicationStatusChanged' => 'applicationStatusChanged',
|
||||
'applicationStatusChanged',
|
||||
];
|
||||
|
||||
public function mount()
|
||||
@@ -40,8 +40,12 @@ class Deploy extends Component
|
||||
$this->deployment_uuid = new Cuid2(7);
|
||||
$this->parameters['deployment_uuid'] = $this->deployment_uuid;
|
||||
}
|
||||
public function deploy(bool $force = false)
|
||||
public function deploy(bool $force = false, bool|null $debug = null)
|
||||
{
|
||||
if ($debug && !$this->application->settings->is_debug_enabled) {
|
||||
$this->application->settings->is_debug_enabled = true;
|
||||
$this->application->settings->save();
|
||||
}
|
||||
$this->set_deployment_uuid();
|
||||
|
||||
queue_application_deployment(
|
||||
@@ -62,5 +66,6 @@ class Deploy extends Component
|
||||
instant_remote_process(["docker rm -f {$this->application->uuid}"], $this->application->destination->server);
|
||||
$this->application->status = get_container_status(server: $this->application->destination->server, container_id: $this->application->uuid);
|
||||
$this->application->save();
|
||||
$this->emit('applicationStatusChanged');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,15 +2,12 @@
|
||||
|
||||
namespace App\Http\Livewire\Project\Application\EnvironmentVariable;
|
||||
|
||||
use App\Models\Application;
|
||||
use App\Models\EnvironmentVariable;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Livewire\Component;
|
||||
|
||||
class Add extends Component
|
||||
{
|
||||
public $parameters;
|
||||
public bool $is_preview = false;
|
||||
public string $key;
|
||||
public string $value;
|
||||
public bool $is_build_time = false;
|
||||
@@ -32,6 +29,7 @@ class Add extends Component
|
||||
'key' => $this->key,
|
||||
'value' => $this->value,
|
||||
'is_build_time' => $this->is_build_time,
|
||||
'is_preview' => $this->is_preview,
|
||||
]);
|
||||
}
|
||||
public function clear()
|
||||
|
||||
@@ -21,6 +21,7 @@ class All extends Component
|
||||
'key' => $data['key'],
|
||||
'value' => $data['value'],
|
||||
'is_build_time' => $data['is_build_time'],
|
||||
'is_preview' => $data['is_preview'],
|
||||
'application_id' => $this->application->id,
|
||||
]);
|
||||
$this->application->refresh();
|
||||
|
||||
@@ -11,7 +11,7 @@ class Status extends Component
|
||||
|
||||
public function applicationStatusChanged()
|
||||
{
|
||||
$this->emit('applicationStatusChanged');
|
||||
$this->application->refresh();
|
||||
$this->emit('applicationStatusChanged');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,16 +14,22 @@ use Spatie\Url\Url;
|
||||
class PublicGitRepository extends Component
|
||||
{
|
||||
public string $repository_url;
|
||||
private object $repository_url_parsed;
|
||||
|
||||
public int $port = 3000;
|
||||
public string $type;
|
||||
public $parameters;
|
||||
public $query;
|
||||
|
||||
public $github_apps;
|
||||
public $gitlab_apps;
|
||||
|
||||
public $branches = [];
|
||||
public string $selected_branch = 'main';
|
||||
public bool $is_static = false;
|
||||
public null|string $publish_directory = null;
|
||||
public string|null $publish_directory = null;
|
||||
|
||||
private GithubApp|GitlabApp $git_source;
|
||||
private string $git_host;
|
||||
private string $git_repository;
|
||||
private string $git_branch;
|
||||
|
||||
protected $rules = [
|
||||
'repository_url' => 'required|url',
|
||||
@@ -34,7 +40,7 @@ class PublicGitRepository extends Component
|
||||
public function mount()
|
||||
{
|
||||
if (config('app.env') === 'local') {
|
||||
$this->repository_url = 'https://github.com/coollabsio/coolify-examples/tree/nodejs-fastify';
|
||||
$this->repository_url = 'https://github.com/coollabsio/coolify-examples';
|
||||
$this->port = 3000;
|
||||
}
|
||||
$this->parameters = get_parameters();
|
||||
@@ -52,18 +58,43 @@ class PublicGitRepository extends Component
|
||||
}
|
||||
$this->emit('saved', 'Application settings updated!');
|
||||
}
|
||||
public function load_branches()
|
||||
{
|
||||
$this->get_git_source();
|
||||
|
||||
try {
|
||||
['data' => $data] = get_from_git_api($this->git_source, "/repos/{$this->git_repository}/branches");
|
||||
$this->branches = collect($data)->pluck('name')->toArray();
|
||||
} catch (\Throwable $th) {
|
||||
return general_error_handler($th, $this);
|
||||
}
|
||||
}
|
||||
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);
|
||||
$this->git_branch = $this->repository_url_parsed->getSegment(4) ?? 'main';
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
public function submit()
|
||||
{
|
||||
try {
|
||||
$this->validate();
|
||||
|
||||
$url = Url::fromString($this->repository_url);
|
||||
$git_host = $url->getHost();
|
||||
$git_repository = $url->getSegment(1) . '/' . $url->getSegment(2);
|
||||
$git_branch = $url->getSegment(4) ?? 'main';
|
||||
|
||||
$destination_uuid = $this->query['destination'];
|
||||
$project_uuid = $this->parameters['project_uuid'];
|
||||
$environment_name = $this->parameters['environment_name'];
|
||||
|
||||
$this->get_git_source();
|
||||
$this->git_branch = $this->selected_branch ?? $this->git_branch;
|
||||
|
||||
$destination = StandaloneDocker::where('uuid', $destination_uuid)->first();
|
||||
if (!$destination) {
|
||||
$destination = SwarmDocker::where('uuid', $destination_uuid)->first();
|
||||
@@ -73,29 +104,24 @@ class PublicGitRepository extends Component
|
||||
}
|
||||
$destination_class = $destination->getMorphClass();
|
||||
|
||||
$project = Project::where('uuid', $this->parameters['project_uuid'])->first();
|
||||
$environment = $project->load(['environments'])->environments->where('name', $this->parameters['environment_name'])->first();
|
||||
$project = Project::where('uuid', $project_uuid)->first();
|
||||
$environment = $project->load(['environments'])->environments->where('name', $environment_name)->first();
|
||||
|
||||
|
||||
$application_init = [
|
||||
'name' => generate_application_name($git_repository, $git_branch),
|
||||
'git_repository' => $git_repository,
|
||||
'git_branch' => $git_branch,
|
||||
'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 ($git_host == 'github.com') {
|
||||
$application_init['source_id'] = GithubApp::where('name', 'Public GitHub')->first()->id;
|
||||
$application_init['source_type'] = GithubApp::class;
|
||||
} elseif ($git_host == 'gitlab.com') {
|
||||
$application_init['source_id'] = GitlabApp::where('name', 'Public GitLab')->first()->id;
|
||||
$application_init['source_type'] = GitlabApp::class;
|
||||
} elseif ($git_host == 'bitbucket.org') {
|
||||
}
|
||||
|
||||
$application = Application::create($application_init);
|
||||
$application->settings->is_static = $this->is_static;
|
||||
$application->settings->save();
|
||||
@@ -106,7 +132,7 @@ class PublicGitRepository extends Component
|
||||
'application_uuid' => $application->uuid,
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return general_error_handler($e);
|
||||
return general_error_handler($e, $this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user