wip
This commit is contained in:
@@ -19,11 +19,19 @@ class DemoDeployApplication extends Component
|
||||
|
||||
public Application $application;
|
||||
public $destination;
|
||||
public string $deployment_id;
|
||||
public string $workdir;
|
||||
|
||||
|
||||
public CoolifyInstanceSettings $coolify_instance_settings;
|
||||
public $wildcard_domain;
|
||||
|
||||
protected $command;
|
||||
|
||||
private function dockerPreCommand($command)
|
||||
{
|
||||
return $this->command[] = "docker exec {$this->deployment_id} sh -c '{$command}'";
|
||||
}
|
||||
public function deploy()
|
||||
{
|
||||
$this->isKeepAliveOn = true;
|
||||
@@ -36,22 +44,24 @@ class DemoDeployApplication extends Component
|
||||
$this->wildcard_domain = $project_wildcard_domain ?? $global_wildcard_domain ?? null;
|
||||
|
||||
$source = $this->application->source->getMorphClass()::where('id', $this->application->source->id)->first();
|
||||
$deployment_id = new Cuid2(10);
|
||||
$this->deployment_id = new Cuid2(10);
|
||||
|
||||
$workdir = $this->get_workdir('application', $this->application->uuid, $deployment_id);
|
||||
$this->workdir = "/tmp/{$this->deployment_id}";
|
||||
|
||||
$command[] = "echo 'Starting deployment of {$this->application->name} ({$this->application->uuid})'";
|
||||
$command[] = 'mkdirs -p ' . $workdir;
|
||||
$command[] = "git clone -b {$this->application->git_branch} {$source->html_url}/{$this->application->git_repository}.git {$workdir}";
|
||||
$this->command[] = "echo 'Starting deployment of {$this->application->name} ({$this->application->uuid})'";
|
||||
$this->command[] = "docker run -d --name {$this->deployment_id} --rm -v /var/run/docker.sock:/var/run/docker.sock coolify-builder >/dev/null";
|
||||
|
||||
if (!file_exists($workdir) && $workdir != "/") {
|
||||
$command[] = "echo 'Removing {$workdir}'";
|
||||
$command[] = "rm -rf {$workdir}";
|
||||
}
|
||||
$this->activity = remoteProcess(implode("\n", $command), $this->destination->server->name);
|
||||
$this->dockerPreCommand('hostname');
|
||||
$this->dockerPreCommand("mkdir -p {$this->workdir}");
|
||||
$this->dockerPreCommand("ls -ld {$this->workdir}");
|
||||
$this->dockerPreCommand("git clone -b {$this->application->git_branch} {$source->html_url}/{$this->application->git_repository}.git {$this->workdir}");
|
||||
$this->dockerPreCommand("ls -l {$this->workdir}");
|
||||
$this->command[] = "docker stop -t 0 {$this->deployment_id} >/dev/null";
|
||||
|
||||
$this->activity = remoteProcess(implode("\n", $this->command), $this->destination->server->name);
|
||||
|
||||
Deployment::create([
|
||||
'uuid' => $deployment_id,
|
||||
'uuid' => $this->deployment_id,
|
||||
'type_id' => $this->application->id,
|
||||
'type_type' => Application::class,
|
||||
'activity_log_id' => $this->activity->id,
|
||||
|
Reference in New Issue
Block a user