diff --git a/app/Livewire/Project/New/PublicGitRepository.php b/app/Livewire/Project/New/PublicGitRepository.php index f4f3008d4..802d6ccb2 100644 --- a/app/Livewire/Project/New/PublicGitRepository.php +++ b/app/Livewire/Project/New/PublicGitRepository.php @@ -6,6 +6,7 @@ use App\Models\GithubApp; use App\Models\GitlabApp; use App\Models\Project; +use App\Models\Service; use App\Models\StandaloneDocker; use App\Models\SwarmDocker; use Carbon\Carbon; @@ -33,6 +34,8 @@ class PublicGitRepository extends Component public $build_pack = 'nixpacks'; public bool $show_is_static = true; + public bool $new_compose_services = false; + protected $rules = [ 'repository_url' => 'required|url', 'port' => 'required|numeric', @@ -177,6 +180,31 @@ public function submit() $project = Project::where('uuid', $project_uuid)->first(); $environment = $project->load(['environments'])->environments->where('name', $environment_name)->first(); + if ($this->build_pack === 'dockercompose' && isDev() && $this->new_compose_services ) { + $server = $destination->server; + $new_service = [ + 'name' => 'service' . str()->random(10), + 'docker_compose_raw' => 'coolify', + 'environment_id' => $environment->id, + 'server_id' => $server->id, + ]; + if ($this->git_source === 'other') { + $new_service['git_repository'] = $this->git_repository; + $new_service['git_branch'] = $this->git_branch; + } else { + $new_service['git_repository'] = $this->git_repository; + $new_service['git_branch'] = $this->git_branch; + $new_service['source_id'] = $this->git_source->id; + $new_service['source_type'] = $this->git_source->getMorphClass(); + } + $service = Service::create($new_service); + return redirect()->route('project.service.configuration', [ + 'service_uuid' => $service->uuid, + 'environment_name' => $environment->name, + 'project_uuid' => $project->uuid, + ]); + return; + } if ($this->git_source === 'other') { $application_init = [ 'name' => generate_random_name(), diff --git a/database/migrations/2024_06_07_151615_add_git_to_services.php b/database/migrations/2024_06_07_151615_add_git_to_services.php new file mode 100644 index 000000000..77d952734 --- /dev/null +++ b/database/migrations/2024_06_07_151615_add_git_to_services.php @@ -0,0 +1,32 @@ +string('git_repository')->nullable(); + $table->string('git_branch')->nullable(); + $table->nullableMorphs('source'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('services', function (Blueprint $table) { + $table->dropColumn('git_repository'); + $table->dropColumn('git_branch'); + $table->dropMorphs('source'); + }); + } +}; 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 62e2e05e6..1bfe7c054 100644 --- a/resources/views/livewire/project/new/public-git-repository.blade.php +++ b/resources/views/livewire/project/new/public-git-repository.blade.php @@ -5,7 +5,8 @@