feat: add deployments as activity
fix: tests refactor: remoteProcess
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class ProjectController extends Controller
|
||||
{
|
||||
@@ -103,7 +104,7 @@ class ProjectController extends Controller
|
||||
if (!$application) {
|
||||
return redirect()->route('home');
|
||||
}
|
||||
$deployment = $application->deployments->where('uuid', $deployment_uuid)->first();
|
||||
return view('project.deployment', ['project' => $project, 'deployment' => $deployment]);
|
||||
$activity = $application->get_deployment($deployment_uuid);
|
||||
return view('project.deployment', ['project' => $project, 'activity' => $activity]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ class DeployApplication extends Component
|
||||
}
|
||||
private function start_builder_container()
|
||||
{
|
||||
$this->command[] = "docker run --pull=always -d --name {$this->deployment_uuid} --rm -v /var/run/docker.sock:/var/run/docker.sock ghcr.io/coollabsio/coolify-builder >/dev/null";
|
||||
$this->command[] = "docker run --pull=always -d --name {$this->deployment_uuid} --rm -v /var/run/docker.sock:/var/run/docker.sock ghcr.io/coollabsio/coolify-builder >/dev/null 2>&1";
|
||||
}
|
||||
public function deploy()
|
||||
{
|
||||
@@ -36,18 +36,17 @@ class DeployApplication extends Component
|
||||
$wildcard_domain = $project_wildcard_domain ?? $global_wildcard_domain ?? null;
|
||||
|
||||
// Create Deployment ID
|
||||
$this->deployment_uuid = new Cuid2(10);
|
||||
$this->deployment_uuid = new Cuid2(12);
|
||||
$workdir = "/artifacts/{$this->deployment_uuid}";
|
||||
|
||||
// Start build process
|
||||
$this->command[] = "echo 'Starting deployment of {$application->name} ({$application->uuid})'";
|
||||
$this->start_builder_container();
|
||||
$this->execute_in_builder('hostname');
|
||||
// $this->execute_in_builder('hostname');
|
||||
$this->execute_in_builder("git clone -b {$application->git_branch} {$source->html_url}/{$application->git_repository}.git {$workdir}");
|
||||
$this->execute_in_builder("ls -l {$workdir}");
|
||||
$this->command[] = "docker stop -t 0 {$this->deployment_uuid} >/dev/null";
|
||||
|
||||
$this->activity = remoteProcess(implode("\n", $this->command), $destination->server->name);
|
||||
$this->activity = remoteProcess($this->command, $destination->server, $this->deployment_uuid, $application);
|
||||
|
||||
// Create Deployment
|
||||
Deployment::create([
|
||||
|
||||
@@ -3,16 +3,12 @@
|
||||
namespace App\Http\Livewire;
|
||||
|
||||
use Livewire\Component;
|
||||
use Spatie\Activitylog\Models\Activity;
|
||||
|
||||
class PollActivity extends Component
|
||||
{
|
||||
public $activity;
|
||||
public $activity_log_id;
|
||||
public $isKeepAliveOn = true;
|
||||
public function mount() {
|
||||
$this->activity = Activity::find($this->activity_log_id);
|
||||
}
|
||||
|
||||
public function polling()
|
||||
{
|
||||
$this->activity?->refresh();
|
||||
|
||||
@@ -19,11 +19,13 @@ class RunCommand extends Component
|
||||
|
||||
public $servers = [];
|
||||
|
||||
protected $rules = [
|
||||
'server' => 'required',
|
||||
];
|
||||
public function mount()
|
||||
{
|
||||
$this->servers = Server::all()->pluck('name')->toArray();
|
||||
$this->server = $this->servers[0];
|
||||
|
||||
$this->servers = Server::all();
|
||||
$this->server = $this->servers[0]->uuid;
|
||||
}
|
||||
public function render()
|
||||
{
|
||||
@@ -33,25 +35,19 @@ class RunCommand extends Component
|
||||
public function runCommand()
|
||||
{
|
||||
$this->isKeepAliveOn = true;
|
||||
|
||||
$this->activity = remoteProcess($this->command, $this->server);
|
||||
$this->activity = remoteProcess([$this->command], Server::where('uuid', $this->server)->first());
|
||||
}
|
||||
|
||||
public function runSleepingBeauty()
|
||||
{
|
||||
$this->isKeepAliveOn = true;
|
||||
|
||||
$this->activity = remoteProcess('x=1; while [ $x -le 40 ]; do sleep 0.1 && echo "Welcome $x times" $(( x++ )); done', $this->server);
|
||||
$this->activity = remoteProcess(['x=1; while [ $x -le 40 ]; do sleep 0.1 && echo "Welcome $x times" $(( x++ )); done'], Server::where('uuid', $this->server)->first());
|
||||
}
|
||||
|
||||
public function runDummyProjectBuild()
|
||||
{
|
||||
$this->isKeepAliveOn = true;
|
||||
|
||||
$this->activity = remoteProcess(<<<EOT
|
||||
cd projects/dummy-project
|
||||
~/.docker/cli-plugins/docker-compose build --no-cache
|
||||
EOT, $this->server);
|
||||
$this->activity = remoteProcess([' cd projects/dummy-project', 'docker-compose build --no-cache'], Server::where('uuid', $this->server)->first());
|
||||
}
|
||||
|
||||
public function polling()
|
||||
|
||||
Reference in New Issue
Block a user