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.

add new public repo

Andras Bacsai6135c139da9f
diff --git a/app/Http/Controllers/ApplicationController.php b/app/Http/Controllers/ApplicationController.php
index e9584aad1a..3cc33c2033 100644
--- a/app/Http/Controllers/ApplicationController.php
+++ b/app/Http/Controllers/ApplicationController.php
@@ -11,15 +11,15 @@ class ApplicationController extends Controller
{
$project = session('currentTeam')->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
if (!$project) {
- return redirect()->route('home');
+ return redirect()->route('dashboard');
}
$environment = $project->load(['environments'])->environments->where('name', request()->route('environment_name'))->first()->load(['applications']);
if (!$environment) {
- return redirect()->route('home');
+ return redirect()->route('dashboard');
}
$application = $environment->applications->where('uuid', request()->route('application_uuid'))->first();
if (!$application) {
- return redirect()->route('home');
+ return redirect()->route('dashboard');
}
return view('project.application.configuration', ['application' => $application]);
}
@@ -27,15 +27,15 @@ class ApplicationController extends Controller
{
$project = session('currentTeam')->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
if (!$project) {
- return redirect()->route('home');
+ return redirect()->route('dashboard');
}
$environment = $project->load(['environments'])->environments->where('name', request()->route('environment_name'))->first()->load(['applications']);
if (!$environment) {
- return redirect()->route('home');
+ return redirect()->route('dashboard');
}
$application = $environment->applications->where('uuid', request()->route('application_uuid'))->first();
if (!$application) {
- return redirect()->route('home');
+ return redirect()->route('dashboard');
}
return view('project.application.deployments', ['application' => $application, 'deployments' => $application->deployments()]);
}
@@ -46,15 +46,15 @@ class ApplicationController extends Controller
$project = session('currentTeam')->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
if (!$project) {
- return redirect()->route('home');
+ return redirect()->route('dashboard');
}
$environment = $project->load(['environments'])->environments->where('name', request()->route('environment_name'))->first()->load(['applications']);
if (!$environment) {
- return redirect()->route('home');
+ return redirect()->route('dashboard');
}
$application = $environment->applications->where('uuid', request()->route('application_uuid'))->first();
if (!$application) {
- return redirect()->route('home');
+ return redirect()->route('dashboard');
}
$activity = Activity::where('properties->deployment_uuid', '=', $deployment_uuid)->first();
diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php
index 6ac9dc6118..710c10f830 100644
--- a/app/Http/Controllers/ProjectController.php
+++ b/app/Http/Controllers/ProjectController.php
@@ -10,7 +10,7 @@ class ProjectController extends Controller
{
$project = session('currentTeam')->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
if (!$project) {
- return redirect()->route('home');
+ return redirect()->route('dashboard');
}
$project->load(['environments']);
if (count($project->environments) == 1) {
@@ -23,11 +23,11 @@ class ProjectController extends Controller
{
$project = session('currentTeam')->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
if (!$project) {
- return redirect()->route('home');
+ return redirect()->route('dashboard');
}
$environment = $project->load(['environments'])->environments->where('name', request()->route('environment_name'))->first();
if (!$environment) {
- return redirect()->route('home');
+ return redirect()->route('dashboard');
}
return view('project.resources', ['project' => $project, 'environment' => $environment]);
}
@@ -36,15 +36,15 @@ class ProjectController extends Controller
{
$project = session('currentTeam')->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
if (!$project) {
- return redirect()->route('home');
+ return redirect()->route('dashboard');
}
$environment = $project->load(['environments'])->environments->where('name', request()->route('environment_name'))->first()->load(['applications']);
if (!$environment) {
- return redirect()->route('home');
+ return redirect()->route('dashboard');
}
$application = $environment->applications->where('uuid', request()->route('application_uuid'))->first();
if (!$application) {
- return redirect()->route('home');
+ return redirect()->route('dashboard');
}
return view('project.application.configuration', ['application' => $application]);
}
@@ -52,15 +52,15 @@ class ProjectController extends Controller
{
$project = session('currentTeam')->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
if (!$project) {
- return redirect()->route('home');
+ return redirect()->route('dashboard');
}
$environment = $project->load(['environments'])->environments->where('name', request()->route('environment_name'))->first()->load(['applications']);
if (!$environment) {
- return redirect()->route('home');
+ return redirect()->route('dashboard');
}
$application = $environment->applications->where('uuid', request()->route('application_uuid'))->first();
if (!$application) {
- return redirect()->route('home');
+ return redirect()->route('dashboard');
}
return view('project.application.deployments', ['application' => $application, 'deployments' => $application->deployments()]);
}
@@ -71,15 +71,15 @@ class ProjectController extends Controller
$project = session('currentTeam')->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
if (!$project) {
- return redirect()->route('home');
+ return redirect()->route('dashboard');
}
$environment = $project->load(['environments'])->environments->where('name', request()->route('environment_name'))->first()->load(['applications']);
if (!$environment) {
- return redirect()->route('home');
+ return redirect()->route('dashboard');
}
$application = $environment->applications->where('uuid', request()->route('application_uuid'))->first();
if (!$application) {
- return redirect()->route('home');
+ return redirect()->route('dashboard');
}
$activity = Activity::where('properties->deployment_uuid', '=', $deployment_uuid)->first();
diff --git a/app/Http/Livewire/Project/Application/Deploy.php b/app/Http/Livewire/Project/Application/Deploy.php
index 9a1263eda3..a8696e506e 100644
--- a/app/Http/Livewire/Project/Application/Deploy.php
+++ b/app/Http/Livewire/Project/Application/Deploy.php
@@ -24,7 +24,7 @@ class Deploy extends Component
public function mount()
{
$this->parameters = Route::current()->parameters();
- $this->application = Application::find($this->applicationId)->first();
+ $this->application = Application::where('id', $this->applicationId)->first();
$this->destination = $this->application->destination->getMorphClass()::where('id', $this->application->destination->id)->first();
}
protected function setDeploymentUuid()
diff --git a/app/Http/Livewire/Project/Application/General.php b/app/Http/Livewire/Project/Application/General.php
index 1bf6706ac3..e760eb9758 100644
--- a/app/Http/Livewire/Project/Application/General.php
+++ b/app/Http/Livewire/Project/Application/General.php
@@ -36,7 +36,8 @@ class General extends Component
'application.build_pack' => 'required',
'application.base_directory' => 'required',
'application.publish_directory' => 'nullable',
- 'application.ports_exposes' => 'nullable',
+ 'application.ports_exposes' => 'required',
+ 'application.ports_mappings' => 'nullable',
];
public function instantSave()
{
@@ -54,7 +55,7 @@ class General extends Component
}
public function mount()
{
- $this->application = Application::find($this->applicationId)->with('destination', 'settings')->first();
+ $this->application = Application::where('id', $this->applicationId)->with('destination', 'settings')->firstOrFail();
$this->is_git_submodules_allowed = $this->application->settings->is_git_submodules_allowed;
$this->is_git_lfs_allowed = $this->application->settings->is_git_lfs_allowed;
$this->is_debug = $this->application->settings->is_debug;
@@ -64,7 +65,6 @@ class General extends Component
$this->is_http2 = $this->application->settings->is_http2;
$this->is_auto_deploy = $this->application->settings->is_auto_deploy;
$this->is_dual_cert = $this->application->settings->is_dual_cert;
-
}
public function submit()
{
diff --git a/app/Http/Livewire/Project/Application/Source.php b/app/Http/Livewire/Project/Application/Source.php
index 16d7eeadcb..56d1c6e866 100644
--- a/app/Http/Livewire/Project/Application/Source.php
+++ b/app/Http/Livewire/Project/Application/Source.php
@@ -17,6 +17,6 @@ class Source extends Component
];
public function mount()
{
- $this->application = Application::find($this->applicationId)->first();
+ $this->application = Application::where('id', $this->applicationId)->first();
}
}
diff --git a/app/Http/Livewire/Project/New/PublicGitRepository.php b/app/Http/Livewire/Project/New/PublicGitRepository.php
new file mode 100644
index 0000000000..8433ee829f
--- /dev/null
+++ b/app/Http/Livewire/Project/New/PublicGitRepository.php
@@ -0,0 +1,90 @@
+<?php
+
+namespace App\Http\Livewire\Project\New;
+
+use App\Http\Livewire\Application\Destination;
+use App\Models\Application;
+use App\Models\Git;
+use App\Models\GithubApp;
+use App\Models\GitlabApp;
+use App\Models\Project;
+use App\Models\Server;
+use App\Models\StandaloneDocker;
+use App\Models\SwarmDocker;
+use Livewire\Component;
+use Spatie\Url\Url;
+
+class PublicGitRepository extends Component
+{
+ public string $public_repository_url;
+ public int $port;
+
+ public $servers;
+ public $standalone_docker;
+ public $swarm_docker;
+ public $chosenServer;
+ public $chosenDestination;
+ public $github_apps;
+ public $gitlab_apps;
+
+ protected $rules = [
+ 'public_repository_url' => 'required|url',
+ ];
+ public function mount()
+ {
+ if (env('APP_ENV') === 'local') {
+ $this->public_repository_url = 'https://github.com/coollabsio/coolify-examples/tree/nodejs-fastify';
+ $this->port = 3000;
+ }
+ $this->servers = session('currentTeam')->load(['servers'])->servers;
+ }
+ public function chooseServer($server_id)
+ {
+ $this->chosenServer = $server_id;
+ $this->standalone_docker = StandaloneDocker::where('server_id', $server_id)->get();
+ $this->swarm_docker = SwarmDocker::where('server_id', $server_id)->get();
+ }
+ public function setDestination($destination_uuid, $destination_type)
+ {
+ $class = "App\Models\\{$destination_type}";
+ $instance = new $class;
+ $this->chosenDestination = $instance::where('uuid', $destination_uuid)->first();
+ }
+
+ public function submit()
+ {
+ $this->validate();
+
+ $url = Url::fromString($this->public_repository_url);
+ $git_host = $url->getHost();
+ $git_repository = $url->getSegment(1) . '/' . $url->getSegment(2);
+ $git_branch = $url->getSegment(4) ?? 'main';
+
+ $project = Project::create([
+ 'name' => fake()->company(),
+ 'description' => fake()->sentence(),
+ 'team_id' => session('currentTeam')->id,
+ ]);
+ $application_init = [
+ 'name' => fake()->words(2, true),
+ 'git_repository' => $git_repository,
+ 'git_branch' => $git_branch,
+ 'build_pack' => 'nixpacks',
+ 'ports_exposes' => $this->port,
+ 'environment_id' => $project->environments->first()->id,
+ 'destination_id' => $this->chosenDestination->id,
+ 'destination_type' => $this->chosenDestination->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_init['source_id'] = GithubApp::where('name', 'Public Bitbucket')->first()->id;
+ // $application_init['source_type'] = GithubApp::class;
+ }
+ Application::create($application_init);
+ }
+}
diff --git a/app/Http/Livewire/Project/NewProject.php b/app/Http/Livewire/Project/NewProject.php
deleted file mode 100644
index b24a31580f..0000000000
--- a/app/Http/Livewire/Project/NewProject.php
+++ /dev/null
@@ -1,10 +0,0 @@
-<?php
-
-namespace App\Http\Livewire\Project;
-
-use Livewire\Component;
-
-class NewProject extends Component
-{
-
-}
diff --git a/app/Jobs/DeployApplicationJob.php b/app/Jobs/DeployApplicationJob.php
index 325980c3e7..7f973107aa 100644
--- a/app/Jobs/DeployApplicationJob.php
+++ b/app/Jobs/DeployApplicationJob.php
@@ -393,7 +393,7 @@ class DeployApplicationJob implements ShouldQueue
if ($this->application->source->getMorphClass() == 'App\Models\GithubApp') {
if ($this->source->is_public) {
- $git_clone_command = "{$git_clone_command} {$this->source->html_url}/{$this->application->git_repository}.git {$this->workdir}";
+ $git_clone_command = "{$git_clone_command} {$this->source->html_url}/{$this->application->git_repository} {$this->workdir}";
$git_clone_command = $this->setGitImportSettings($git_clone_command);
return [
$this->execute_in_builder($git_clone_command)
diff --git a/app/Models/Application.php b/app/Models/Application.php
index 723ddeebb3..fdcbeb5be6 100644
--- a/app/Models/Application.php
+++ b/app/Models/Application.php
@@ -16,6 +16,20 @@ class Application extends BaseModel
});
}
+ protected $fillable = [
+ 'name',
+ 'description',
+ 'git_repository',
+ 'git_branch',
+ 'build_pack',
+ 'environment_id',
+ 'destination_id',
+ 'destination_type',
+ 'source_id',
+ 'source_type',
+ 'ports_mappings',
+ 'ports_exposes',
+ ];
public function environment()
{
return $this->belongsTo(Environment::class);
diff --git a/app/Models/ApplicationSetting.php b/app/Models/ApplicationSetting.php
index a664f8d3c3..61d9f6ed86 100644
--- a/app/Models/ApplicationSetting.php
+++ b/app/Models/ApplicationSetting.php
@@ -7,6 +7,7 @@ use Illuminate\Database\Eloquent\Model;
class ApplicationSetting extends Model
{
protected $fillable = [
+ 'application_id',
'is_git_submodules_allowed',
'is_git_lfs_allowed',
];
diff --git a/app/Models/Environment.php b/app/Models/Environment.php
index 29f34208b8..c79472e88e 100644
--- a/app/Models/Environment.php
+++ b/app/Models/Environment.php
@@ -2,8 +2,21 @@
namespace App\Models;
-class Environment extends BaseModel
+use Illuminate\Database\Eloquent\Casts\Attribute;
+use Illuminate\Database\Eloquent\Model;
+
+class Environment extends Model
{
+ protected $fillable = [
+ 'name',
+ 'project_id',
+ ];
+ protected function name(): Attribute
+ {
+ return Attribute::make(
+ set: fn (string $value) => strtolower($value),
+ );
+ }
public function project()
{
return $this->belongsTo(Project::class);
@@ -21,4 +34,3 @@ class Environment extends BaseModel
return $this->hasMany(Service::class);
}
}
-
diff --git a/app/Models/Git.php b/app/Models/Git.php
new file mode 100644
index 0000000000..a615b65f4e
--- /dev/null
+++ b/app/Models/Git.php
@@ -0,0 +1,13 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Model;
+
+class Git extends Model
+{
+ public function applications()
+ {
+ return $this->morphMany(Application::class, 'source');
+ }
+}
diff --git a/app/Models/GitDeployKey.php b/app/Models/GitDeployKey.php
deleted file mode 100644
index f487f37c51..0000000000
--- a/app/Models/GitDeployKey.php
+++ /dev/null
@@ -1,7 +0,0 @@
-<?php
-
-namespace App\Models;
-
-class GitDeployKey extends BaseModel
-{
-}
diff --git a/app/Models/GitlabApp.php b/app/Models/GitlabApp.php
index ad5f658e2c..5e52dc00c8 100644
--- a/app/Models/GitlabApp.php
+++ b/app/Models/GitlabApp.php
@@ -4,6 +4,10 @@ namespace App\Models;
class GitlabApp extends BaseModel
{
+ public function applications()
+ {
+ return $this->morphMany(Application::class, 'source');
+ }
public function privateKey()
{
return $this->belongsTo(PrivateKey::class);
diff --git a/app/Models/InstanceSettings.php b/app/Models/InstanceSettings.php
index fa9dfa1f88..8f8936b1f7 100644
--- a/app/Models/InstanceSettings.php
+++ b/app/Models/InstanceSettings.php
@@ -2,10 +2,8 @@
namespace App\Models;
-use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class InstanceSettings extends Model
{
- use HasFactory;
}
diff --git a/app/Models/Project.php b/app/Models/Project.php
index e3f2f105b8..1ab08db17a 100644
--- a/app/Models/Project.php
+++ b/app/Models/Project.php
@@ -10,15 +10,28 @@ class Project extends BaseModel
ProjectSetting::create([
'project_id' => $project->id,
]);
+ Environment::create([
+ 'name' => 'Production',
+ 'project_id' => $project->id,
+ ]);
});
}
- public function environments() {
+ protected $fillable = [
+ 'name',
+ 'description',
+ 'team_id',
+ 'project_id'
+ ];
+ public function environments()
+ {
return $this->hasMany(Environment::class);
}
- public function settings() {
+ public function settings()
+ {
return $this->hasOne(ProjectSetting::class);
}
- public function applications() {
+ public function applications()
+ {
return $this->hasManyThrough(Application::class, Environment::class);
}
}
diff --git a/app/Models/ProjectSetting.php b/app/Models/ProjectSetting.php
index 78dcb32ba9..1d0d7c48ca 100644
--- a/app/Models/ProjectSetting.php
+++ b/app/Models/ProjectSetting.php
@@ -4,4 +4,7 @@ namespace App\Models;
class ProjectSetting extends BaseModel
{
+ protected $fillable = [
+ 'project_id'
+ ];
}
diff --git a/app/Models/Server.php b/app/Models/Server.php
index da302d0564..e06dc67e3e 100644
--- a/app/Models/Server.php
+++ b/app/Models/Server.php
@@ -12,6 +12,10 @@ class Server extends BaseModel
]);
});
}
+ public function destinations()
+ {
+ return $this->hasMany(PrivateKey::class);
+ }
public function privateKey()
{
return $this->belongsTo(PrivateKey::class);
diff --git a/app/View/Components/FormInput.php b/app/View/Components/FormInput.php
new file mode 100644
index 0000000000..5b346b11dd
--- /dev/null
+++ b/app/View/Components/FormInput.php
@@ -0,0 +1,31 @@
+<?php
+
+namespace App\View\Components;
+
+use Closure;
+use Illuminate\Contracts\View\View;
+use Illuminate\View\Component;
+
+class FormInput extends Component
+{
+ /**
+ * Create a new component instance.
+ */
+ public function __construct(
+ public string $id,
+ public bool $required = false,
+ public bool $readonly = false,
+ public string|null $label = null,
+ public string|null $type = 'text',
+ public bool $instantSave = false,
+ ) {
+ }
+
+ /**
+ * Get the view / contents that represent the component.
+ */
+ public function render(): View|Closure|string
+ {
+ return view('components.form-input');
+ }
+}
diff --git a/app/View/Components/Input.php b/app/View/Components/Input.php
index 07879b157b..41ef10a63b 100644
--- a/app/View/Components/Input.php
+++ b/app/View/Components/Input.php
@@ -12,14 +12,12 @@ class Input extends Component
* Create a new component instance.
*/
public function __construct(
- public string $name,
+ public string $id,
public bool $required = false,
public bool $readonly = false,
public string|null $label = null,
public string|null $type = 'text',
- public bool $instantSave = false,
) {
- //
}
/**
diff --git a/composer.json b/composer.json
index 3f4d36cafb..92f1fdf09b 100644
--- a/composer.json
+++ b/composer.json
@@ -16,6 +16,7 @@
"spatie/laravel-activitylog": "^4.7.3",
"spatie/laravel-data": "^3.4.3",
"spatie/laravel-ray": "^1.32.4",
+ "spatie/url": "^2.2",
"symfony/yaml": "^6.2",
"visus/cuid2": "^2.0.0"
},
diff --git a/composer.lock b/composer.lock
index 449f2337e6..dd39669484 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "d7ed21949975efcb1891e098e4d2abfa",
+ "content-hash": "987e0c4c7aea49957b194208f27253b3",
"packages": [
{
"name": "bacon/bacon-qr-code",
@@ -4180,6 +4180,68 @@
],
"time": "2023-03-06T07:22:28+00:00"
},
+ {
+ "name": "spatie/url",
+ "version": "2.2.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/spatie/url.git",
+ "reference": "8a52d669b7ada3bd8ba4a3cdba885056a35a978d"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/spatie/url/zipball/8a52d669b7ada3bd8ba4a3cdba885056a35a978d",
+ "reference": "8a52d669b7ada3bd8ba4a3cdba885056a35a978d",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^8.0",
+ "psr/http-message": "^1.0",
+ "spatie/macroable": "^2.0"
+ },
+ "require-dev": {
+ "pestphp/pest": "^1.21"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Spatie\\Url\\": "src"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Sebastian De Deyne",
+ "email": "[email protected]",
+ "homepage": "https://spatie.be",
+ "role": "Developer"
+ }
+ ],
+ "description": "Parse, build and manipulate URL's",
+ "homepage": "https://github.com/spatie/url",
+ "keywords": [
+ "spatie",
+ "url"
+ ],
+ "support": {
+ "issues": "https://github.com/spatie/url/issues",
+ "source": "https://github.com/spatie/url/tree/2.2.0"
+ },
+ "funding": [
+ {
+ "url": "https://spatie.be/open-source/support-us",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/spatie",
+ "type": "github"
+ }
+ ],
+ "time": "2022-12-14T09:57:56+00:00"
+ },
{
"name": "symfony/console",
"version": "v6.2.8",
diff --git a/database/migrations/2023_03_27_075444_create_environments_table.php b/database/migrations/2023_03_27_075444_create_environments_table.php
index 708621f427..f9514dcce3 100644
--- a/database/migrations/2023_03_27_075444_create_environments_table.php
+++ b/database/migrations/2023_03_27_075444_create_environments_table.php
@@ -13,10 +13,10 @@ return new class extends Migration
{
Schema::create('environments', function (Blueprint $table) {
$table->id();
- $table->string('uuid')->unique();
- $table->string('name')->unique();
+ $table->string('name');
$table->foreignId('project_id');
$table->timestamps();
+ $table->unique(['name', 'project_id']);
});
}
diff --git a/database/migrations/2023_03_27_081716_create_applications_table.php b/database/migrations/2023_03_27_081716_create_applications_table.php
index 23b6575e7e..fe3345bb19 100644
--- a/database/migrations/2023_03_27_081716_create_applications_table.php
+++ b/database/migrations/2023_03_27_081716_create_applications_table.php
@@ -54,7 +54,7 @@ return new class extends Migration
$table->string('status')->default('exited');
- $table->morphs('destination');
+ $table->nullableMorphs('destination');
$table->morphs('source');
$table->foreignId('environment_id');
diff --git a/database/migrations/2023_03_28_083722_create_gits_table.php b/database/migrations/2023_03_28_083722_create_gits_table.php
new file mode 100644
index 0000000000..cb7a8de1d7
--- /dev/null
+++ b/database/migrations/2023_03_28_083722_create_gits_table.php
@@ -0,0 +1,38 @@
+<?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('gits', function (Blueprint $table) {
+ $table->id();
+ $table->enum('type', ['github', 'gitlab', 'bitbucket', 'custom']);
+
+ $table->string('api_url');
+ $table->string('html_url');
+
+ $table->integer('custom_port')->default(22);
+ $table->string('custom_user')->default('git');
+
+ $table->longText('webhook_secret')->nullable();
+ $table->foreignId('private_key_id')->nullable();
+ $table->foreignId('project_id');
+ $table->timestamps();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down(): void
+ {
+ Schema::dropIfExists('gits');
+ }
+};
diff --git a/database/migrations/2023_03_28_100003_create_git_deploy_keys_table.php b/database/migrations/2023_03_28_100003_create_git_deploy_keys_table.php
deleted file mode 100644
index 2908a190a1..0000000000
--- a/database/migrations/2023_03_28_100003_create_git_deploy_keys_table.php
+++ /dev/null
@@ -1,32 +0,0 @@
-<?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('git_deploy_keys', function (Blueprint $table) {
- $table->id();
- $table->string('uuid')->unique();
- $table->string('name')->nullable();
- $table->string('url');
-
- $table->foreignId('private_key_id');
- $table->timestamps();
- });
- }
-
- /**
- * Reverse the migrations.
- */
- public function down(): void
- {
- Schema::dropIfExists('git_deploy_keys');
- }
-};
diff --git a/database/seeders/EnvironmentSeeder.php b/database/seeders/EnvironmentSeeder.php
index b06a70c5fe..345bda5c5d 100644
--- a/database/seeders/EnvironmentSeeder.php
+++ b/database/seeders/EnvironmentSeeder.php
@@ -14,11 +14,5 @@ class EnvironmentSeeder extends Seeder
*/
public function run(): void
{
- $project_1 = Project::find(1);
- Environment::create([
- 'id' => 1,
- 'name' => 'production',
- 'project_id' => $project_1->id,
- ]);
}
}
diff --git a/database/seeders/GitDeployKeySeeder.php b/database/seeders/GitDeployKeySeeder.php
deleted file mode 100644
index ecbcb56538..0000000000
--- a/database/seeders/GitDeployKeySeeder.php
+++ /dev/null
@@ -1,17 +0,0 @@
-<?php
-
-namespace Database\Seeders;
-
-use Illuminate\Database\Console\Seeds\WithoutModelEvents;
-use Illuminate\Database\Seeder;
-
-class GitDeployKeySeeder extends Seeder
-{
- /**
- * Run the database seeds.
- */
- public function run(): void
- {
- //
- }
-}
diff --git a/database/seeders/GitSeeder.php b/database/seeders/GitSeeder.php
new file mode 100644
index 0000000000..ce426d162a
--- /dev/null
+++ b/database/seeders/GitSeeder.php
@@ -0,0 +1,29 @@
+<?php
+
+namespace Database\Seeders;
+
+use App\Models\Git;
+use App\Models\PrivateKey;
+use App\Models\Project;
+use App\Models\Team;
+use Illuminate\Database\Seeder;
+
+class GitSeeder extends Seeder
+{
+ /**
+ * Run the database seeds.
+ */
+ public function run(): void
+ {
+ // $project = Project::find(1);
+ // $private_key_1 = PrivateKey::find(1);
+
+ // Git::create([
+ // 'api_url' => 'https://api.github.com',
+ // 'html_url' => 'https://github.com',
+ // 'is_public' => false,
+ // 'private_key_id' => $private_key_1->id,
+ // 'project_id' => $project->id,
+ // ]);
+ }
+}
diff --git a/database/seeders/GithubAppSeeder.php b/database/seeders/GithubAppSeeder.php
index d5abe181ff..9e468f913e 100644
--- a/database/seeders/GithubAppSeeder.php
+++ b/database/seeders/GithubAppSeeder.php
@@ -38,13 +38,5 @@ class GithubAppSeeder extends Seeder
'private_key_id' => $private_key_2->id,
'team_id' => $root_team->id,
]);
- GithubApp::create([
- 'name' => 'Private GitHub (deployment key)',
- 'api_url' => 'https://api.github.com',
- 'html_url' => 'https://github.com',
- 'is_public' => false,
- 'private_key_id' => $private_key_1->id,
- 'team_id' => $root_team->id,
- ]);
}
}
diff --git a/database/seeders/ProjectSeeder.php b/database/seeders/ProjectSeeder.php
index d8325b40d3..6aaca38332 100644
--- a/database/seeders/ProjectSeeder.php
+++ b/database/seeders/ProjectSeeder.php
@@ -12,7 +12,6 @@ class ProjectSeeder extends Seeder
{
$root_team = Team::find(0);
Project::create([
- 'id' => 1,
'name' => "My first project",
'description' => "This is a test project in development",
'team_id' => $root_team->id,
diff --git a/resources/views/components/form-input.blade.php b/resources/views/components/form-input.blade.php
new file mode 100644
index 0000000000..86515f1432
--- /dev/null
+++ b/resources/views/components/form-input.blade.php
@@ -0,0 +1,34 @@
+@if ($type === 'checkbox')
+ <label for={{ $id }}>
+ @if ($label)
+ {{ $label }}
+ @else
+ {{ $id }}
+ @endif
+ @if ($required)
+ *
+ @endif
+ <input type="checkbox" id={{ $id }}
+ @if ($instantSave) wire:click='instantSave' wire:model.defer={{ $id }} @else wire:model.defer={{ $id }} @endif>
+ </label>
+ @error($id)
+ <span class="text-red-500">{{ $message }}</span>
+ @enderror
+@else
+ <label for={{ $id }}>
+ @if ($label)
+ {{ $label }}
+ @else
+ {{ $id }}
+ @endif
+ @if ($required)
+ *
+ @endif
+ </label>
+ <input type={{ $type }} id={{ $id }} wire:model.defer={{ $id }}
+ @if ($required) required @endif
+ @if ($readonly) readOnly=true disabled=true @endif />
+ @error($id)
+ <div class="text-red-500">{{ $message }}</div>
+ @enderror
+@endif
diff --git a/resources/views/components/input.blade.php b/resources/views/components/input.blade.php
index 6ec6357b72..0acf572ce7 100644
--- a/resources/views/components/input.blade.php
+++ b/resources/views/components/input.blade.php
@@ -1,33 +1,11 @@
-@if ($type === 'checkbox')
- <label for={{ $name }}>
- @if ($label)
- {{ $label }}
- @else
- {{ $name }}
- @endif
- @if ($required)
- *
- @endif
- <input type="checkbox" id={{ $name }}
- @if ($instantSave) wire:click='instantSave' wire:model.defer={{ $name }} @else wire:model.defer={{ $name }} @endif
- name={{ $name }}>
- </label>
-@else
- <label for={{ $name }}>
- @if ($label)
- {{ $label }}
- @else
- {{ $name }}
- @endif
- @if ($required)
- *
- @endif
- </label>
- <input type={{ $type }} id={{ $name }} wire:model.defer={{ $name }}
- name={{ $name }} @if ($required) required @endif
- @if ($readonly) readOnly=true disabled=true @endif />
-@endif
-
-@error($name)
- <span class="text-red-500">{{ $message }}</span>
-@enderror
+<label for={{ $id }}>
+ @if ($label)
+ {{ $label }}
+ @else
+ {{ $id }}
+ @endif
+ @if ($required)
+ *
+ @endif
+ <input id={{ $id }} type={{ $type }} wire:model.defer={{ $id }}>
+</label>
diff --git a/resources/views/dashboard.blade.php b/resources/views/dashboard.blade.php
index c13d96d292..bce2b8efe3 100644
--- a/resources/views/dashboard.blade.php
+++ b/resources/views/dashboard.blade.php
@@ -1,5 +1,5 @@
<x-layout>
- <h1>Projects <button><a class="no-underline" href="{{ route('project.new') }}">New</a></button></h1>
+ <h1>Projects <a href="{{ route('project.new') }}"><button>New</button></a></h1>
@forelse ($projects as $project)
<a href="{{ route('project.environments', [$project->uuid]) }}">{{ data_get($project, 'name') }}</a>
@empty
diff --git a/resources/views/livewire/project/application/general.blade.php b/resources/views/livewire/project/application/general.blade.php
index 82071d5e7c..9da146dd92 100644
--- a/resources/views/livewire/project/application/general.blade.php
+++ b/resources/views/livewire/project/application/general.blade.php
@@ -1,37 +1,38 @@
<div>
<form wire:submit.prevent='submit' class="flex flex-col">
- <div class="flex flex-col xl:flex-row gap-2">
- <div class="flex-col flex w-96">
- <x-input name="application.name" label="Name" required />
- <x-input name="application.fqdn" label="FQDN" />
+ <div class="flex flex-col gap-2 xl:flex-row">
+ <div class="flex flex-col w-96">
+ <x-form-input id="application.name" label="Name" required />
+ <x-form-input id="application.fqdn" label="FQDN" />
</div>
- <div class="flex-col flex w-96">
- <x-input name="application.install_command" label="Install Command" />
- <x-input name="application.build_command" label="Build Command" />
- <x-input name="application.start_command" label="Start Command" />
- <x-input name="application.build_pack" label="Build Pack" />
+ <div class="flex flex-col w-96">
+ <x-form-input id="application.install_command" label="Install Command" />
+ <x-form-input id="application.build_command" label="Build Command" />
+ <x-form-input id="application.start_command" label="Start Command" />
+ <x-form-input id="application.build_pack" label="Build Pack" />
</div>
- <div class="flex-col flex w-96">
- <x-input name="application.base_directory" label="Base Directory" />
- <x-input name="application.publish_directory" label="Publish Directory" />
+ <div class="flex flex-col w-96">
+ <x-form-input id="application.base_directory" label="Base Directory" />
+ <x-form-input id="application.publish_directory" label="Publish Directory" />
</div>
- <div class="flex-col flex w-96">
- <x-input name="application.ports_exposes" label="Ports Exposes" />
+ <div class="flex flex-col w-96">
+ <x-form-input id="application.ports_exposes" label="Ports Exposes" />
+ <x-form-input id="application.ports_mappings" label="Ports Mappings" />
</div>
</div>
<button class="flex mx-auto mt-4" type="submit">
Submit
</button>
</form>
- <div class="flex flex-col pt-4 w-52 text-right">
- <x-input instantSave type="checkbox" name="is_auto_deploy" label="Auto Deploy?" />
- <x-input instantSave type="checkbox" name="is_dual_cert" label="Dual Certs?" />
- <x-input instantSave type="checkbox" name="is_previews" label="Previews?" />
- <x-input instantSave type="checkbox" name="is_bot" label="Is Bot?" />
- <x-input instantSave type="checkbox" name="is_custom_ssl" label="Is Custom SSL?" />
- <x-input instantSave type="checkbox" name="is_http2" label="Is Http2?" />
- <x-input instantSave type="checkbox" name="is_git_submodules_allowed" label="Git Submodules Allowed?" />
- <x-input instantSave type="checkbox" name="is_git_lfs_allowed" label="Git LFS Allowed?" />
- <x-input instantSave type="checkbox" name="is_debug" label="Debug" />
+ <div class="flex flex-col pt-4 text-right w-52">
+ <x-form-input instantSave type="checkbox" id="is_auto_deploy" label="Auto Deploy?" />
+ <x-form-input instantSave type="checkbox" id="is_dual_cert" label="Dual Certs?" />
+ <x-form-input instantSave type="checkbox" id="is_previews" label="Previews?" />
+ <x-form-input instantSave type="checkbox" id="is_bot" label="Is Bot?" />
+ <x-form-input instantSave type="checkbox" id="is_custom_ssl" label="Is Custom SSL?" />
+ <x-form-input instantSave type="checkbox" id="is_http2" label="Is Http2?" />
+ <x-form-input instantSave type="checkbox" id="is_git_submodules_allowed" label="Git Submodules Allowed?" />
+ <x-form-input instantSave type="checkbox" id="is_git_lfs_allowed" label="Git LFS Allowed?" />
+ <x-form-input instantSave type="checkbox" id="is_debug" label="Debug" />
</div>
</div>
diff --git a/resources/views/livewire/project/application/source.blade.php b/resources/views/livewire/project/application/source.blade.php
index 45329f7690..aa4404ec64 100644
--- a/resources/views/livewire/project/application/source.blade.php
+++ b/resources/views/livewire/project/application/source.blade.php
@@ -1,9 +1,9 @@
<div>
<p>Source Name: {{ data_get($application,'source.name') }}</p>
<p>Is Public Source: {{ data_get($application,'source.is_public') }}</p>
- <div class="flex-col flex w-96">
- <x-input name="application.git_repository" label="Git Repository" readonly />
- <x-input name="application.git_branch" label="Git Branch" readonly />
- <x-input name="application.git_commit_sha" label="Git Commit SHA" readonly />
+ <div class="flex flex-col w-96">
+ <x-form-input id="application.git_repository" label="Git Repository" readonly />
+ <x-form-input id="application.git_branch" label="Git Branch" readonly />
+ <x-form-input id="application.git_commit_sha" label="Git Commit SHA" readonly />
</div>
</div>
diff --git a/resources/views/livewire/project/new-project.blade.php b/resources/views/livewire/project/new-project.blade.php
deleted file mode 100644
index e22a7f78f7..0000000000
--- a/resources/views/livewire/project/new-project.blade.php
+++ /dev/null
@@ -1,11 +0,0 @@
-<div>
- <div class="flex flex-col w-64 gap-2">
- <button>Repository (any git)</button>
- <button>Repository through GitHub App</button>
- <button>Repository through GitLab App</button>
- <button>Repository through Bitbucket App</button>
- <button>Deploy Database</button>
- <button>Deploy Service</button>
- <button>Empty Project</button>
- </div>
-</div>
diff --git a/resources/views/livewire/project/new/public-git-repository.blade.php b/resources/views/livewire/project/new/public-git-repository.blade.php
new file mode 100644
index 0000000000..934ba1e180
--- /dev/null
+++ b/resources/views/livewire/project/new/public-git-repository.blade.php
@@ -0,0 +1,31 @@
+<div>
+ @forelse ($servers as $server)
+ <button @if ($chosenServer == $server->id) class="bg-blue-500" @endif
+ wire:click="chooseServer({{ $server->id }})">{{ $server->name }}</button>
+ @empty
+ No servers
+ @endforelse
+ @isset($chosenServer)
+ <div>
+ @foreach ($standalone_docker as $standalone)
+ <button @if ($chosenDestination?->uuid == $standalone->uuid) class="bg-blue-500" @endif
+ wire:click="setDestination('{{ $standalone->uuid }}','StandaloneDocker')">{{ $standalone->network }}</button>
+ @endforeach
+ @foreach ($swarm_docker as $standalone)
+ <button @if ($chosenDestination?->uuid == $standalone->uuid) class="bg-blue-500" @endif
+ wire:click="setDestination('{{ $standalone->uuid }}','SwarmDocker')">{{ $standalone->uuid }}</button>
+ @endforeach
+ </div>
+ @endisset
+
+ @isset($chosenDestination)
+ <form wire:submit.prevent='submit'>
+ <x-form-input id="public_repository_url" label="Repository URL" />
+ <x-form-input type="number" id="port" label="Port" />
+ <button type="submit">
+ Submit
+ </button>
+ </form>
+ @endisset
+
+</div>
diff --git a/resources/views/livewire/server/form.blade.php b/resources/views/livewire/server/form.blade.php
index 996a3c599a..38e33833fb 100644
--- a/resources/views/livewire/server/form.blade.php
+++ b/resources/views/livewire/server/form.blade.php
@@ -2,13 +2,13 @@
<form wire:submit.prevent='submit' class="flex flex-col">
<div class="flex flex-col gap-2 xl:flex-row">
<div class="flex flex-col w-96">
- <x-input name="server.name" label="Name" required />
- <x-input name="server.description" label="Description" />
+ <x-form-input id="server.name" label="Name" required />
+ <x-form-input id="server.description" label="Description" />
</div>
<div class="flex flex-col w-96">
- <x-input name="server.ip" label="IP Address" required />
- <x-input name="server.user" label="User" required />
- <x-input type="number" name="server.port" label="Port" required />
+ <x-form-input id="server.ip" label="IP Address" required />
+ <x-form-input id="server.user" label="User" required />
+ <x-form-input type="number" id="server.port" label="Port" required />
</div>
</div>
<button class="w-16 mt-4" type="submit">
diff --git a/resources/views/livewire/settings/form.blade.php b/resources/views/livewire/settings/form.blade.php
index f81c885932..cc9313f50d 100644
--- a/resources/views/livewire/settings/form.blade.php
+++ b/resources/views/livewire/settings/form.blade.php
@@ -2,12 +2,12 @@
<form wire:submit.prevent='submit' class="flex flex-col">
<div class="flex flex-col gap-2 xl:flex-row">
<div class="flex flex-col w-96">
- <x-input name="settings.fqdn" label="FQDN" />
- <x-input name="settings.wildcard_domain" label="Wildcard Domain" />
+ <x-form-input id="settings.fqdn" label="FQDN" />
+ <x-form-input id="settings.wildcard_domain" label="Wildcard Domain" />
</div>
<div class="flex flex-col w-96">
- <x-input type="number" name="settings.public_port_min" label="Public Port Min" />
- <x-input type="number" name="settings.public_port_max" label="Public Port Max" />
+ <x-form-input type="number" id="settings.public_port_min" label="Public Port Min" />
+ <x-form-input type="number" id="settings.public_port_max" label="Public Port Max" />
</div>
</div>
<button class="w-16 mt-4" type="submit">
@@ -15,9 +15,9 @@
</button>
</form>
<div class="flex flex-col pt-4 text-right w-52">
- <x-input instantSave type="checkbox" name="do_not_track" label="Do Not Track" />
- <x-input instantSave type="checkbox" name="is_auto_update_enabled" label="Auto Update?" />
- <x-input instantSave type="checkbox" name="is_registration_enabled" label="Registration Enabled?" />
- <x-input instantSave type="checkbox" name="is_https_forced" label="Force https?" />
+ <x-form-input instantSave type="checkbox" id="do_not_track" label="Do Not Track" />
+ <x-form-input instantSave type="checkbox" id="is_auto_update_enabled" label="Auto Update?" />
+ <x-form-input instantSave type="checkbox" id="is_registration_enabled" label="Registration Enabled?" />
+ <x-form-input instantSave type="checkbox" id="is_https_forced" label="Force https?" />
</div>
</div>
diff --git a/resources/views/project/new.blade.php b/resources/views/project/new.blade.php
index f23e5726f2..c000d79918 100644
--- a/resources/views/project/new.blade.php
+++ b/resources/views/project/new.blade.php
@@ -1,4 +1,26 @@
<x-layout>
<h1>New Project</h1>
- <livewire:project.new-project />
+ <div x-data="{ tab: window.location.hash ? window.location.hash.substring(1) : 'choose' }">
+ <div class="flex flex-col w-64 gap-2 mb-10">
+ <button @click.prevent="tab = 'public-repo'; window.location.hash = 'public-repo'">Public Repository
+ </button>
+ <button @click.prevent="tab = 'github-private-repo'; window.location.hash = 'github-private-repo'">Private
+ Repository (GitHub App)</button>
+ <button @click.prevent="tab = 'empty-project'; window.location.hash = 'empty-project'">Empty
+ Project</button>
+ </div>
+
+ <div x-cloak x-show="tab === 'public-repo'">
+ <livewire:project.new.public-git-repository />
+ </div>
+ <div x-cloak x-show="tab === 'github-private-repo'">
+ github-private-repo
+ </div>
+ <div x-cloak x-show="tab === 'empty-project'">
+ empty-project
+ </div>
+ <div x-cloak x-show="tab === 'choose'">
+ Choose any option
+ </div>
+ </div>
</x-layout>
diff --git a/routes/web.php b/routes/web.php
index 826729807e..da324f4f00 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -41,7 +41,7 @@ Route::middleware(['auth'])->group(function () {
'settings' => $settings
]);
} else {
- return redirect()->route('home');
+ return redirect()->route('dashboard');
}
})->name('settings');