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.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
fix: ssh-agent revert
Andras Bacsai54a57d217f81
diff --git a/app/Actions/CoolifyTask/RunRemoteProcess.php b/app/Actions/CoolifyTask/RunRemoteProcess.phpindex e213f57f1a..842bdd2acf 100644--- a/app/Actions/CoolifyTask/RunRemoteProcess.php+++ b/app/Actions/CoolifyTask/RunRemoteProcess.php@@ -73,7 +73,7 @@ class RunRemoteProcess$this->time_start = hrtime(true);$status = ProcessStatus::IN_PROGRESS;- $processResult = processWithEnv()->forever()->run($this->getCommand(), $this->handleOutput(...));+ $processResult = Process::forever()->run($this->getCommand(), $this->handleOutput(...));if ($this->activity->properties->get('status') === ProcessStatus::ERROR->value) {$status = ProcessStatus::ERROR;diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.phpindex ea682b03a8..dd6648603f 100644--- a/app/Jobs/ApplicationDeploymentJob.php+++ b/app/Jobs/ApplicationDeploymentJob.php@@ -652,7 +652,7 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncryptedprivate function generate_healthcheck_commands(){- if ($this->application->dockerfile) {+ if ($this->application->dockerfile || $this->application->build_pack === 'dockerfile') {// TODO: disabled HC because there are several ways to hc a simple docker image, hard to figure out a good way. Like some docker images (pocketbase) does not have curl.return 'exit 0';}diff --git a/app/Traits/ExecuteRemoteCommand.php b/app/Traits/ExecuteRemoteCommand.phpindex e03c414b82..7416e1ce37 100644--- a/app/Traits/ExecuteRemoteCommand.php+++ b/app/Traits/ExecuteRemoteCommand.php@@ -39,7 +39,7 @@ trait ExecuteRemoteCommand$this->save = data_get($single_command, 'save');$remote_command = generateSshCommand( $ip, $user, $port, $command);- $process = processWithEnv()->timeout(3600)->idleTimeout(3600)->start($remote_command, function (string $type, string $output) use ($command, $hidden) {+ $process = Process::timeout(3600)->idleTimeout(3600)->start($remote_command, function (string $type, string $output) use ($command, $hidden) {$output = Str::of($output)->trim();$new_log_entry = ['command' => $command,diff --git a/bootstrap/helpers/remoteProcess.php b/bootstrap/helpers/remoteProcess.phpindex 84f2dc9d37..93128e04a8 100644--- a/bootstrap/helpers/remoteProcess.php+++ b/bootstrap/helpers/remoteProcess.php@@ -49,20 +49,23 @@ function remote_process(])();}-function removePrivateKeyFromSshAgent(Server $server)-{- if (data_get($server, 'privateKey.private_key') === null) {- throw new \Exception("Server {$server->name} does not have a private key");- }- processWithEnv()->run("echo '{$server->privateKey->private_key}' | ssh-add -d -");-}+// function removePrivateKeyFromSshAgent(Server $server)+// {+// if (data_get($server, 'privateKey.private_key') === null) {+// throw new \Exception("Server {$server->name} does not have a private key");+// }+// // processWithEnv()->run("echo '{$server->privateKey->private_key}' | ssh-add -d -");+// }function addPrivateKeyToSshAgent(Server $server){if (data_get($server, 'privateKey.private_key') === null) {throw new \Exception("Server {$server->name} does not have a private key");}- // ray('adding key', $server->privateKey->private_key);- processWithEnv()->run("echo '{$server->privateKey->private_key}' | ssh-add -q -");+ $sshKeyFileLocation = "id.root@{$server->uuid}";+ Storage::disk('ssh-keys')->makeDirectory('.');+ Storage::disk('ssh-mux')->makeDirectory('.');+ Storage::disk('ssh-keys')->put($sshKeyFileLocation, $server->privateKey->private_key);+ return '/var/www/html/storage/app/ssh/keys/' . $sshKeyFileLocation;}function generateSshCommand(string $server_ip, string $user, string $port, string $command, bool $isMux = true)@@ -71,7 +74,7 @@ function generateSshCommand(string $server_ip, string $user, string $port, strinif (!$server) {throw new \Exception("Server with ip {$server_ip} not found");}- addPrivateKeyToSshAgent($server);+ $privateKeyLocation = addPrivateKeyToSshAgent($server);$timeout = config('constants.ssh.command_timeout');$connectionTimeout = config('constants.ssh.connection_timeout');$serverInterval = config('constants.ssh.server_interval');@@ -83,7 +86,8 @@ function generateSshCommand(string $server_ip, string $user, string $port, strin$ssh_command .= '-o ControlMaster=auto -o ControlPersist=1m -o ControlPath=/var/www/html/storage/app/ssh/mux/%h_%p_%r ';}$command = "PATH=\$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/host/usr/local/sbin:/host/usr/local/bin:/host/usr/sbin:/host/usr/bin:/host/sbin:/host/bin && $command";- $ssh_command .= '-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null '+ $ssh_command .= "-i {$privateKeyLocation} "+ . '-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null '. '-o PasswordAuthentication=no '. "-o ConnectTimeout=$connectionTimeout ". "-o ServerAliveInterval=$serverInterval "@@ -97,28 +101,28 @@ function generateSshCommand(string $server_ip, string $user, string $port, strin// ray($ssh_command);return $ssh_command;}-function processWithEnv()-{- return Process::env(['SSH_AUTH_SOCK' => config('coolify.ssh_auth_sock')]);-}-function instantCommand(string $command, $throwError = true)-{- $process = processWithEnv()->run($command);- $output = trim($process->output());- $exitCode = $process->exitCode();- if ($exitCode !== 0) {- if (!$throwError) {- return null;- }- throw new \RuntimeException($process->errorOutput(), $exitCode);- }- return $output;-}+// function processWithEnv()+// {+// return Process::env(['SSH_AUTH_SOCK' => config('coolify.ssh_auth_sock')]);+// }+// function instantCommand(string $command, $throwError = true)+// {+// $process = Process::run($command);+// $output = trim($process->output());+// $exitCode = $process->exitCode();+// if ($exitCode !== 0) {+// if (!$throwError) {+// return null;+// }+// throw new \RuntimeException($process->errorOutput(), $exitCode);+// }+// return $output;+// }function instant_remote_process(array $command, Server $server, $throwError = true, $repeat = 1){$command_string = implode("\n", $command);$ssh_command = generateSshCommand($server->ip, $server->user, $server->port, $command_string);- $process = processWithEnv()->run($ssh_command);+ $process = Process::run($ssh_command);$output = trim($process->output());$exitCode = $process->exitCode();if ($exitCode !== 0) {@@ -169,14 +173,9 @@ function decode_remote_command_output(?ApplicationDeploymentQueue $application_dfunction refresh_server_connection(PrivateKey $private_key){foreach ($private_key->servers as $server) {- // Delete the old ssh mux file to force a new one to be createdStorage::disk('ssh-mux')->delete($server->muxFilename());- // check if user is authenticated- // if (currentTeam()->id) {- // currentTeam()->privateKeys = PrivateKey::where('team_id', currentTeam()->id)->get();- // }}- removePrivateKeyFromSshAgent($server);+ // removePrivateKeyFromSshAgent($server);}function validateServer(Server $server)diff --git a/config/coolify.php b/config/coolify.phpindex 68960015b7..cd16d6b6f6 100644--- a/config/coolify.php+++ b/config/coolify.php@@ -8,5 +8,4 @@ return ['dev_webhook' => env('SERVEO_URL'),'base_config_path' => env('BASE_CONFIG_PATH', '/data/coolify'),'helper_image' => env('HELPER_IMAGE', 'ghcr.io/coollabsio/coolify-helper:latest'),- 'ssh_auth_sock' => env('SSH_AUTH_SOCK', '/tmp/coolify-ssh-agent.sock'),];diff --git a/docker-compose.dev.yml b/docker-compose.dev.ymlindex 9af78058f7..cefdec07f1 100644--- a/docker-compose.dev.yml+++ b/docker-compose.dev.yml@@ -21,7 +21,6 @@ services:SSL_MODE: "off"AUTORUN_LARAVEL_STORAGE_LINK: "false"AUTORUN_LARAVEL_MIGRATION: "false"- SSH_AUTH_SOCK: "/tmp/coolify-ssh-agent.sock"volumes:- .:/var/www/html/:cachedpostgres:diff --git a/docker-compose.prod.yml b/docker-compose.prod.ymlindex 473513115c..6268f99634 100644--- a/docker-compose.prod.yml+++ b/docker-compose.prod.yml@@ -64,7 +64,6 @@ services:- LEMON_SQUEEZY_BASIC_PLAN_IDS- LEMON_SQUEEZY_PRO_PLAN_IDS- LEMON_SQUEEZY_ULTIMATE_PLAN_IDS- - SSH_AUTH_SOCK="/tmp/coolify-ssh-agent.sock"ports:- "${APP_PORT:-8000}:80"expose:diff --git a/docker/dev-ssu/etc/s6-overlay/s6-rc.d/ssh-agent/type b/docker/dev-ssu/etc/s6-overlay/s6-rc.d/ssh-agent/typedeleted file mode 100644index bdd22a1850..0000000000--- a/docker/dev-ssu/etc/s6-overlay/s6-rc.d/ssh-agent/type+++ /dev/null@@ -1 +0,0 @@-oneshotdiff --git a/docker/dev-ssu/etc/s6-overlay/s6-rc.d/ssh-agent/up b/docker/dev-ssu/etc/s6-overlay/s6-rc.d/ssh-agent/updeleted file mode 100644index 0490fb31f2..0000000000--- a/docker/dev-ssu/etc/s6-overlay/s6-rc.d/ssh-agent/up+++ /dev/null@@ -1,5 +0,0 @@-#!/usr/bin/execlineb -P-foreground {- s6-sleep 5- su - webuser -c "ssh-agent -a /tmp/coolify-ssh-agent.sock"-}diff --git a/docker/dev-ssu/etc/s6-overlay/s6-rc.d/user/contents.d/ssh-agent b/docker/dev-ssu/etc/s6-overlay/s6-rc.d/user/contents.d/ssh-agentdeleted file mode 100644index e69de29bb2..0000000000diff --git a/docker/prod-ssu/etc/s6-overlay/s6-rc.d/ssh-agent/type b/docker/prod-ssu/etc/s6-overlay/s6-rc.d/ssh-agent/typedeleted file mode 100644index bdd22a1850..0000000000--- a/docker/prod-ssu/etc/s6-overlay/s6-rc.d/ssh-agent/type+++ /dev/null@@ -1 +0,0 @@-oneshotdiff --git a/docker/prod-ssu/etc/s6-overlay/s6-rc.d/ssh-agent/up b/docker/prod-ssu/etc/s6-overlay/s6-rc.d/ssh-agent/updeleted file mode 100644index 0490fb31f2..0000000000--- a/docker/prod-ssu/etc/s6-overlay/s6-rc.d/ssh-agent/up+++ /dev/null@@ -1,5 +0,0 @@-#!/usr/bin/execlineb -P-foreground {- s6-sleep 5- su - webuser -c "ssh-agent -a /tmp/coolify-ssh-agent.sock"-}diff --git a/docker/prod-ssu/etc/s6-overlay/s6-rc.d/user/contents.d/ssh-agent b/docker/prod-ssu/etc/s6-overlay/s6-rc.d/user/contents.d/ssh-agentdeleted file mode 100644index e69de29bb2..0000000000