diff --git a/app/Actions/RemoteProcess/RunRemoteProcess.php b/app/Actions/RemoteProcess/RunRemoteProcess.php index 6627c1bd7..ecf1d660b 100644 --- a/app/Actions/RemoteProcess/RunRemoteProcess.php +++ b/app/Actions/RemoteProcess/RunRemoteProcess.php @@ -31,7 +31,7 @@ class RunRemoteProcess /** * Create a new job instance. */ - public function __construct(Activity $activity, bool $hideFromOutput) + public function __construct(Activity $activity, bool $hideFromOutput = false) { if ($activity->getExtraProperty('type') !== ActivityTypes::REMOTE_PROCESS->value && $activity->getExtraProperty('type') !== ActivityTypes::DEPLOYMENT->value) { diff --git a/bootstrap/helpers.php b/bootstrap/helpers.php index d68d413b4..ef1183cf7 100644 --- a/bootstrap/helpers.php +++ b/bootstrap/helpers.php @@ -23,7 +23,9 @@ function remoteProcess( ?string $deployment_uuid = null, ?Model $model = null, ): Activity { + $command_string = implode("\n", $command); + // @TODO: Check if the user has access to this server // checkTeam($server->team_id); @@ -31,7 +33,6 @@ function remoteProcess( return resolve(DispatchRemoteProcess::class, [ 'remoteProcessArgs' => new RemoteProcessArgs( - model: $model, server_ip: $server->ip, private_key_location: $private_key_location, deployment_uuid: $deployment_uuid, @@ -41,6 +42,7 @@ function remoteProcess( port: $server->port, user: $server->user, type: $deployment_uuid ? ActivityTypes::DEPLOYMENT->value : ActivityTypes::REMOTE_PROCESS->value, + model: $model, ), ])(); } diff --git a/tests/Feature/DockerCommandsTest.php b/tests/Feature/DockerCommandsTest.php index f7b88de6c..322ca734c 100644 --- a/tests/Feature/DockerCommandsTest.php +++ b/tests/Feature/DockerCommandsTest.php @@ -16,6 +16,7 @@ it('starts a docker container correctly', function () { + test()->actingAs(User::factory([ 'uuid' => Str::uuid(), 'email' => Str::uuid().'@example.com', @@ -31,22 +32,9 @@ $containerName = 'coolify_test_' . now()->format('Ymd_his'); $host = Server::where('name', 'testing-local-docker-container')->first(); - // Stop testing containers - $activity = remoteProcess([ - "docker stop $(docker ps --filter='name={$coolifyNamePrefix}*' -aq)", - "docker rm $(docker ps --filter='name={$coolifyNamePrefix}*' -aq)", - ], $host); - - throw_if( - $activity->getExtraProperty('exitCode') !== 0, - new RuntimeException($activity->description), - ); - - expect($activity->getExtraProperty('exitCode'))->toBe(0); - // Assert there's no containers start with coolify_test_* $activity = remoteProcess([$areThereCoolifyTestContainers], $host); - $containers = formatDockerCmdOutputToJson($activity->getExtraProperty('stdout')); + $containers = formatDockerCmdOutputToJson($activity->description); expect($containers)->toBeEmpty(); // start a container nginx -d --name = $containerName @@ -55,13 +43,13 @@ // docker ps name = $container $activity = remoteProcess([$areThereCoolifyTestContainers], $host); - $containers = formatDockerCmdOutputToJson($activity->getExtraProperty('stdout')); + $containers = formatDockerCmdOutputToJson($activity->description); expect($containers->where('Names', $containerName)->count())->toBe(1); // Stop testing containers $activity = remoteProcess([ - "docker stop $(docker ps --filter='name={$coolifyNamePrefix}*' -aq)", - "docker rm $(docker ps --filter='name={$coolifyNamePrefix}*' -aq)", + "docker ps --filter='name={$coolifyNamePrefix}*' -aq && " . + "docker rm -f $(docker ps --filter='name={$coolifyNamePrefix}*' -aq)" ], $host); expect($activity->getExtraProperty('exitCode'))->toBe(0); });