Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

wip: new services based git apps

Andras Bacsaia20290cac8f9
diff --git a/app/Livewire/Project/New/PublicGitRepository.php b/app/Livewire/Project/New/PublicGitRepository.php
index f4f3008d4e..802d6ccb23 100644
--- a/app/Livewire/Project/New/PublicGitRepository.php
+++ b/app/Livewire/Project/New/PublicGitRepository.php
@@ -6,6 +6,7 @@ use App\Models\Application;
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 @@ class PublicGitRepository extends Component
$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 0000000000..77d9527348
--- /dev/null
+++ b/database/migrations/2024_06_07_151615_add_git_to_services.php
@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration
+{
+ /**
+ * Run the migrations.
+ */
+ public function up(): void
+ {
+ Schema::table('services', function (Blueprint $table) {
+ $table->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 62e2e05e6a..1bfe7c0549 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 @@
<div class="flex flex-col gap-2">
<div class="flex flex-col gap-2">
<div class="flex items-end gap-2">
- <x-forms.input required id="repository_url" label="Repository URL (https://)" helper="{!! __('repository.url') !!}" />
+ <x-forms.input required id="repository_url" label="Repository URL (https://)"
+ helper="{!! __('repository.url') !!}" />
<x-forms.button type="submit">
Check repository
</x-forms.button>
@@ -58,6 +59,10 @@
helper="If your application is a static site or the final build assets should be served as a static site, enable this." />
</div>
@endif
+ @if ($build_pack === 'dockercompose' && isDev())
+ <div class="dark:text-warning">If you choose Docker Compose based deployments, you cannot change it afterwards.</div>
+ <x-forms.checkbox instantSave label="New Compose Services (only in dev mode)" id="new_compose_services"></x-forms.checkbox>
+ @endif
</div>
<x-forms.button wire:click.prevent='submit'>
Continue