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.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
feat: init postgresql database
Andras Bacsaia020bc872d74
diff --git a/app/Actions/Database/StartPostgresql.php b/app/Actions/Database/StartPostgresql.phpnew file mode 100644index 0000000000..d9f2c88469--- /dev/null+++ b/app/Actions/Database/StartPostgresql.php@@ -0,0 +1,25 @@+<?php++namespace App\Actions\Database;++use App\Models\Server;+use App\Models\StandaloneDocker;+use App\Models\Team;+use App\Models\Postgresql;++class StartPostgresql+{+ public function __invoke(Server $server, Postgresql $database)+ {+ $activity = remote_process([+ "echo 'Creating required Docker networks...'",+ "echo 'Creating required Docker networks...'",+ "echo 'Creating required Docker networks...'",+ "sleep 4",+ "echo 'Creating required Docker networks...'",+ "echo 'Creating required Docker networks...'",++ ], $server);+ return $activity;+ }+}\ No newline at end of filediff --git a/app/Http/Controllers/ApplicationController.php b/app/Http/Controllers/ApplicationController.phpindex 9d49f6c522..84a6bc0ece 100644--- a/app/Http/Controllers/ApplicationController.php+++ b/app/Http/Controllers/ApplicationController.php@@ -84,4 +84,4 @@ class ApplicationController extends Controller'deployment_uuid' => $deploymentUuid,]);}-}+}\ No newline at end of filediff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.phpindex 60549c381c..a376729835 100644--- a/app/Http/Controllers/Controller.php+++ b/app/Http/Controllers/Controller.php@@ -43,7 +43,9 @@ class Controller extends BaseController$s3s = S3Storage::ownedByCurrentTeam()->get();$resources = 0;foreach ($projects as $project) {+ ray($project->postgresqls);$resources += $project->applications->count();+ $resources += $project->postgresqls->count();}return view('dashboard', [diff --git a/app/Http/Controllers/DatabaseController.php b/app/Http/Controllers/DatabaseController.phpnew file mode 100644index 0000000000..7adb53f1fe--- /dev/null+++ b/app/Http/Controllers/DatabaseController.php@@ -0,0 +1,30 @@+<?php++namespace App\Http\Controllers;++use App\Models\ApplicationDeploymentQueue;+use Illuminate\Foundation\Auth\Access\AuthorizesRequests;+use Illuminate\Foundation\Validation\ValidatesRequests;+use Illuminate\Http\Request;+use Spatie\Activitylog\Models\Activity;++class DatabaseController extends Controller+{+ use AuthorizesRequests, ValidatesRequests;+ public function configuration()+ {+ $project = session('currentTeam')->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();+ if (!$project) {+ return redirect()->route('dashboard');+ }+ $environment = $project->load(['environments'])->environments->where('name', request()->route('environment_name'))->first()->load(['applications']);+ if (!$environment) {+ return redirect()->route('dashboard');+ }+ $database = $environment->databases->where('uuid', request()->route('database_uuid'))->first();+ if (!$database) {+ return redirect()->route('dashboard');+ }+ return view('project.database.configuration', ['database' => $database]);+ }+}\ No newline at end of filediff --git a/app/Http/Livewire/ActivityMonitor.php b/app/Http/Livewire/ActivityMonitor.phpindex 4352b9dc94..b11bcdb383 100644--- a/app/Http/Livewire/ActivityMonitor.php+++ b/app/Http/Livewire/ActivityMonitor.php@@ -51,4 +51,4 @@ class ActivityMonitor extends Component]);$this->activity->save();}-}+}\ No newline at end of filediff --git a/app/Http/Livewire/S3Test.php b/app/Http/Livewire/Dev/S3Test.phpsimilarity index 94%rename from app/Http/Livewire/S3Test.phprename to app/Http/Livewire/Dev/S3Test.phpindex 57ef3728e8..7aaf732bc8 100644--- a/app/Http/Livewire/S3Test.php+++ b/app/Http/Livewire/Dev/S3Test.php@@ -1,6 +1,6 @@<?php-namespace App\Http\Livewire;+namespace App\Http\Livewire\Dev;use App\Models\S3Storage;use Illuminate\Support\Facades\Storage;@@ -14,7 +14,6 @@ class S3Test extends Componentpublic $file;public function mount() {$this->s3 = S3Storage::first();- ray($this->s3);}public function save() {try {diff --git a/app/Http/Livewire/Project/Application/General.php b/app/Http/Livewire/Project/Application/General.phpindex f632a4431a..2d15489fb6 100644--- a/app/Http/Livewire/Project/Application/General.php+++ b/app/Http/Livewire/Project/Application/General.php@@ -33,6 +33,7 @@ class General extends Componentprotected $rules = ['application.name' => 'required',+ 'application.description' => 'nullable','application.fqdn' => 'nullable','application.git_repository' => 'required','application.git_branch' => 'required',@@ -49,6 +50,7 @@ class General extends Component];protected $validationAttributes = ['application.name' => 'name',+ 'application.description' => 'description','application.fqdn' => 'FQDN','application.git_repository' => 'Git repository','application.git_branch' => 'Git branch',diff --git a/app/Http/Livewire/Application/Heading.php b/app/Http/Livewire/Project/Application/Heading.phpsimilarity index 97%rename from app/Http/Livewire/Application/Heading.phprename to app/Http/Livewire/Project/Application/Heading.phpindex b062862b58..8a52061efe 100644--- a/app/Http/Livewire/Application/Heading.php+++ b/app/Http/Livewire/Project/Application/Heading.php@@ -1,6 +1,6 @@<?php-namespace App\Http\Livewire\Application;+namespace App\Http\Livewire\Project\Application;use App\Jobs\ApplicationContainerStatusJob;use App\Models\Application;diff --git a/app/Http/Livewire/Project/Database/Heading.php b/app/Http/Livewire/Project/Database/Heading.phpnew file mode 100644index 0000000000..8b653bc0a9--- /dev/null+++ b/app/Http/Livewire/Project/Database/Heading.php@@ -0,0 +1,23 @@+<?php++namespace App\Http\Livewire\Project\Database;++use Livewire\Component;+use App\Actions\Database\StartPostgresql;++class Heading extends Component+{+ public $database;+ public array $parameters;++ public function mount()+ {+ $this->parameters = getRouteParameters();+ }+ public function start() {+ if ($this->database->type() === 'postgresql') {+ $activity = resolve(StartPostgresql::class)($this->database->destination->server, $this->database);+ $this->emit('newMonitorActivity', $activity->id);+ }+ }+}\ No newline at end of filediff --git a/app/Http/Livewire/Project/Database/Postgresql/General.php b/app/Http/Livewire/Project/Database/Postgresql/General.phpnew file mode 100644index 0000000000..b3e2faa992--- /dev/null+++ b/app/Http/Livewire/Project/Database/Postgresql/General.php@@ -0,0 +1,39 @@+<?php++namespace App\Http\Livewire\Project\Database\Postgresql;++use Livewire\Component;++class General extends Component+{+ public $database;+ protected $rules = [+ 'database.name' => 'required',+ 'database.description' => 'nullable',+ 'database.postgres_user' => 'required',+ 'database.postgres_password' => 'required',+ 'database.postgres_db' => 'required',+ 'database.postgres_initdb_args' => 'nullable',+ 'database.postgres_host_auth_method' => 'nullable',+ 'database.init_scripts' => 'nullable',+ ];+ protected $validationAttributes = [+ 'database.name' => 'Name',+ 'database.description' => 'Description',+ 'database.postgres_user' => 'Postgres User',+ 'database.postgres_password' => 'Postgres Password',+ 'database.postgres_db' => 'Postgres DB',+ 'database.postgres_initdb_args' => 'Postgres Initdb Args',+ 'database.postgres_host_auth_method' => 'Postgres Host Auth Method',+ 'database.init_scripts' => 'Init Scripts',+ ];+ public function submit() {+ try {+ $this->validate();+ $this->database->save();+ $this->emit('success', 'Database updated successfully.');+ } catch (\Exception $e) {+ return general_error_handler(err: $e, that: $this);+ }+ }+}\ No newline at end of filediff --git a/app/Models/Environment.php b/app/Models/Environment.phpindex c79472e88e..e7139a5bdb 100644--- a/app/Models/Environment.php+++ b/app/Models/Environment.php@@ -17,6 +17,12 @@ class Environment extends Modelset: fn (string $value) => strtolower($value),);}+ public function can_delete_environment() {+ return $this->applications()->count() == 0 && $this->postgresqls()->count() == 0;+ }+ public function databases() {+ return $this->postgresqls();+ }public function project(){return $this->belongsTo(Project::class);@@ -25,12 +31,12 @@ class Environment extends Model{return $this->hasMany(Application::class);}- public function databases()+ public function postgresqls(){- return $this->hasMany(Database::class);+ return $this->hasMany(Postgresql::class);}public function services(){return $this->hasMany(Service::class);}-}+}\ No newline at end of filediff --git a/app/Models/Postgresql.php b/app/Models/Postgresql.phpnew file mode 100644index 0000000000..10e536685f--- /dev/null+++ b/app/Models/Postgresql.php@@ -0,0 +1,25 @@+<?php++namespace App\Models;++use Illuminate\Database\Eloquent\Factories\HasFactory;++class Postgresql extends BaseModel+{+ use HasFactory;+ protected $guarded = [];+ protected $casts = [+ 'postgres_password' => 'encrypted',+ ];+ public function type() {+ return 'postgresql';+ }+ public function environment()+ {+ return $this->belongsTo(Environment::class);+ }+ public function destination()+ {+ return $this->morphTo();+ }+}\ No newline at end of filediff --git a/app/Models/Project.php b/app/Models/Project.phpindex a0a3427552..791b8a7cc7 100644--- a/app/Models/Project.php+++ b/app/Models/Project.php@@ -46,4 +46,8 @@ class Project extends BaseModel{return $this->hasManyThrough(Application::class, Environment::class);}-}+ public function postgresqls()+ {+ return $this->hasManyThrough(Postgresql::class, Environment::class);+ }+}\ No newline at end of filediff --git a/app/Models/S3Storage.php b/app/Models/S3Storage.phpindex 46fc377838..a6f6360ac6 100644--- a/app/Models/S3Storage.php+++ b/app/Models/S3Storage.php@@ -8,6 +8,10 @@ class S3Storage extends BaseModel{use HasFactory;protected $guarded = [];+ protected $casts = [+ 'key' => 'encrypted',+ 'secret' => 'encrypted',+ ];static public function ownedByCurrentTeam(array $select = ['*']){diff --git a/app/Models/StandaloneDocker.php b/app/Models/StandaloneDocker.phpindex ea257dd603..e5f1cf3f3f 100644--- a/app/Models/StandaloneDocker.php+++ b/app/Models/StandaloneDocker.php@@ -13,9 +13,9 @@ class StandaloneDocker extends BaseModel{return $this->morphMany(Application::class, 'destination');}- public function databases()+ public function postgresqls(){- return $this->morphMany(Database::class, 'destination');+ return $this->morphMany(Postgresql::class, 'destination');}public function server(){@@ -25,4 +25,4 @@ class StandaloneDocker extends BaseModel{return $this->applications->count() > 0 || $this->databases->count() > 0;}-}+}\ No newline at end of filediff --git a/app/View/Components/Modal.php b/app/View/Components/Modal.phpindex b317d3c44a..22c5a7bba5 100644--- a/app/View/Components/Modal.php+++ b/app/View/Components/Modal.php@@ -14,7 +14,7 @@ class Modal extends Component*/public function __construct(public string $modalId,- public string $modalTitle,+ public string|null $modalTitle = null,public string|null $modalBody = null,public string|null $modalSubmit = null,public bool $yesOrNo = false,@@ -30,4 +30,4 @@ class Modal extends Component{return view('components.modal');}-}+}\ No newline at end of filediff --git a/database/migrations/2023_08_07_073651_create_s3_storages_table.php b/database/migrations/2023_08_07_073651_create_s3_storages_table.phpindex 711707e9ef..cdda367a22 100644--- a/database/migrations/2023_08_07_073651_create_s3_storages_table.php+++ b/database/migrations/2023_08_07_073651_create_s3_storages_table.php@@ -14,7 +14,7 @@ return new class extends MigrationSchema::create('s3_storages', function (Blueprint $table) {$table->id();$table->string('uuid')->unique();- $table->string('name')->nullable();+ $table->string('name');$table->longText('description')->nullable();$table->string('region')->default('us-east-1');$table->longText('key');diff --git a/database/migrations/2023_08_07_142950_create_postgresqls_table.php b/database/migrations/2023_08_07_142950_create_postgresqls_table.phpnew file mode 100644index 0000000000..8d126ce3e6--- /dev/null+++ b/database/migrations/2023_08_07_142950_create_postgresqls_table.php@@ -0,0 +1,42 @@+<?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::create('postgresqls', function (Blueprint $table) {+ $table->id();+ $table->string('uuid')->unique();+ $table->string('name');+ $table->string('description')->nullable();++ $table->string('postgres_user')->default('postgres');+ $table->string('postgres_password');+ $table->string('postgres_db')->default('postgres');+ $table->string('postgres_initdb_args')->nullable();+ $table->string('postgres_host_auth_method')->nullable();+ $table->json('init_scripts')->nullable();++ $table->timestamp('started_at')->nullable();+ $table->morphs('destination');++ $table->foreignId('environment_id');+ $table->timestamps();+ });+ }++ /**+ * Reverse the migrations.+ */+ public function down(): void+ {+ Schema::dropIfExists('postgresqls');+ }+};\ No newline at end of filediff --git a/database/migrations/2023_03_27_083620_create_databases_table.php b/database/migrations/2023_08_07_142951_add_description_field_to_applications_table.phpsimilarity index 51%rename from database/migrations/2023_03_27_083620_create_databases_table.phprename to database/migrations/2023_08_07_142951_add_description_field_to_applications_table.phpindex bfafb9c0c6..02d4c59354 100644--- a/database/migrations/2023_03_27_083620_create_databases_table.php+++ b/database/migrations/2023_08_07_142951_add_description_field_to_applications_table.php@@ -11,15 +11,8 @@ return new class extends Migration*/public function up(): void{- Schema::create('databases', function (Blueprint $table) {- $table->id();- $table->string('uuid')->unique();- $table->string('name');-- $table->morphs('destination');-- $table->foreignId('environment_id');- $table->timestamps();+ Schema::table('applications', function (Blueprint $table) {+ $table->string('description')->nullable();});}@@ -28,6 +21,8 @@ return new class extends Migration*/public function down(): void{- Schema::dropIfExists('databases');+ Schema::table('applications', function (Blueprint $table) {+ $table->dropColumn('description');+ });}-};+};\ No newline at end of filediff --git a/database/seeders/ApplicationSeeder.php b/database/seeders/ApplicationSeeder.phpindex 2859bed818..9cffe6fbe1 100644--- a/database/seeders/ApplicationSeeder.php+++ b/database/seeders/ApplicationSeeder.php@@ -19,13 +19,11 @@ class ApplicationSeeder extends Seeder*/public function run(): void{- $environment_1 = Environment::find(1);- $standalone_docker_1 = StandaloneDocker::find(1);-$github_public_source = GithubApp::where('name', 'Public GitHub')->first();Application::create(['name' => 'coollabsio/coolify-examples:nodejs-fastify',+ 'description' => 'NodeJS Fastify Example','fqdn' => 'http://foo.com','repository_project_id' => 603035348,'git_repository' => 'coollabsio/coolify-examples',@@ -33,11 +31,11 @@ class ApplicationSeeder extends Seeder'build_pack' => 'nixpacks','ports_exposes' => '3000','ports_mappings' => '3000:3000',- 'environment_id' => $environment_1->id,- 'destination_id' => $standalone_docker_1->id,+ 'environment_id' => 1,+ 'destination_id' => 1,'destination_type' => StandaloneDocker::class,'source_id' => $github_public_source->id,'source_type' => GithubApp::class]);}-}+}\ No newline at end of filediff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.phpindex bba3978ac4..7fa45e6b86 100644--- a/database/seeders/DatabaseSeeder.php+++ b/database/seeders/DatabaseSeeder.php@@ -32,6 +32,7 @@ class DatabaseSeeder extends SeederEnvironmentVariableSeeder::class,LocalPersistentVolumeSeeder::class,S3StorageSeeder::class,+ PostgresqlSeeder::class,]);}}\ No newline at end of filediff --git a/database/seeders/PostgresqlSeeder.php b/database/seeders/PostgresqlSeeder.phpnew file mode 100644index 0000000000..2568feb106--- /dev/null+++ b/database/seeders/PostgresqlSeeder.php@@ -0,0 +1,26 @@+<?php++namespace Database\Seeders;++use Illuminate\Database\Console\Seeds\WithoutModelEvents;+use Illuminate\Database\Seeder;+use App\Models\Postgresql;+use App\Models\StandaloneDocker;++class PostgresqlSeeder extends Seeder+{+ /**+ * Run the database seeds.+ */+ public function run(): void+ {+ Postgresql::create([+ 'name' => 'Local PostgreSQL',+ 'description' => 'Local PostgreSQL for testing',+ 'postgres_password' => 'postgres',+ 'environment_id' => 1,+ 'destination_id' => 1,+ 'destination_type' => StandaloneDocker::class,+ ]);+ }+}\ No newline at end of filediff --git a/resources/views/components/databases/navbar.blade.php b/resources/views/components/databases/navbar.blade.phpnew file mode 100644index 0000000000..fc8e7b68a9--- /dev/null+++ b/resources/views/components/databases/navbar.blade.php@@ -0,0 +1,41 @@+<div class="navbar-main">+ <a class="{{ request()->routeIs('project.database.configuration') ? 'text-white' : '' }}"+ href="{{ route('project.database.configuration', $parameters) }}">+ <button>Configuration</button>+ </a>+ {{-- <x-applications.links :application="$application" /> --}}+ <div class="flex-1"></div>+ {{-- <x-applications.advanced :application="$application" /> --}}++ @if ($database->status === 'running')+ <button wire:click='start' class="flex items-center gap-2 cursor-pointer hover:text-white text-neutral-400">+ <svg xmlns="http://www.w3.org/2000/svg" class="w-5 h-5 text-warning" viewBox="0 0 24 24" stroke-width="2"+ stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">+ <path stroke="none" d="M0 0h24v24H0z" fill="none"></path>+ <path+ d="M10.09 4.01l.496 -.495a2 2 0 0 1 2.828 0l7.071 7.07a2 2 0 0 1 0 2.83l-7.07 7.07a2 2 0 0 1 -2.83 0l-7.07 -7.07a2 2 0 0 1 0 -2.83l3.535 -3.535h-3.988">+ </path>+ <path d="M7.05 11.038v-3.988"></path>+ </svg>+ Restart+ </button>+ <button wire:click='stop' class="flex items-center gap-2 cursor-pointer hover:text-white text-neutral-400">+ <svg xmlns="http://www.w3.org/2000/svg" class="w-5 h-5 text-error" viewBox="0 0 24 24" stroke-width="2"+ stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">+ <path stroke="none" d="M0 0h24v24H0z" fill="none"></path>+ <path d="M6 5m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v12a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"></path>+ <path d="M14 5m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v12a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"></path>+ </svg>+ Stop+ </button>+ @else+ <button wire:click='start' onclick="logs.showModal()"+ class="flex items-center gap-2 cursor-pointer hover:text-white text-neutral-400">+ <svg xmlns="http://www.w3.org/2000/svg" class="w-5 h-5 text-warning" viewBox="0 0 24 24" stroke-width="1.5"+ stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">+ <path stroke="none" d="M0 0h24v24H0z" fill="none" />+ <path d="M7 4v16l13 -8z" />+ </svg>Start+ </button>+ @endif+</div>diff --git a/resources/views/components/modal.blade.php b/resources/views/components/modal.blade.phpindex 052c2b9433..7115154379 100644--- a/resources/views/components/modal.blade.php+++ b/resources/views/components/modal.blade.php@@ -10,7 +10,9 @@</svg></div><div class="flex flex-col w-full gap-2">- <h3 class="text-lg font-bold">{{ $modalTitle }}</h3>+ @isset($modalTitle)+ <h3 class="text-lg font-bold">{{ $modalTitle }}</h3>+ @endisset@isset($modalBody){{ $modalBody }}@endisset@@ -31,8 +33,11 @@</div></form>@else- <form method="dialog" class="flex flex-col gap-2 rounded modal-box" wire:submit.prevent='submit'>- <h3 class="text-lg font-bold">{{ $modalTitle }}</h3>+ <form method="dialog" class="flex flex-col w-11/12 max-w-5xl gap-2 rounded modal-box"+ wire:submit.prevent='submit'>+ @isset($modalTitle)+ <h3 class="text-lg font-bold">{{ $modalTitle }}</h3>+ @endisset@isset($modalBody){{ $modalBody }}@endissetdiff --git a/resources/views/components/applications/breadcrumbs.blade.php b/resources/views/components/resources/breadcrumbs.blade.phpsimilarity index 91%rename from resources/views/components/applications/breadcrumbs.blade.phprename to resources/views/components/resources/breadcrumbs.blade.phpindex b707d118e8..4bba9677e2 100644--- a/resources/views/components/applications/breadcrumbs.blade.php+++ b/resources/views/components/resources/breadcrumbs.blade.php@@ -3,7 +3,7 @@<li class="inline-flex items-center"><a class="text-xs truncate lg:text-sm"href="{{ route('project.show', ['project_uuid' => $this->parameters['project_uuid']]) }}">- {{ $application->environment->project->name }}</a>+ {{ $resource->environment->project->name }}</a></li><li><div class="flex items-center">@@ -25,7 +25,7 @@d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z"clip-rule="evenodd"></path></svg>- <span class="text-xs truncate lg:text-sm">{{ data_get($application, 'name') }}</span>+ <span class="text-xs truncate lg:text-sm">{{ data_get($resource, 'name') }}</span></div></li><li>@@ -38,9 +38,9 @@</svg></div></li>- @if ($application->status === 'running')+ @if ($resource->status === 'running')<x-status.running />- @elseif($application->status === 'restarting')+ @elseif($resource->status === 'restarting')<x-status.restarting />@else<x-status.stopped />diff --git a/resources/views/dashboard.blade.php b/resources/views/dashboard.blade.phpindex 609f487cd5..17a1435aff 100644--- a/resources/views/dashboard.blade.php+++ b/resources/views/dashboard.blade.php@@ -23,6 +23,6 @@</div></div>@if (isDev())- <livewire:s3-test />+ <livewire:dev.s3-test />@endif</x-layout>diff --git a/resources/views/livewire/s3-test.blade.php b/resources/views/livewire/dev/s3-test.blade.phpsimilarity index 100%rename from resources/views/livewire/s3-test.blade.phprename to resources/views/livewire/dev/s3-test.blade.phpdiff --git a/resources/views/livewire/project/application/general.blade.php b/resources/views/livewire/project/application/general.blade.phpindex 76bb140b22..614446478a 100644--- a/resources/views/livewire/project/application/general.blade.php+++ b/resources/views/livewire/project/application/general.blade.php@@ -10,21 +10,22 @@<div class="flex flex-col gap-2 py-4"><div class="flex flex-col items-end gap-2 xl:flex-row"><x-forms.input id="application.name" label="Name" required />- <x-forms.input placeholder="https://coolify.io" id="application.fqdn" label="Domains"- helper="You can specify one domain with path or more with comma.<br><span class='text-helper'>Example</span>- http://app.coolify.io, https://cloud.coolify.io/dashboard<br>- http://app.coolify.io/api/v3" />- @if ($wildcard_domain)- <div class="flex flex-row gap-2">- @if ($global_wildcard_domain)- <x-forms.button wire:click="generateGlobalRandomDomain">Set Global Wildcard- </x-forms.button>- @endif- @if ($server_wildcard_domain)- <x-forms.button wire:click="generateServerRandomDomain">Set Server Wildcard- </x-forms.button>- @endif- </div>- @endif+ <x-forms.input id="application.description" label="Description" /></div>+ <x-forms.input placeholder="https://coolify.io" id="application.fqdn" label="Domains"+ helper="You can specify one domain with path or more with comma.<br><span class='text-helper'>Example</span>- http://app.coolify.io, https://cloud.coolify.io/dashboard<br>- http://app.coolify.io/api/v3" />+ @if ($wildcard_domain)+ <div class="flex flex-row gap-2">+ @if ($global_wildcard_domain)+ <x-forms.button wire:click="generateGlobalRandomDomain">Set Global Wildcard+ </x-forms.button>+ @endif+ @if ($server_wildcard_domain)+ <x-forms.button wire:click="generateServerRandomDomain">Set Server Wildcard+ </x-forms.button>+ @endif+ </div>+ @endif<x-forms.select id="application.build_pack" label="Build Pack" required><option value="nixpacks">Nixpacks</option><option disabled value="docker">Docker</option>diff --git a/resources/views/livewire/application/heading.blade.php b/resources/views/livewire/project/application/heading.blade.phpsimilarity index 63%rename from resources/views/livewire/application/heading.blade.phprename to resources/views/livewire/project/application/heading.blade.phpindex c3d33543e4..ca76d38e81 100644--- a/resources/views/livewire/application/heading.blade.php+++ b/resources/views/livewire/project/application/heading.blade.php@@ -1,4 +1,4 @@<nav x-init="$wire.check_status" wire:poll.10000ms="check_status">- <x-applications.breadcrumbs :application="$application" :parameters="$parameters" />+ <x-resources.breadcrumbs :resource="$application" :parameters="$parameters" /><x-applications.navbar :application="$application" :parameters="$parameters" /></nav>diff --git a/resources/views/livewire/project/database/heading.blade.php b/resources/views/livewire/project/database/heading.blade.phpnew file mode 100644index 0000000000..e1f51c332f--- /dev/null+++ b/resources/views/livewire/project/database/heading.blade.php@@ -0,0 +1,4 @@+<nav>+ <x-resources.breadcrumbs :resource="$database" :parameters="$parameters" />+ <x-databases.navbar :database="$database" :parameters="$parameters" />+</nav>diff --git a/resources/views/livewire/project/database/postgresql/general.blade.php b/resources/views/livewire/project/database/postgresql/general.blade.phpnew file mode 100644index 0000000000..283fe7d475--- /dev/null+++ b/resources/views/livewire/project/database/postgresql/general.blade.php@@ -0,0 +1,18 @@+<div>+ <form wire:submit.prevent="submit">+ <div class="flex items-center gap-2">+ <h2>General</h2>+ <x-forms.button type="submit">+ Save+ </x-forms.button>+ </div>+ <x-forms.input label="Name" id="database.name" />+ <x-forms.input label="Description" id="database.description" />+ <x-forms.input label="Username" id="database.postgres_username" placeholder="If empty, use postgres." />+ <x-forms.input label="Password" id="database.postgres_password" type="password" />+ <x-forms.input label="Database" id="database.postgres_db" placeholder="If empty, use $USERNAME." />+ <x-forms.input label="Init Args" id="database.postgres_initdb_args" placeholder="If empty, use default." />+ <x-forms.input label="Host Auth Method" id="database.postgres_host_auth_method"+ placeholder="If empty, use default." />+ </form>+</div>diff --git a/resources/views/project/application/configuration.blade.php b/resources/views/project/application/configuration.blade.phpindex 73a9ff8059..d0c6e5cfa2 100644--- a/resources/views/project/application/configuration.blade.php+++ b/resources/views/project/application/configuration.blade.php@@ -1,6 +1,6 @@<x-layout><h1>Configuration</h1>- <livewire:application.heading :application="$application" />+ <livewire:project.application.heading :application="$application" /><div x-data="{ activeTab: window.location.hash ? window.location.hash.substring(1) : 'general' }" class="flex h-full pt-6"><div class="flex flex-col gap-4 min-w-fit"><a :class="activeTab === 'general' && 'text-white'"diff --git a/resources/views/project/application/deployment.blade.php b/resources/views/project/application/deployment.blade.phpindex 8f36eed2b2..0ed0d72b55 100644--- a/resources/views/project/application/deployment.blade.php+++ b/resources/views/project/application/deployment.blade.php@@ -1,5 +1,5 @@<x-layout><h1 class="py-0">Deployment</h1>- <livewire:application.heading :application="$application" />+ <livewire:project.application.heading :application="$application" /><livewire:project.application.deployment-logs :application_deployment_queue="$application_deployment_queue" /></x-layout>diff --git a/resources/views/project/application/deployments.blade.php b/resources/views/project/application/deployments.blade.phpindex b4fcd8982a..46d7316538 100644--- a/resources/views/project/application/deployments.blade.php+++ b/resources/views/project/application/deployments.blade.php@@ -1,5 +1,5 @@<x-layout><h1>Deployments</h1>- <livewire:application.heading :application="$application" />+ <livewire:project.application.heading :application="$application" /><livewire:project.application.deployments :application="$application" :deployments="$deployments" :deployments_count="$deployments_count" /></x-layout>diff --git a/resources/views/project/database.blade.php b/resources/views/project/database.blade.phpdeleted file mode 100644index f256fecb94..0000000000--- a/resources/views/project/database.blade.php+++ /dev/null@@ -1,5 +0,0 @@-<x-layout>- <h1>Database</h1>---</x-layout>diff --git a/resources/views/project/database/configuration.blade.php b/resources/views/project/database/configuration.blade.phpnew file mode 100644index 0000000000..ab75e76164--- /dev/null+++ b/resources/views/project/database/configuration.blade.php@@ -0,0 +1,65 @@+<x-layout>+ <h1>Configuration</h1>+ <livewire:project.database.heading :database="$database" />+ <x-modal modalId="logs">+ <x-slot:modalBody>+ <livewire:activity-monitor :header="true" />+ </x-slot:modalBody>+ <x-slot:modalSubmit>+ <x-forms.button onclick="logs.close()" type="submit">+ Close+ </x-forms.button>+ </x-slot:modalSubmit>+ </x-modal>+ <div x-data="{ activeTab: window.location.hash ? window.location.hash.substring(1) : 'general' }" class="flex h-full pt-6">+ <div class="flex flex-col gap-4 min-w-fit">+ <a :class="activeTab === 'general' && 'text-white'"+ @click.prevent="activeTab = 'general'; window.location.hash = 'general'" href="#">General</a>+ <a :class="activeTab === 'environment-variables' && 'text-white'"+ @click.prevent="activeTab = 'environment-variables'; window.location.hash = 'environment-variables'"+ href="#">Environment+ Variables</a>+ <a :class="activeTab === 'source' && 'text-white'"+ @click.prevent="activeTab = 'source'; window.location.hash = 'source'" href="#">Source</a>+ <a :class="activeTab === 'destination' && 'text-white'"+ @click.prevent="activeTab = 'destination'; window.location.hash = 'destination'"+ href="#">Destination+ </a>+ <a :class="activeTab === 'storages' && 'text-white'"+ @click.prevent="activeTab = 'storages'; window.location.hash = 'storages'" href="#">Storages+ </a>+ <a :class="activeTab === 'resource-limits' && 'text-white'"+ @click.prevent="activeTab = 'resource-limits'; window.location.hash = 'resource-limits'"+ href="#">Resource Limits+ </a>+ <a :class="activeTab === 'danger' && 'text-white'"+ @click.prevent="activeTab = 'danger'; window.location.hash = 'danger'" href="#">Danger Zone+ </a>+ </div>+ <div class="w-full pl-8">+ <div x-cloak x-show="activeTab === 'general'" class="h-full">+ @if ($database->getMorphClass() === 'App\Models\Postgresql')+ <livewire:project.database.postgresql.general :database="$database" />+ @endif+ </div>+ <div x-cloak x-show="activeTab === 'environment-variables'">+ {{-- <livewire:project.application.environment-variable.all :application="$application" /> --}}+ </div>+ <div x-cloak x-show="activeTab === 'source'">+ {{-- <livewire:project.application.source :application="$application" /> --}}+ </div>+ <div x-cloak x-show="activeTab === 'destination'">+ {{-- <livewire:project.application.destination :destination="$application->destination" /> --}}+ </div>+ <div x-cloak x-show="activeTab === 'storages'">+ {{-- <livewire:project.application.storages.all :application="$application" /> --}}+ </div>+ <div x-cloak x-show="activeTab === 'resource-limits'">+ {{-- <livewire:project.application.resource-limits :application="$application" /> --}}+ </div>+ <div x-cloak x-show="activeTab === 'danger'">+ {{-- <livewire:project.application.danger :application="$application" /> --}}+ </div>+ </div>+ </div>+</x-layout>diff --git a/resources/views/project/resources.blade.php b/resources/views/project/resources.blade.phpindex 0c4060a00c..30e72bcc39 100644--- a/resources/views/project/resources.blade.php+++ b/resources/views/project/resources.blade.php@@ -5,7 +5,7 @@<a href="{{ route('project.resources.new', ['project_uuid' => request()->route('project_uuid'), 'environment_name' => request()->route('environment_name')]) }} "class="font-normal text-white normal-case border-none rounded hover:no-underline btn btn-primary btn-sm no-animation">+Add</a>- @if ($environment->applications->count() === 0)+ @if ($environment->can_delete_environment())<livewire:project.delete-environment :environment_id="$environment->id" />@endif</div>@@ -31,14 +31,26 @@</ol></nav></div>- @if ($environment->applications->count() === 0)+ @if ($environment->can_delete_environment())<p>No resources found.</p>@endif<div class="grid gap-2 lg:grid-cols-2">@foreach ($environment->applications->sortBy('name') as $application)<a class="box"href="{{ route('project.application.configuration', [$project->uuid, $environment->name, $application->uuid]) }}">- {{ $application->name }}+ <div class="flex flex-col">+ <div>{{ $application->name }}</div>+ <div class="text-xs text-gray-400">{{ $application->description }}</div>+ </div>+ </a>+ @endforeach+ @foreach ($environment->databases->sortBy('name') as $databases)+ <a class="box"+ href="{{ route('project.database.configuration', [$project->uuid, $environment->name, $databases->uuid]) }}">+ <div class="flex flex-col">+ <div>{{ $databases->name }}</div>+ <div class="text-xs text-gray-400">{{ $databases->description }}</div>+ </div></a>@endforeach</div>diff --git a/routes/web.php b/routes/web.phpindex 91a4aa2ab8..d04c51d8f7 100644--- a/routes/web.php+++ b/routes/web.php@@ -1,6 +1,7 @@<?phpuse App\Http\Controllers\ApplicationController;+use App\Http\Controllers\DatabaseController;use App\Http\Controllers\Controller;use App\Http\Controllers\MagicController;use App\Http\Controllers\ProjectController;@@ -52,6 +53,7 @@ Route::middleware(['auth'])->group(function () {Route::get('/project/{project_uuid}/{environment_name}/new', [ProjectController::class, 'new'])->name('project.resources.new');Route::get('/project/{project_uuid}/{environment_name}', [ProjectController::class, 'resources'])->name('project.resources');Route::get('/project/{project_uuid}/{environment_name}/application/{application_uuid}', [ApplicationController::class, 'configuration'])->name('project.application.configuration');+ Route::get('/project/{project_uuid}/{environment_name}/database/{database_uuid}', [DatabaseController::class, 'configuration'])->name('project.database.configuration');Route::get('/project/{project_uuid}/{environment_name}/application/{application_uuid}/deployment', [ApplicationController::class, 'deployments'])->name('project.application.deployments');Route::get('/project/{project_uuid}/{environment_name}/application/{application_uuid}/deployment/{deployment_uuid}',