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.

fix: shorter cuids (7) feat: show deployments

Andras Bacsai1c259fe12eb5
diff --git a/app/Actions/RemoteProcess/DispatchRemoteProcess.php b/app/Actions/RemoteProcess/DispatchRemoteProcess.php
index 0f9d601920..21e40d3a06 100644
--- a/app/Actions/RemoteProcess/DispatchRemoteProcess.php
+++ b/app/Actions/RemoteProcess/DispatchRemoteProcess.php
@@ -19,12 +19,10 @@ class DispatchRemoteProcess
$this->activity = activity()
->withProperties($properties)
->performedOn($remoteProcessArgs->model)
- ->event('deployment')
->log("");
} else {
$this->activity = activity()
->withProperties($remoteProcessArgs->toArray())
- ->event('remote_process')
->log("");
}
}
diff --git a/app/Actions/RemoteProcess/RunRemoteProcess.php b/app/Actions/RemoteProcess/RunRemoteProcess.php
index 14b9190e12..3104cc36f0 100644
--- a/app/Actions/RemoteProcess/RunRemoteProcess.php
+++ b/app/Actions/RemoteProcess/RunRemoteProcess.php
@@ -31,7 +31,8 @@ class RunRemoteProcess
*/
public function __construct(Activity $activity)
{
- if ($activity->getExtraProperty('type') !== ActivityTypes::REMOTE_PROCESS->value) {
+
+ if ($activity->getExtraProperty('type') !== ActivityTypes::REMOTE_PROCESS->value && $activity->getExtraProperty('type') !== ActivityTypes::DEPLOYMENT->value) {
throw new \RuntimeException('Incompatible Activity to run a remote command.');
}
diff --git a/app/Enums/ActivityTypes.php b/app/Enums/ActivityTypes.php
index ad1c10c7ab..5bcab7cd77 100644
--- a/app/Enums/ActivityTypes.php
+++ b/app/Enums/ActivityTypes.php
@@ -5,4 +5,5 @@ namespace App\Enums;
enum ActivityTypes: string
{
case REMOTE_PROCESS = 'remote_process';
+ case DEPLOYMENT = 'deployment';
}
diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php
index 43b17430cd..a31681a4b5 100644
--- a/app/Http/Controllers/ProjectController.php
+++ b/app/Http/Controllers/ProjectController.php
@@ -42,7 +42,7 @@ class ProjectController extends Controller
if (!$application) {
return redirect()->route('home');
}
- return view('project.application', ['project' => $project, 'application' => $application]);
+ return view('project.application', ['project' => $project, 'application' => $application, 'deployments' => $application->deployments()]);
}
public function database()
{
diff --git a/app/Http/Livewire/DeployApplication.php b/app/Http/Livewire/DeployApplication.php
index e6889f1e46..95cc1b30bc 100644
--- a/app/Http/Livewire/DeployApplication.php
+++ b/app/Http/Livewire/DeployApplication.php
@@ -36,7 +36,7 @@ class DeployApplication extends Component
$wildcard_domain = $project_wildcard_domain ?? $global_wildcard_domain ?? null;
// Create Deployment ID
- $this->deployment_uuid = new Cuid2(12);
+ $this->deployment_uuid = new Cuid2(7);
$workdir = "/artifacts/{$this->deployment_uuid}";
// Start build process
@@ -48,20 +48,9 @@ class DeployApplication extends Component
$this->command[] = "docker stop -t 0 {$this->deployment_uuid} >/dev/null";
$this->activity = remoteProcess($this->command, $destination->server, $this->deployment_uuid, $application);
- // Create Deployment
- Deployment::create([
- 'uuid' => $this->deployment_uuid,
- 'type_id' => $application->id,
- 'type_type' => Application::class,
- 'activity_log_id' => $this->activity->id,
- ]);
- // Redirect to deployment page
- return redirect()->route('project.deployment', [
- "deployment_uuid" => $this->deployment_uuid,
- "project_uuid" => $application->environment->project->uuid,
- "environment_name" => $application->environment->name,
- "application_uuid" => $application->uuid
- ]);
+ $currentUrl = url()->previous();
+ $deploymentUrl = "$currentUrl/deployment/$this->deployment_uuid";
+ return redirect($deploymentUrl);
}
public function render()
{
diff --git a/app/Models/Application.php b/app/Models/Application.php
index afd52ae90d..c6bacd941e 100644
--- a/app/Models/Application.php
+++ b/app/Models/Application.php
@@ -22,7 +22,10 @@ class Application extends BaseModel
{
return $this->morphTo();
}
-
+ public function deployments()
+ {
+ return Activity::where('subject_id', $this->id)->where('properties->deployment_uuid', '!=', null)->orderBy('created_at', 'desc')->get();
+ }
public function get_deployment(string $deployment_uuid)
{
return Activity::where('subject_id', $this->id)->where('properties->deployment_uuid', '=', $deployment_uuid)->first();
diff --git a/app/Models/BaseModel.php b/app/Models/BaseModel.php
index 32bf22f890..1d9564ee20 100644
--- a/app/Models/BaseModel.php
+++ b/app/Models/BaseModel.php
@@ -12,7 +12,7 @@ abstract class BaseModel extends Model
parent::boot();
static::creating(function (Model $model) {
- $model->uuid = (string) new Cuid2();
+ $model->uuid = (string) new Cuid2(7);
});
}
}
diff --git a/app/Models/User.php b/app/Models/User.php
index 576415ec12..5ba3a299d3 100644
--- a/app/Models/User.php
+++ b/app/Models/User.php
@@ -48,7 +48,7 @@ class User extends Authenticatable
parent::boot();
static::creating(function (Model $model) {
- $model->uuid = (string) new Cuid2();
+ $model->uuid = (string) new Cuid2(7);
});
}
public function teams()
diff --git a/bootstrap/helpers.php b/bootstrap/helpers.php
index 0b9498831e..86bc7a6e05 100644
--- a/bootstrap/helpers.php
+++ b/bootstrap/helpers.php
@@ -2,6 +2,7 @@
use App\Actions\RemoteProcess\DispatchRemoteProcess;
use App\Data\RemoteProcessArgs;
+use App\Enums\ActivityTypes;
use App\Models\Server;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Storage;
@@ -29,6 +30,7 @@ if (!function_exists('remoteProcess')) {
return resolve(DispatchRemoteProcess::class, [
'remoteProcessArgs' => new RemoteProcessArgs(
+ type: $deployment_uuid ? ActivityTypes::DEPLOYMENT->value : ActivityTypes::REMOTE_PROCESS->value,
model: $model,
server_ip: $server->ip,
deployment_uuid: $deployment_uuid,
diff --git a/resources/views/project/application.blade.php b/resources/views/project/application.blade.php
index 36ab571462..db9ba59ee8 100644
--- a/resources/views/project/application.blade.php
+++ b/resources/views/project/application.blade.php
@@ -3,4 +3,13 @@
<p>Name: {{ $project->name }}</p>
<p>UUID: {{ $project->uuid }}</p>
<livewire:deploy-application :application_uuid="$application->uuid" />
+ <div>
+ <h1>Deployments</h1>
+ @foreach ($deployments as $deployment)
+ <p>
+ <a href="{{ url()->current() }}/deployment/{{ data_get($deployment->properties, 'deployment_uuid') }}">
+ {{ data_get($deployment->properties, 'deployment_uuid') }}</a>
+ </p>
+ @endforeach
+ </div>
</x-layout>
diff --git a/routes/web.php b/routes/web.php
index 875a117c87..067b0536f9 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -20,9 +20,12 @@ use Illuminate\Support\Facades\Route;
Route::middleware(['auth'])->group(function () {
Route::get('/', [HomeController::class, 'show'])->name('home');
Route::get('/project/{project_uuid}', [ProjectController::class, 'environments'])->name('project.environments');
+
Route::get('/project/{project_uuid}/{environment_name}', [ProjectController::class, 'resources'])->name('project.resources');
+
Route::get('/project/{project_uuid}/{environment_name}/application/{application_uuid}', [ProjectController::class, 'application'])->name('project.application');
Route::get('/project/{project_uuid}/{environment_name}/application/{application_uuid}/deployment/{deployment_uuid}', [ProjectController::class, 'deployment'])->name('project.deployment');
+
Route::get('/project/{project_uuid}/{environment_name}/database/{database_uuid}', [ProjectController::class, 'database'])->name('project.database');
Route::get('/project/{project_uuid}/{environment_name}/service/{service_uuid}', [ProjectController::class, 'service'])->name('project.service');