From 167379b0e0e9bcf6b1c41c146566943ca89bf388 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 24 May 2023 15:25:08 +0200 Subject: [PATCH] fix --- app/Actions/CoolifyTask/RunRemoteProcess.php | 2 +- .../Proxy/CheckProxySettingsInSync.php | 4 +- app/Actions/Proxy/InstallProxy.php | 4 +- app/Actions/Server/InstallDocker.php | 2 +- app/Http/Livewire/Destination/Form.php | 4 +- .../Destination/New/StandaloneDocker.php | 4 +- app/Http/Livewire/ForceUpgrade.php | 10 +- .../Livewire/Project/Application/Danger.php | 2 +- .../Livewire/Project/Application/Rollback.php | 4 +- app/Http/Livewire/RunCommand.php | 2 +- app/Http/Livewire/Server/Form.php | 6 +- app/Http/Livewire/Server/Proxy.php | 4 +- app/Jobs/ApplicationDeploymentJob.php | 6 +- app/Jobs/ContainerStatusJob.php | 2 +- app/Jobs/ContainerStopJob.php | 2 +- app/Jobs/CoolifyTask.php | 7 +- app/Jobs/InstanceAutoUpdate.php | 10 +- app/Jobs/InstanceDockerCleanup.php | 2 +- app/Providers/AppServiceProvider.php | 2 +- bootstrap/helpers/docker.php | 2 +- bootstrap/helpers/remoteProcess.php | 150 +++++++++--------- tests/Feature/DockerCommandsTest.php | 10 +- tests/Feature/RemoteProcessTest.php | 2 +- 23 files changed, 118 insertions(+), 125 deletions(-) diff --git a/app/Actions/CoolifyTask/RunRemoteProcess.php b/app/Actions/CoolifyTask/RunRemoteProcess.php index 38cec0d9d..45040b717 100644 --- a/app/Actions/CoolifyTask/RunRemoteProcess.php +++ b/app/Actions/CoolifyTask/RunRemoteProcess.php @@ -100,7 +100,7 @@ protected function getCommand(): string $port = $this->activity->getExtraProperty('port'); $command = $this->activity->getExtraProperty('command'); - return generateSshCommand($private_key_location, $server_ip, $user, $port, $command); + return generate_ssh_command($private_key_location, $server_ip, $user, $port, $command); } protected function handleOutput(string $type, string $output) diff --git a/app/Actions/Proxy/CheckProxySettingsInSync.php b/app/Actions/Proxy/CheckProxySettingsInSync.php index ce2b4c034..88c01d624 100644 --- a/app/Actions/Proxy/CheckProxySettingsInSync.php +++ b/app/Actions/Proxy/CheckProxySettingsInSync.php @@ -11,7 +11,7 @@ class CheckProxySettingsInSync public function __invoke(Server $server, bool $reset = false) { $proxy_path = config('coolify.proxy_config_path'); - $output = instantRemoteProcess([ + $output = instant_remote_process([ "cat $proxy_path/docker-compose.yml", ], $server, false); if (is_null($output) || $reset) { @@ -23,7 +23,7 @@ public function __invoke(Server $server, bool $reset = false) $server->extra_attributes->last_saved_proxy_settings = Str::of($docker_compose_yml_base64)->pipe('md5')->value; $server->save(); if (is_null($output) || $reset) { - instantRemoteProcess([ + instant_remote_process([ "mkdir -p $proxy_path", "echo '$docker_compose_yml_base64' | base64 -d > $proxy_path/docker-compose.yml", ], $server); diff --git a/app/Actions/Proxy/InstallProxy.php b/app/Actions/Proxy/InstallProxy.php index 42492ba41..67bfb1205 100644 --- a/app/Actions/Proxy/InstallProxy.php +++ b/app/Actions/Proxy/InstallProxy.php @@ -25,7 +25,7 @@ public function __invoke(Server $server): Activity return "docker network ls --format '{{.Name}}' | grep '^$network$' >/dev/null 2>&1 || docker network create --attachable $network > /dev/null 2>&1"; }); - $configuration = instantRemoteProcess([ + $configuration = instant_remote_process([ "cat $proxy_path/docker-compose.yml", ], $server, false); if (is_null($configuration)) { @@ -40,7 +40,7 @@ public function __invoke(Server $server): Activity $env_file_base64 = base64_encode( $this->getEnvContents() ); - $activity = remoteProcess([ + $activity = remote_process([ ...$create_networks_command, "echo 'Docker networks created...'", "mkdir -p $proxy_path", diff --git a/app/Actions/Server/InstallDocker.php b/app/Actions/Server/InstallDocker.php index 55c1fcc4b..69aae2898 100644 --- a/app/Actions/Server/InstallDocker.php +++ b/app/Actions/Server/InstallDocker.php @@ -10,7 +10,7 @@ class InstallDocker public function __invoke(Server $server) { $config = base64_encode('{ "live-restore": true }'); - $activity = remoteProcess([ + $activity = remote_process([ "echo Installing Docker...", "curl https://releases.rancher.com/install-docker/23.0.sh | sh", "echo Configuring Docker...", diff --git a/app/Http/Livewire/Destination/Form.php b/app/Http/Livewire/Destination/Form.php index 9bc2369f8..bc1c24c88 100644 --- a/app/Http/Livewire/Destination/Form.php +++ b/app/Http/Livewire/Destination/Form.php @@ -25,8 +25,8 @@ public function delete() if ($this->destination->attachedTo()) { return $this->emit('error', 'You must delete all resources before deleting this destination.'); } - instantRemoteProcess(["docker network disconnect {$this->destination->network} coolify-proxy"], $this->destination->server, throwError: false); - instantRemoteProcess(['docker network rm -f ' . $this->destination->network], $this->destination->server); + instant_remote_process(["docker network disconnect {$this->destination->network} coolify-proxy"], $this->destination->server, throwError: false); + instant_remote_process(['docker network rm -f ' . $this->destination->network], $this->destination->server); } $this->destination->delete(); return redirect()->route('dashboard'); diff --git a/app/Http/Livewire/Destination/New/StandaloneDocker.php b/app/Http/Livewire/Destination/New/StandaloneDocker.php index 1ebb3824e..d9d556510 100644 --- a/app/Http/Livewire/Destination/New/StandaloneDocker.php +++ b/app/Http/Livewire/Destination/New/StandaloneDocker.php @@ -45,8 +45,8 @@ public function submit() return; } $server = Server::find($this->server_id); - instantRemoteProcess(['docker network create --attachable ' . $this->network], $server, throwError: false); - instantRemoteProcess(["docker network connect $this->network coolify-proxy"], $server, throwError: false); + instant_remote_process(['docker network create --attachable ' . $this->network], $server, throwError: false); + instant_remote_process(["docker network connect $this->network coolify-proxy"], $server, throwError: false); $docker = ModelsStandaloneDocker::create([ 'name' => $this->name, diff --git a/app/Http/Livewire/ForceUpgrade.php b/app/Http/Livewire/ForceUpgrade.php index 033f3ef43..c66272bcc 100644 --- a/app/Http/Livewire/ForceUpgrade.php +++ b/app/Http/Livewire/ForceUpgrade.php @@ -15,10 +15,10 @@ public function upgrade() if (!$server) { return; } - instantRemoteProcess([ + instant_remote_process([ "sleep 2" ], $server); - remoteProcess([ + remote_process([ "sleep 10" ], $server, ActivityTypes::INLINE->value); $this->emit('updateInitiated'); @@ -31,18 +31,18 @@ public function upgrade() return; } - instantRemoteProcess([ + instant_remote_process([ "curl -fsSL $cdn/docker-compose.yml -o /data/coolify/source/docker-compose.yml", "curl -fsSL $cdn/docker-compose.prod.yml -o /data/coolify/source/docker-compose.prod.yml", "curl -fsSL $cdn/.env.production -o /data/coolify/source/.env.production", "curl -fsSL $cdn/upgrade.sh -o /data/coolify/source/upgrade.sh", ], $server); - instantRemoteProcess([ + instant_remote_process([ "docker compose -f /data/coolify/source/docker-compose.yml -f /data/coolify/source/docker-compose.prod.yml pull", ], $server); - remoteProcess([ + remote_process([ "bash /data/coolify/source/upgrade.sh $latestVersion" ], $server, ActivityTypes::INLINE->value); diff --git a/app/Http/Livewire/Project/Application/Danger.php b/app/Http/Livewire/Project/Application/Danger.php index 33e8a613b..52c947c58 100644 --- a/app/Http/Livewire/Project/Application/Danger.php +++ b/app/Http/Livewire/Project/Application/Danger.php @@ -18,7 +18,7 @@ public function delete() { $destination = $this->application->destination->getMorphClass()::where('id', $this->application->destination->id)->first(); - instantRemoteProcess(["docker rm -f {$this->application->uuid}"], $destination->server); + instant_remote_process(["docker rm -f {$this->application->uuid}"], $destination->server); $this->application->delete(); return redirect()->route('project.resources', [ 'project_uuid' => $this->parameters['project_uuid'], diff --git a/app/Http/Livewire/Project/Application/Rollback.php b/app/Http/Livewire/Project/Application/Rollback.php index 1ee01a746..853e0f9cf 100644 --- a/app/Http/Livewire/Project/Application/Rollback.php +++ b/app/Http/Livewire/Project/Application/Rollback.php @@ -42,13 +42,13 @@ public function loadImages() { try { $image = $this->application->uuid; - $output = instantRemoteProcess([ + $output = instant_remote_process([ "docker inspect --format='{{.Config.Image}}' {$this->application->uuid}", ], $this->application->destination->server, throwError: false); $current_tag = Str::of($output)->trim()->explode(":"); $this->current = data_get($current_tag, 1); - $output = instantRemoteProcess([ + $output = instant_remote_process([ "docker images --format '{{.Repository}}#{{.Tag}}#{{.CreatedAt}}'", ], $this->application->destination->server); $this->images = Str::of($output)->trim()->explode("\n")->filter(function ($item) use ($image) { diff --git a/app/Http/Livewire/RunCommand.php b/app/Http/Livewire/RunCommand.php index 2db18ab84..aca729720 100755 --- a/app/Http/Livewire/RunCommand.php +++ b/app/Http/Livewire/RunCommand.php @@ -26,7 +26,7 @@ public function runCommand() { try { $this->validate(); - $activity = remoteProcess([$this->command], Server::where('uuid', $this->server)->first(), ActivityTypes::INLINE->value); + $activity = remote_process([$this->command], Server::where('uuid', $this->server)->first(), ActivityTypes::INLINE->value); $this->emit('newMonitorActivity', $activity->id); } catch (\Exception $e) { return general_error_handler($e); diff --git a/app/Http/Livewire/Server/Form.php b/app/Http/Livewire/Server/Form.php index 2e7522ecd..83d7567f5 100644 --- a/app/Http/Livewire/Server/Form.php +++ b/app/Http/Livewire/Server/Form.php @@ -36,7 +36,7 @@ public function installDocker() public function validateServer() { try { - $this->uptime = instantRemoteProcess(['uptime'], $this->server, false); + $this->uptime = instant_remote_process(['uptime'], $this->server, false); if (!$this->uptime) { $this->uptime = 'Server not reachable.'; throw new \Exception('Server not reachable.'); @@ -47,11 +47,11 @@ public function validateServer() $this->emit('serverValidated'); } } - $this->dockerVersion = instantRemoteProcess(['docker version|head -2|grep -i version'], $this->server, false); + $this->dockerVersion = instant_remote_process(['docker version|head -2|grep -i version'], $this->server, false); if (!$this->dockerVersion) { $this->dockerVersion = 'Not installed.'; } - $this->dockerComposeVersion = instantRemoteProcess(['docker compose version|head -2|grep -i version'], $this->server, false); + $this->dockerComposeVersion = instant_remote_process(['docker compose version|head -2|grep -i version'], $this->server, false); if (!$this->dockerComposeVersion) { $this->dockerComposeVersion = 'Not installed.'; } diff --git a/app/Http/Livewire/Server/Proxy.php b/app/Http/Livewire/Server/Proxy.php index dc5ba8adf..8c637e1fe 100644 --- a/app/Http/Livewire/Server/Proxy.php +++ b/app/Http/Livewire/Server/Proxy.php @@ -51,7 +51,7 @@ public function setProxy() } public function stopProxy() { - instantRemoteProcess([ + instant_remote_process([ "docker rm -f coolify-proxy", ], $this->server); $this->server->extra_attributes->proxy_status = 'exited'; @@ -65,7 +65,7 @@ public function saveConfiguration() $docker_compose_yml_base64 = base64_encode($this->proxy_settings); $this->server->extra_attributes->last_saved_proxy_settings = Str::of($docker_compose_yml_base64)->pipe('md5')->value; $this->server->save(); - instantRemoteProcess([ + instant_remote_process([ "echo '$docker_compose_yml_base64' | base64 -d > $proxy_path/docker-compose.yml", ], $this->server); } catch (\Exception $e) { diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php index 95f914b18..b96355d28 100644 --- a/app/Jobs/ApplicationDeploymentJob.php +++ b/app/Jobs/ApplicationDeploymentJob.php @@ -60,7 +60,7 @@ public function __construct( $server = $this->destination->server; - $private_key_location = savePrivateKeyForServer($server); + $private_key_location = save_private_key_for_server($server); $remoteProcessArgs = new CoolifyTaskArgs( server_ip: $server->ip, @@ -452,13 +452,13 @@ private function execute_now( if ($isDebuggable && !$this->application->settings->is_debug) { $hideFromOutput = true; } - $remoteProcess = resolve(RunRemoteProcess::class, [ + $remote_process = resolve(RunRemoteProcess::class, [ 'activity' => $this->activity, 'hideFromOutput' => $hideFromOutput, 'isFinished' => $isFinished, 'ignoreErrors' => $ignoreErrors, ]); - $result = $remoteProcess(); + $result = $remote_process(); if ($propertyName) { $this->activity->properties = $this->activity->properties->merge([ $propertyName => trim($result->output()), diff --git a/app/Jobs/ContainerStatusJob.php b/app/Jobs/ContainerStatusJob.php index 2b3209ffc..4264c1dd4 100644 --- a/app/Jobs/ContainerStatusJob.php +++ b/app/Jobs/ContainerStatusJob.php @@ -47,7 +47,7 @@ protected function check_all_servers() $not_found_applications = $applications; $containers = collect(); foreach ($servers as $server) { - $output = instantRemoteProcess(['docker ps -a -q --format \'{{json .}}\''], $server); + $output = instant_remote_process(['docker ps -a -q --format \'{{json .}}\''], $server); $containers = $containers->concat(format_docker_command_output_to_json($output)); } foreach ($containers as $container) { diff --git a/app/Jobs/ContainerStopJob.php b/app/Jobs/ContainerStopJob.php index d1cdb18a2..d44851d9a 100644 --- a/app/Jobs/ContainerStopJob.php +++ b/app/Jobs/ContainerStopJob.php @@ -29,7 +29,7 @@ public function handle(): void { try { $application = Application::find($this->application_id)->first(); - instantRemoteProcess(["docker rm -f {$application->uuid}"], $this->server); + instant_remote_process(["docker rm -f {$application->uuid}"], $this->server); $application->status = get_container_status(server: $application->destination->server, container_id: $application->uuid); $application->save(); } catch (\Exception $e) { diff --git a/app/Jobs/CoolifyTask.php b/app/Jobs/CoolifyTask.php index d96095cc4..df4b0e8cc 100755 --- a/app/Jobs/CoolifyTask.php +++ b/app/Jobs/CoolifyTask.php @@ -19,18 +19,19 @@ class CoolifyTask implements ShouldQueue */ public function __construct( public Activity $activity, - ){} + ) { + } /** * Execute the job. */ public function handle(): void { - $remoteProcess = resolve(RunRemoteProcess::class, [ + $remote_process = resolve(RunRemoteProcess::class, [ 'activity' => $this->activity, ]); - $remoteProcess(); + $remote_process(); // @TODO: Remove file at $this->activity->getExtraProperty('private_key_location') after process is finished } } diff --git a/app/Jobs/InstanceAutoUpdate.php b/app/Jobs/InstanceAutoUpdate.php index 2955772b2..3bb9b6784 100644 --- a/app/Jobs/InstanceAutoUpdate.php +++ b/app/Jobs/InstanceAutoUpdate.php @@ -46,10 +46,10 @@ public function handle(): void if (!$server) { return; } - instantRemoteProcess([ + instant_remote_process([ "sleep 2" ], $server); - remoteProcess([ + remote_process([ "sleep 10" ], $server, ActivityTypes::INLINE->value); } else { @@ -68,18 +68,18 @@ public function handle(): void return; } - instantRemoteProcess([ + instant_remote_process([ "curl -fsSL $cdn/docker-compose.yml -o /data/coolify/source/docker-compose.yml", "curl -fsSL $cdn/docker-compose.prod.yml -o /data/coolify/source/docker-compose.prod.yml", "curl -fsSL $cdn/.env.production -o /data/coolify/source/.env.production", "curl -fsSL $cdn/upgrade.sh -o /data/coolify/source/upgrade.sh", ], $server); - instantRemoteProcess([ + instant_remote_process([ "docker compose -f /data/coolify/source/docker-compose.yml -f /data/coolify/source/docker-compose.prod.yml pull", ], $server); - remoteProcess([ + remote_process([ "bash /data/coolify/source/upgrade.sh $latest_version" ], $server, ActivityTypes::INLINE->value); } diff --git a/app/Jobs/InstanceDockerCleanup.php b/app/Jobs/InstanceDockerCleanup.php index 253fac815..0bb238e0e 100644 --- a/app/Jobs/InstanceDockerCleanup.php +++ b/app/Jobs/InstanceDockerCleanup.php @@ -31,7 +31,7 @@ public function handle(): void try { $servers = Server::all(); foreach ($servers as $server) { - instantRemoteProcess(['docker image prune -f'], $server); + instant_remote_process(['docker image prune -f'], $server); } } catch (\Exception $e) { Log::error($e->getMessage()); diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index be599237a..015584d9e 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -27,7 +27,7 @@ public function register(): void public function boot(): void { Queue::after(function (JobProcessed $event) { - // @TODO: Remove `coolify-builder` container after the remoteProcess job is finishged and remoteProcess->type == `deployment`. + // @TODO: Remove `coolify-builder` container after the remote_process job is finishged and remote_process->type == `deployment`. if ($event->job->resolveName() === CoolifyTask::class) { } }); diff --git a/bootstrap/helpers/docker.php b/bootstrap/helpers/docker.php index f4c28f673..ce6057e5f 100644 --- a/bootstrap/helpers/docker.php +++ b/bootstrap/helpers/docker.php @@ -31,7 +31,7 @@ function format_docker_labels_to_json($rawOutput): Collection function get_container_status(Server $server, string $container_id, bool $throwError = false) { - $container = instantRemoteProcess(["docker inspect --format '{{json .State}}' {$container_id}"], $server, $throwError); + $container = instant_remote_process(["docker inspect --format '{{json .State}}' {$container_id}"], $server, $throwError); if (!$container) { return 'exited'; } diff --git a/bootstrap/helpers/remoteProcess.php b/bootstrap/helpers/remoteProcess.php index ade752b41..5d0666951 100644 --- a/bootstrap/helpers/remoteProcess.php +++ b/bootstrap/helpers/remoteProcess.php @@ -1,5 +1,6 @@ team_id); + // @TODO: Check if the user has access to this server + // checkTeam($server->team_id); - $private_key_location = savePrivateKeyForServer($server); + $private_key_location = save_private_key_for_server($server); - return resolve(PrepareCoolifyTask::class, [ - 'remoteProcessArgs' => new CoolifyTaskArgs( - server_ip: $server->ip, - private_key_location: $private_key_location, - command: << new CoolifyTaskArgs( + server_ip: $server->ip, + private_key_location: $private_key_location, + command: <<port, - user: $server->user, - type: $type, - type_uuid: $type_uuid, - model: $model, - ), - ])(); - } + port: $server->port, + user: $server->user, + type: $type, + type_uuid: $type_uuid, + model: $model, + ), + ])(); +} +function save_private_key_for_server(Server $server) +{ + $temp_file = "id.root@{$server->ip}"; + Storage::disk('ssh-keys')->put($temp_file, $server->privateKey->private_key); + return '/var/www/html/storage/app/ssh-keys/' . $temp_file; } -if (!function_exists('savePrivateKeyForServer')) { - function savePrivateKeyForServer(Server $server) - { - $temp_file = "id.root@{$server->ip}"; - Storage::disk('ssh-keys')->put($temp_file, $server->privateKey->private_key); - return '/var/www/html/storage/app/ssh-keys/' . $temp_file; +function generate_ssh_command(string $private_key_location, string $server_ip, string $user, string $port, string $command, bool $isMux = true) +{ + Storage::disk('local')->makeDirectory('.ssh'); + + $delimiter = 'EOF-COOLIFY-SSH'; + $ssh_command = "ssh "; + + if ($isMux && config('coolify.mux_enabled')) { + $ssh_command .= '-o ControlMaster=auto -o ControlPersist=1m -o ControlPath=/var/www/html/storage/app/.ssh/ssh_mux_%h_%p_%r '; } + $ssh_command .= "-i {$private_key_location} " + . '-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ' + . '-o PasswordAuthentication=no ' + . '-o ConnectTimeout=3600 ' + . '-o ServerAliveInterval=20 ' + . '-o RequestTTY=no ' + . '-o LogLevel=ERROR ' + . "-p {$port} " + . "{$user}@{$server_ip} " + . " 'bash -se' << \\$delimiter" . PHP_EOL + . $command . PHP_EOL + . $delimiter; + + return $ssh_command; } -if (!function_exists('generateSshCommand')) { - function generateSshCommand(string $private_key_location, string $server_ip, string $user, string $port, string $command, bool $isMux = true) - { - Storage::disk('local')->makeDirectory('.ssh'); - - $delimiter = 'EOF-COOLIFY-SSH'; - $ssh_command = "ssh "; - - if ($isMux && config('coolify.mux_enabled')) { - $ssh_command .= '-o ControlMaster=auto -o ControlPersist=1m -o ControlPath=/var/www/html/storage/app/.ssh/ssh_mux_%h_%p_%r '; +function instant_remote_process(array $command, Server $server, $throwError = true) +{ + $command_string = implode("\n", $command); + $private_key_location = save_private_key_for_server($server); + $ssh_command = generate_ssh_command($private_key_location, $server->ip, $server->user, $server->port, $command_string); + $process = Process::run($ssh_command); + $output = trim($process->output()); + $exitCode = $process->exitCode(); + if ($exitCode !== 0) { + if (!$throwError) { + return null; } - $ssh_command .= "-i {$private_key_location} " - . '-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ' - . '-o PasswordAuthentication=no ' - . '-o ConnectTimeout=3600 ' - . '-o ServerAliveInterval=20 ' - . '-o RequestTTY=no ' - . '-o LogLevel=ERROR ' - . "-p {$port} " - . "{$user}@{$server_ip} " - . " 'bash -se' << \\$delimiter" . PHP_EOL - . $command . PHP_EOL - . $delimiter; - - return $ssh_command; - } -} - -if (!function_exists('instantRemoteProcess')) { - function instantRemoteProcess(array $command, Server $server, $throwError = true) - { - $command_string = implode("\n", $command); - $private_key_location = savePrivateKeyForServer($server); - $ssh_command = generateSshCommand($private_key_location, $server->ip, $server->user, $server->port, $command_string); - $process = Process::run($ssh_command); - $output = trim($process->output()); - $exitCode = $process->exitCode(); - if ($exitCode !== 0) { - if (!$throwError) { - return null; - } - throw new \RuntimeException($process->errorOutput()); - } - return $output; + throw new \RuntimeException($process->errorOutput()); } + return $output; } diff --git a/tests/Feature/DockerCommandsTest.php b/tests/Feature/DockerCommandsTest.php index b29d6191d..202c276aa 100644 --- a/tests/Feature/DockerCommandsTest.php +++ b/tests/Feature/DockerCommandsTest.php @@ -33,28 +33,28 @@ $containerName = 'coolify_test_' . now()->format('Ymd_his'); $host = Server::where('name', 'testing-local-docker-container')->first(); - remoteProcess([ + remote_process([ "docker rm -f $(docker ps --filter='name={$coolifyNamePrefix}*' -aq) > /dev/null 2>&1" ], $host); // Assert there's no containers start with coolify_test_* - $activity = remoteProcess([$areThereCoolifyTestContainers], $host); + $activity = remote_process([$areThereCoolifyTestContainers], $host); $tidyOutput = RunRemoteProcess::decodeOutput($activity); $containers = format_docker_command_output_to_json($tidyOutput); expect($containers)->toBeEmpty(); // start a container nginx -d --name = $containerName - $activity = remoteProcess(["docker run -d --rm --name {$containerName} nginx"], $host); + $activity = remote_process(["docker run -d --rm --name {$containerName} nginx"], $host); expect($activity->getExtraProperty('exitCode'))->toBe(0); // docker ps name = $container - $activity = remoteProcess([$areThereCoolifyTestContainers], $host); + $activity = remote_process([$areThereCoolifyTestContainers], $host); $tidyOutput = RunRemoteProcess::decodeOutput($activity); $containers = format_docker_command_output_to_json($tidyOutput); expect($containers->where('Names', $containerName)->count())->toBe(1); // Stop testing containers - $activity = remoteProcess([ + $activity = remote_process([ "docker ps --filter='name={$coolifyNamePrefix}*' -aq && " . "docker rm -f $(docker ps --filter='name={$coolifyNamePrefix}*' -aq)" ], $host); diff --git a/tests/Feature/RemoteProcessTest.php b/tests/Feature/RemoteProcessTest.php index 12786b82b..ca3777e9d 100644 --- a/tests/Feature/RemoteProcessTest.php +++ b/tests/Feature/RemoteProcessTest.php @@ -17,7 +17,7 @@ $host = Server::where('name', 'testing-local-docker-container')->first(); - $activity = remoteProcess([ + $activity = remote_process([ 'pwd', 'x=1; while [ $x -le 3 ]; do sleep 0.1 && echo "Welcome $x times" $(( x++ )); done', ], $host);