From d679e1a7d0f6553f82ebe132a9f160a95248b71e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 13 Sep 2025 12:45:57 +0000 Subject: [PATCH 01/12] chore(deps): bump axios from 1.8.4 to 1.12.0 in /docker/coolify-realtime Bumps [axios](https://github.com/axios/axios) from 1.8.4 to 1.12.0. - [Release notes](https://github.com/axios/axios/releases) - [Changelog](https://github.com/axios/axios/blob/v1.x/CHANGELOG.md) - [Commits](https://github.com/axios/axios/compare/v1.8.4...v1.12.0) --- updated-dependencies: - dependency-name: axios dependency-version: 1.12.0 dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- docker/coolify-realtime/package-lock.json | 10 +++++----- docker/coolify-realtime/package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docker/coolify-realtime/package-lock.json b/docker/coolify-realtime/package-lock.json index 49907cbd4..c445c972c 100644 --- a/docker/coolify-realtime/package-lock.json +++ b/docker/coolify-realtime/package-lock.json @@ -7,7 +7,7 @@ "dependencies": { "@xterm/addon-fit": "0.10.0", "@xterm/xterm": "5.5.0", - "axios": "1.8.4", + "axios": "1.12.0", "cookie": "1.0.2", "dotenv": "16.5.0", "node-pty": "1.0.0", @@ -36,13 +36,13 @@ "license": "MIT" }, "node_modules/axios": { - "version": "1.8.4", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.8.4.tgz", - "integrity": "sha512-eBSYY4Y68NNlHbHBMdeDmKNtDgXWhQsJcGqzO3iLUM0GraQFSS9cVgPX5I9b3lbdFKyYoAEGAZF1DwhTaljNAw==", + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.12.0.tgz", + "integrity": "sha512-oXTDccv8PcfjZmPGlWsPSwtOJCZ/b6W5jAMCNcfwJbCzDckwG0jrYJFaWH1yvivfCXjVzV/SPDEhMB3Q+DSurg==", "license": "MIT", "dependencies": { "follow-redirects": "^1.15.6", - "form-data": "^4.0.0", + "form-data": "^4.0.4", "proxy-from-env": "^1.1.0" } }, diff --git a/docker/coolify-realtime/package.json b/docker/coolify-realtime/package.json index 7851d7f4d..aec3dbe3d 100644 --- a/docker/coolify-realtime/package.json +++ b/docker/coolify-realtime/package.json @@ -5,7 +5,7 @@ "@xterm/addon-fit": "0.10.0", "@xterm/xterm": "5.5.0", "cookie": "1.0.2", - "axios": "1.8.4", + "axios": "1.12.0", "dotenv": "16.5.0", "node-pty": "1.0.0", "ws": "8.18.1" From 6d56b83e27987bd4e9e191d3a92c38cfff250103 Mon Sep 17 00:00:00 2001 From: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com> Date: Mon, 15 Sep 2025 12:50:34 +0200 Subject: [PATCH 02/12] chore(constants): update realtime_version from 1.0.10 to 1.0.11 --- config/constants.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/constants.php b/config/constants.php index 0d29c997e..4302df577 100644 --- a/config/constants.php +++ b/config/constants.php @@ -4,7 +4,7 @@ return [ 'coolify' => [ 'version' => '4.0.0-beta.427', 'helper_version' => '1.0.10', - 'realtime_version' => '1.0.10', + 'realtime_version' => '1.0.11', 'self_hosted' => env('SELF_HOSTED', true), 'autoupdate' => env('AUTOUPDATE'), 'base_config_path' => env('BASE_CONFIG_PATH', '/data/coolify'), From 7eb0c5a7577bf17398ce5c5fe72cf8578a22a1af Mon Sep 17 00:00:00 2001 From: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com> Date: Mon, 15 Sep 2025 13:59:14 +0200 Subject: [PATCH 03/12] fix(application): improve watch paths handling by trimming and filtering empty paths to prevent unnecessary triggers --- app/Models/Application.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app/Models/Application.php b/app/Models/Application.php index c98d83641..0ae50edca 100644 --- a/app/Models/Application.php +++ b/app/Models/Application.php @@ -1563,7 +1563,19 @@ class Application extends BaseModel if (is_null($this->watch_paths)) { return false; } - $watch_paths = collect(explode("\n", $this->watch_paths)); + $watch_paths = collect(explode("\n", $this->watch_paths)) + ->map(function (string $path): string { + return trim($path); + }) + ->filter(function (string $path): bool { + return strlen($path) > 0; + }); + + // If no valid patterns after filtering, don't trigger + if ($watch_paths->isEmpty()) { + return false; + } + $matches = $modified_files->filter(function ($file) use ($watch_paths) { return $watch_paths->contains(function ($glob) use ($file) { return fnmatch($glob, $file); From 77c7da39e25ec88e04ce28ac9334ee94d4f0922a Mon Sep 17 00:00:00 2001 From: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com> Date: Mon, 15 Sep 2025 14:10:20 +0200 Subject: [PATCH 04/12] feat(deployment): enhance deployment status reporting with detailed information on active deployments and team members --- bootstrap/helpers/shared.php | 75 +++++++++++++++++++++++++++++------- 1 file changed, 61 insertions(+), 14 deletions(-) diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.php index 28f5a083d..a0ab5a704 100644 --- a/bootstrap/helpers/shared.php +++ b/bootstrap/helpers/shared.php @@ -1125,30 +1125,77 @@ function get_public_ips() function isAnyDeploymentInprogress() { $runningJobs = ApplicationDeploymentQueue::where('horizon_job_worker', gethostname())->where('status', ApplicationDeploymentStatus::IN_PROGRESS->value)->get(); - $basicDetails = $runningJobs->map(function ($job) { - return [ - 'id' => $job->id, - 'created_at' => $job->created_at, - 'application_id' => $job->application_id, - 'server_id' => $job->server_id, - 'horizon_job_id' => $job->horizon_job_id, - 'status' => $job->status, - ]; - }); - echo 'Running jobs: '.json_encode($basicDetails)."\n"; + + if ($runningJobs->isEmpty()) { + echo "No deployments in progress.\n"; + exit(0); + } + $horizonJobIds = []; + $deploymentDetails = []; + foreach ($runningJobs as $runningJob) { $horizonJobStatus = getJobStatus($runningJob->horizon_job_id); if ($horizonJobStatus === 'unknown' || $horizonJobStatus === 'reserved') { $horizonJobIds[] = $runningJob->horizon_job_id; + + // Get application and team information + $application = Application::find($runningJob->application_id); + $teamMembers = []; + $deploymentUrl = ''; + + if ($application) { + // Get team members through the application's project + $team = $application->team(); + if ($team) { + $teamMembers = $team->members()->pluck('email')->toArray(); + } + + // Construct the full deployment URL + if ($runningJob->deployment_url) { + $baseUrl = base_url(); + $deploymentUrl = $baseUrl.$runningJob->deployment_url; + } + } + + $deploymentDetails[] = [ + 'id' => $runningJob->id, + 'application_name' => $runningJob->application_name ?? 'Unknown', + 'server_name' => $runningJob->server_name ?? 'Unknown', + 'deployment_url' => $deploymentUrl, + 'team_members' => $teamMembers, + 'created_at' => $runningJob->created_at->format('Y-m-d H:i:s'), + 'horizon_job_id' => $runningJob->horizon_job_id, + ]; } } + if (count($horizonJobIds) === 0) { - echo "No deployments in progress.\n"; + echo "No active deployments in progress (all jobs completed or failed).\n"; exit(0); } - $horizonJobIds = collect($horizonJobIds)->unique()->toArray(); - echo 'There are '.count($horizonJobIds)." deployments in progress.\n"; + + // Display enhanced deployment information + echo "\n=== Running Deployments ===\n"; + echo 'Total active deployments: '.count($horizonJobIds)."\n\n"; + + foreach ($deploymentDetails as $index => $deployment) { + echo 'Deployment #'.($index + 1).":\n"; + echo ' Application: '.$deployment['application_name']."\n"; + echo ' Server: '.$deployment['server_name']."\n"; + echo ' Started: '.$deployment['created_at']."\n"; + if ($deployment['deployment_url']) { + echo ' URL: '.$deployment['deployment_url']."\n"; + } + if (! empty($deployment['team_members'])) { + echo ' Team members: '.implode(', ', $deployment['team_members'])."\n"; + } else { + echo " Team members: No team members found\n"; + } + echo ' Horizon Job ID: '.$deployment['horizon_job_id']."\n"; + echo "\n"; + } + exit(1); } From 54a55be8e573ef88c291477f92e3f2ea0d4c0138 Mon Sep 17 00:00:00 2001 From: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com> Date: Mon, 15 Sep 2025 15:39:07 +0200 Subject: [PATCH 05/12] refactor(deployment): streamline environment variable handling for dockercompose and improve sorting of runtime variables --- app/Jobs/ApplicationDeploymentJob.php | 72 ++++++++++++++++++--------- 1 file changed, 48 insertions(+), 24 deletions(-) diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php index 81628a629..49cfd6141 100644 --- a/app/Jobs/ApplicationDeploymentJob.php +++ b/app/Jobs/ApplicationDeploymentJob.php @@ -911,24 +911,8 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue }); if ($this->pull_request_id === 0) { $this->env_filename = '.env'; - // Filter out buildtime-only variables from runtime environment - $runtime_environment_variables = $sorted_environment_variables->filter(function ($env) { - return ! $env->is_buildtime_only; - }); - foreach ($runtime_environment_variables as $env) { - $envs->push($env->key.'='.$env->real_value); - } - // Add PORT if not exists, use the first port as default - if ($this->build_pack !== 'dockercompose') { - if ($this->application->environment_variables->where('key', 'PORT')->isEmpty()) { - $envs->push("PORT={$ports[0]}"); - } - } - // Add HOST if not exists - if ($this->application->environment_variables->where('key', 'HOST')->isEmpty()) { - $envs->push('HOST=0.0.0.0'); - } + // Generate SERVICE_ variables first for dockercompose if ($this->build_pack === 'dockercompose') { $domains = collect(json_decode($this->application->docker_compose_domains)) ?? collect([]); @@ -957,26 +941,38 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue $envs->push('SERVICE_NAME_'.str($serviceName)->upper().'='.$serviceName); } } - } else { - $this->env_filename = '.env'; - // Filter out buildtime-only variables from runtime environment for preview - $runtime_environment_variables_preview = $sorted_environment_variables_preview->filter(function ($env) { + + // Filter out buildtime-only variables from runtime environment + $runtime_environment_variables = $sorted_environment_variables->filter(function ($env) { return ! $env->is_buildtime_only; }); - foreach ($runtime_environment_variables_preview as $env) { + + // Sort runtime environment variables: those referencing SERVICE_ variables come after others + $runtime_environment_variables = $runtime_environment_variables->sortBy(function ($env) { + if (str($env->value)->startsWith('$SERVICE_') || str($env->value)->contains('${SERVICE_')) { + return 2; + } + + return 1; + }); + + foreach ($runtime_environment_variables as $env) { $envs->push($env->key.'='.$env->real_value); } // Add PORT if not exists, use the first port as default if ($this->build_pack !== 'dockercompose') { - if ($this->application->environment_variables_preview->where('key', 'PORT')->isEmpty()) { + if ($this->application->environment_variables->where('key', 'PORT')->isEmpty()) { $envs->push("PORT={$ports[0]}"); } } // Add HOST if not exists - if ($this->application->environment_variables_preview->where('key', 'HOST')->isEmpty()) { + if ($this->application->environment_variables->where('key', 'HOST')->isEmpty()) { $envs->push('HOST=0.0.0.0'); } + } else { + $this->env_filename = '.env'; + // Generate SERVICE_ variables first for dockercompose preview if ($this->build_pack === 'dockercompose') { $domains = collect(json_decode(data_get($this->preview, 'docker_compose_domains'))) ?? collect([]); @@ -1001,6 +997,34 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue $envs->push('SERVICE_NAME_'.str($rawServiceName)->upper().'='.addPreviewDeploymentSuffix($rawServiceName, $this->pull_request_id)); } } + + // Filter out buildtime-only variables from runtime environment for preview + $runtime_environment_variables_preview = $sorted_environment_variables_preview->filter(function ($env) { + return ! $env->is_buildtime_only; + }); + + // Sort runtime environment variables: those referencing SERVICE_ variables come after others + $runtime_environment_variables_preview = $runtime_environment_variables_preview->sortBy(function ($env) { + if (str($env->value)->startsWith('$SERVICE_') || str($env->value)->contains('${SERVICE_')) { + return 2; + } + + return 1; + }); + + foreach ($runtime_environment_variables_preview as $env) { + $envs->push($env->key.'='.$env->real_value); + } + // Add PORT if not exists, use the first port as default + if ($this->build_pack !== 'dockercompose') { + if ($this->application->environment_variables_preview->where('key', 'PORT')->isEmpty()) { + $envs->push("PORT={$ports[0]}"); + } + } + // Add HOST if not exists + if ($this->application->environment_variables_preview->where('key', 'HOST')->isEmpty()) { + $envs->push('HOST=0.0.0.0'); + } } if ($envs->isEmpty()) { if ($this->env_filename) { From 3255f42385e218a5a23da7216b6ae09ad6ff1c65 Mon Sep 17 00:00:00 2001 From: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com> Date: Mon, 15 Sep 2025 15:39:27 +0200 Subject: [PATCH 06/12] refactor(remoteProcess): remove command log comments for file transfers to simplify code --- bootstrap/helpers/remoteProcess.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/bootstrap/helpers/remoteProcess.php b/bootstrap/helpers/remoteProcess.php index 7fa9671e3..bba3a4117 100644 --- a/bootstrap/helpers/remoteProcess.php +++ b/bootstrap/helpers/remoteProcess.php @@ -40,9 +40,6 @@ function remote_process( // Execute file transfer immediately transfer_file_to_server($content, $destination, $server, ! $ignore_errors); - - // Add a comment to the command log for visibility - $processed_commands[] = "# File transferred via SCP: $destination"; } else { // Regular string command $processed_commands[] = $cmd; @@ -211,9 +208,6 @@ function instant_remote_process(Collection|array $command, Server $server, bool // Execute file transfer immediately transfer_file_to_server($content, $destination, $server, $throwError); - - // Add a comment to the command log for visibility - $processed_commands[] = "# File transferred via SCP: $destination"; } else { // Regular string command $processed_commands[] = $cmd; From e84da21def1a341c410ef7c74997ce5ab228044e Mon Sep 17 00:00:00 2001 From: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com> Date: Mon, 15 Sep 2025 15:40:24 +0200 Subject: [PATCH 07/12] chore(versions): increment coolify version to 4.0.0-beta.428 and update realtime_version to 1.0.10 --- config/constants.php | 4 ++-- versions.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/config/constants.php b/config/constants.php index 4302df577..6dc78516e 100644 --- a/config/constants.php +++ b/config/constants.php @@ -2,9 +2,9 @@ return [ 'coolify' => [ - 'version' => '4.0.0-beta.427', + 'version' => '4.0.0-beta.428', 'helper_version' => '1.0.10', - 'realtime_version' => '1.0.11', + 'realtime_version' => '1.0.10', 'self_hosted' => env('SELF_HOSTED', true), 'autoupdate' => env('AUTOUPDATE'), 'base_config_path' => env('BASE_CONFIG_PATH', '/data/coolify'), diff --git a/versions.json b/versions.json index 2a82cb885..d3fac5855 100644 --- a/versions.json +++ b/versions.json @@ -1,10 +1,10 @@ { "coolify": { "v4": { - "version": "4.0.0-beta.427" + "version": "4.0.0-beta.428" }, "nightly": { - "version": "4.0.0-beta.428" + "version": "4.0.0-beta.429" }, "helper": { "version": "1.0.10" From e23c78fcda800300d0e5b272924383a60c18411b Mon Sep 17 00:00:00 2001 From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com> Date: Mon, 15 Sep 2025 15:48:10 +0200 Subject: [PATCH 08/12] chore(deps): bump helper version --- config/constants.php | 2 +- other/nightly/versions.json | 8 ++++---- versions.json | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/config/constants.php b/config/constants.php index 6dc78516e..0f3f928b8 100644 --- a/config/constants.php +++ b/config/constants.php @@ -3,7 +3,7 @@ return [ 'coolify' => [ 'version' => '4.0.0-beta.428', - 'helper_version' => '1.0.10', + 'helper_version' => '1.0.11', 'realtime_version' => '1.0.10', 'self_hosted' => env('SELF_HOSTED', true), 'autoupdate' => env('AUTOUPDATE'), diff --git a/other/nightly/versions.json b/other/nightly/versions.json index 2a82cb885..fd5dccaf0 100644 --- a/other/nightly/versions.json +++ b/other/nightly/versions.json @@ -1,13 +1,13 @@ { "coolify": { "v4": { - "version": "4.0.0-beta.427" - }, - "nightly": { "version": "4.0.0-beta.428" }, + "nightly": { + "version": "4.0.0-beta.429" + }, "helper": { - "version": "1.0.10" + "version": "1.0.11" }, "realtime": { "version": "1.0.10" diff --git a/versions.json b/versions.json index d3fac5855..fd5dccaf0 100644 --- a/versions.json +++ b/versions.json @@ -7,7 +7,7 @@ "version": "4.0.0-beta.429" }, "helper": { - "version": "1.0.10" + "version": "1.0.11" }, "realtime": { "version": "1.0.10" From 393745b68cfdcfb36c39c1529109d9a620bb90e4 Mon Sep 17 00:00:00 2001 From: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com> Date: Mon, 15 Sep 2025 17:55:08 +0200 Subject: [PATCH 09/12] Revert "refactor(file-transfer): replace base64 encoding with direct file transfer method across multiple database actions for improved clarity and efficiency" This reverts commit 18068857b1f0f06a9704bfe32c143f1b54b3521f. --- app/Actions/Database/StartClickhouse.php | 8 +- app/Actions/Database/StartDatabaseProxy.php | 19 +---- app/Actions/Database/StartDragonfly.php | 8 +- app/Actions/Database/StartKeydb.php | 8 +- app/Actions/Database/StartMariadb.php | 16 +--- app/Actions/Database/StartMongodb.php | 28 +++---- app/Actions/Database/StartMysql.php | 16 +--- app/Actions/Database/StartPostgresql.php | 27 +++---- app/Actions/Database/StartRedis.php | 8 +- app/Actions/Proxy/SaveProxyConfiguration.php | 7 +- app/Actions/Server/ConfigureCloudflared.php | 7 +- app/Actions/Server/InstallDocker.php | 12 +-- app/Actions/Server/StartLogDrain.php | 28 +------ app/Jobs/ApplicationDeploymentJob.php | 82 ++++++++++++-------- app/Models/Server.php | 3 + app/Models/Service.php | 6 +- bootstrap/helpers/remoteProcess.php | 8 +- 17 files changed, 106 insertions(+), 185 deletions(-) diff --git a/app/Actions/Database/StartClickhouse.php b/app/Actions/Database/StartClickhouse.php index 7be727f55..f218fcabb 100644 --- a/app/Actions/Database/StartClickhouse.php +++ b/app/Actions/Database/StartClickhouse.php @@ -99,12 +99,8 @@ class StartClickhouse $docker_compose = generateCustomDockerRunOptionsForDatabases($docker_run_options, $docker_compose, $container_name, $this->database->destination->network); $docker_compose = Yaml::dump($docker_compose, 10); - $this->commands[] = [ - 'transfer_file' => [ - 'content' => $docker_compose, - 'destination' => "$this->configuration_dir/docker-compose.yml", - ], - ]; + $docker_compose_base64 = base64_encode($docker_compose); + $this->commands[] = "echo '{$docker_compose_base64}' | base64 -d | tee $this->configuration_dir/docker-compose.yml > /dev/null"; $readme = generate_readme_file($this->database->name, now()); $this->commands[] = "echo '{$readme}' > $this->configuration_dir/README.md"; $this->commands[] = "echo 'Pulling {$database->image} image.'"; diff --git a/app/Actions/Database/StartDatabaseProxy.php b/app/Actions/Database/StartDatabaseProxy.php index d90eebc17..12fd92792 100644 --- a/app/Actions/Database/StartDatabaseProxy.php +++ b/app/Actions/Database/StartDatabaseProxy.php @@ -52,9 +52,8 @@ class StartDatabaseProxy } $configuration_dir = database_proxy_dir($database->uuid); - $volume_configuration_dir = $configuration_dir; if (isDev()) { - $volume_configuration_dir = '/var/lib/docker/volumes/coolify_dev_coolify_data/_data/databases/'.$database->uuid.'/proxy'; + $configuration_dir = '/var/lib/docker/volumes/coolify_dev_coolify_data/_data/databases/'.$database->uuid.'/proxy'; } $nginxconf = << [ [ 'type' => 'bind', - 'source' => "$volume_configuration_dir/nginx.conf", + 'source' => "$configuration_dir/nginx.conf", 'target' => '/etc/nginx/nginx.conf', ], ], @@ -116,18 +115,8 @@ class StartDatabaseProxy instant_remote_process(["docker rm -f $proxyContainerName"], $server, false); instant_remote_process([ "mkdir -p $configuration_dir", - [ - 'transfer_file' => [ - 'content' => base64_decode($nginxconf_base64), - 'destination' => "$configuration_dir/nginx.conf", - ], - ], - [ - 'transfer_file' => [ - 'content' => base64_decode($dockercompose_base64), - 'destination' => "$configuration_dir/docker-compose.yaml", - ], - ], + "echo '{$nginxconf_base64}' | base64 -d | tee $configuration_dir/nginx.conf > /dev/null", + "echo '{$dockercompose_base64}' | base64 -d | tee $configuration_dir/docker-compose.yaml > /dev/null", "docker compose --project-directory {$configuration_dir} pull", "docker compose --project-directory {$configuration_dir} up -d", ], $server); diff --git a/app/Actions/Database/StartDragonfly.php b/app/Actions/Database/StartDragonfly.php index 579c6841d..38ad99d2e 100644 --- a/app/Actions/Database/StartDragonfly.php +++ b/app/Actions/Database/StartDragonfly.php @@ -183,12 +183,8 @@ class StartDragonfly $docker_compose = generateCustomDockerRunOptionsForDatabases($docker_run_options, $docker_compose, $container_name, $this->database->destination->network); $docker_compose = Yaml::dump($docker_compose, 10); - $this->commands[] = [ - 'transfer_file' => [ - 'content' => $docker_compose, - 'destination' => "$this->configuration_dir/docker-compose.yml", - ], - ]; + $docker_compose_base64 = base64_encode($docker_compose); + $this->commands[] = "echo '{$docker_compose_base64}' | base64 -d | tee $this->configuration_dir/docker-compose.yml > /dev/null"; $readme = generate_readme_file($this->database->name, now()); $this->commands[] = "echo '{$readme}' > $this->configuration_dir/README.md"; $this->commands[] = "echo 'Pulling {$database->image} image.'"; diff --git a/app/Actions/Database/StartKeydb.php b/app/Actions/Database/StartKeydb.php index e1d4e43c1..59bcd4123 100644 --- a/app/Actions/Database/StartKeydb.php +++ b/app/Actions/Database/StartKeydb.php @@ -199,12 +199,8 @@ class StartKeydb $docker_run_options = convertDockerRunToCompose($this->database->custom_docker_run_options); $docker_compose = generateCustomDockerRunOptionsForDatabases($docker_run_options, $docker_compose, $container_name, $this->database->destination->network); $docker_compose = Yaml::dump($docker_compose, 10); - $this->commands[] = [ - 'transfer_file' => [ - 'content' => $docker_compose, - 'destination' => "$this->configuration_dir/docker-compose.yml", - ], - ]; + $docker_compose_base64 = base64_encode($docker_compose); + $this->commands[] = "echo '{$docker_compose_base64}' | base64 -d | tee $this->configuration_dir/docker-compose.yml > /dev/null"; $readme = generate_readme_file($this->database->name, now()); $this->commands[] = "echo '{$readme}' > $this->configuration_dir/README.md"; $this->commands[] = "echo 'Pulling {$database->image} image.'"; diff --git a/app/Actions/Database/StartMariadb.php b/app/Actions/Database/StartMariadb.php index 3f7d22245..13dba4b43 100644 --- a/app/Actions/Database/StartMariadb.php +++ b/app/Actions/Database/StartMariadb.php @@ -203,12 +203,8 @@ class StartMariadb } $docker_compose = Yaml::dump($docker_compose, 10); - $this->commands[] = [ - 'transfer_file' => [ - 'content' => $docker_compose, - 'destination' => "$this->configuration_dir/docker-compose.yml", - ], - ]; + $docker_compose_base64 = base64_encode($docker_compose); + $this->commands[] = "echo '{$docker_compose_base64}' | base64 -d | tee $this->configuration_dir/docker-compose.yml > /dev/null"; $readme = generate_readme_file($this->database->name, now()); $this->commands[] = "echo '{$readme}' > $this->configuration_dir/README.md"; $this->commands[] = "echo 'Pulling {$database->image} image.'"; @@ -288,11 +284,7 @@ class StartMariadb } $filename = 'custom-config.cnf'; $content = $this->database->mariadb_conf; - $this->commands[] = [ - 'transfer_file' => [ - 'content' => $content, - 'destination' => "$this->configuration_dir/{$filename}", - ], - ]; + $content_base64 = base64_encode($content); + $this->commands[] = "echo '{$content_base64}' | base64 -d | tee $this->configuration_dir/{$filename} > /dev/null"; } } diff --git a/app/Actions/Database/StartMongodb.php b/app/Actions/Database/StartMongodb.php index 7135f1c70..870b5b7e5 100644 --- a/app/Actions/Database/StartMongodb.php +++ b/app/Actions/Database/StartMongodb.php @@ -28,6 +28,9 @@ class StartMongodb $container_name = $this->database->uuid; $this->configuration_dir = database_configuration_dir().'/'.$container_name; + if (isDev()) { + $this->configuration_dir = '/var/lib/docker/volumes/coolify_dev_coolify_data/_data/databases/'.$container_name; + } $this->commands = [ "echo 'Starting database.'", @@ -251,12 +254,8 @@ class StartMongodb } $docker_compose = Yaml::dump($docker_compose, 10); - $this->commands[] = [ - 'transfer_file' => [ - 'content' => $docker_compose, - 'destination' => "$this->configuration_dir/docker-compose.yml", - ], - ]; + $docker_compose_base64 = base64_encode($docker_compose); + $this->commands[] = "echo '{$docker_compose_base64}' | base64 -d | tee $this->configuration_dir/docker-compose.yml > /dev/null"; $readme = generate_readme_file($this->database->name, now()); $this->commands[] = "echo '{$readme}' > $this->configuration_dir/README.md"; $this->commands[] = "echo 'Pulling {$database->image} image.'"; @@ -333,22 +332,15 @@ class StartMongodb } $filename = 'mongod.conf'; $content = $this->database->mongo_conf; - $this->commands[] = [ - 'transfer_file' => [ - 'content' => $content, - 'destination' => "$this->configuration_dir/{$filename}", - ], - ]; + $content_base64 = base64_encode($content); + $this->commands[] = "echo '{$content_base64}' | base64 -d | tee $this->configuration_dir/{$filename} > /dev/null"; } private function add_default_database() { $content = "db = db.getSiblingDB(\"{$this->database->mongo_initdb_database}\");db.createCollection('init_collection');db.createUser({user: \"{$this->database->mongo_initdb_root_username}\", pwd: \"{$this->database->mongo_initdb_root_password}\",roles: [{role:\"readWrite\",db:\"{$this->database->mongo_initdb_database}\"}]});"; - $this->commands[] = [ - 'transfer_file' => [ - 'content' => $content, - 'destination' => "$this->configuration_dir/docker-entrypoint-initdb.d/01-default-database.js", - ], - ]; + $content_base64 = base64_encode($content); + $this->commands[] = "mkdir -p $this->configuration_dir/docker-entrypoint-initdb.d"; + $this->commands[] = "echo '{$content_base64}' | base64 -d | tee $this->configuration_dir/docker-entrypoint-initdb.d/01-default-database.js > /dev/null"; } } diff --git a/app/Actions/Database/StartMysql.php b/app/Actions/Database/StartMysql.php index 5f453f80a..5d5611e07 100644 --- a/app/Actions/Database/StartMysql.php +++ b/app/Actions/Database/StartMysql.php @@ -204,12 +204,8 @@ class StartMysql } $docker_compose = Yaml::dump($docker_compose, 10); - $this->commands[] = [ - 'transfer_file' => [ - 'content' => $docker_compose, - 'destination' => "$this->configuration_dir/docker-compose.yml", - ], - ]; + $docker_compose_base64 = base64_encode($docker_compose); + $this->commands[] = "echo '{$docker_compose_base64}' | base64 -d | tee $this->configuration_dir/docker-compose.yml > /dev/null"; $readme = generate_readme_file($this->database->name, now()); $this->commands[] = "echo '{$readme}' > $this->configuration_dir/README.md"; $this->commands[] = "echo 'Pulling {$database->image} image.'"; @@ -291,11 +287,7 @@ class StartMysql } $filename = 'custom-config.cnf'; $content = $this->database->mysql_conf; - $this->commands[] = [ - 'transfer_file' => [ - 'content' => $content, - 'destination' => "$this->configuration_dir/{$filename}", - ], - ]; + $content_base64 = base64_encode($content); + $this->commands[] = "echo '{$content_base64}' | base64 -d | tee $this->configuration_dir/{$filename} > /dev/null"; } } diff --git a/app/Actions/Database/StartPostgresql.php b/app/Actions/Database/StartPostgresql.php index 75ca8ef10..38d46b3c1 100644 --- a/app/Actions/Database/StartPostgresql.php +++ b/app/Actions/Database/StartPostgresql.php @@ -27,6 +27,9 @@ class StartPostgresql $this->database = $database; $container_name = $this->database->uuid; $this->configuration_dir = database_configuration_dir().'/'.$container_name; + if (isDev()) { + $this->configuration_dir = '/var/lib/docker/volumes/coolify_dev_coolify_data/_data/databases/'.$container_name; + } $this->commands = [ "echo 'Starting database.'", @@ -214,12 +217,8 @@ class StartPostgresql } $docker_compose = Yaml::dump($docker_compose, 10); - $this->commands[] = [ - 'transfer_file' => [ - 'content' => $docker_compose, - 'destination' => "$this->configuration_dir/docker-compose.yml", - ], - ]; + $docker_compose_base64 = base64_encode($docker_compose); + $this->commands[] = "echo '{$docker_compose_base64}' | base64 -d | tee $this->configuration_dir/docker-compose.yml > /dev/null"; $readme = generate_readme_file($this->database->name, now()); $this->commands[] = "echo '{$readme}' > $this->configuration_dir/README.md"; $this->commands[] = "echo 'Pulling {$database->image} image.'"; @@ -305,12 +304,8 @@ class StartPostgresql foreach ($this->database->init_scripts as $init_script) { $filename = data_get($init_script, 'filename'); $content = data_get($init_script, 'content'); - $this->commands[] = [ - 'transfer_file' => [ - 'content' => $content, - 'destination' => "$this->configuration_dir/docker-entrypoint-initdb.d/{$filename}", - ], - ]; + $content_base64 = base64_encode($content); + $this->commands[] = "echo '{$content_base64}' | base64 -d | tee $this->configuration_dir/docker-entrypoint-initdb.d/{$filename} > /dev/null"; $this->init_scripts[] = "$this->configuration_dir/docker-entrypoint-initdb.d/{$filename}"; } } @@ -332,11 +327,7 @@ class StartPostgresql $this->database->postgres_conf = $content; $this->database->save(); } - $this->commands[] = [ - 'transfer_file' => [ - 'content' => $content, - 'destination' => $config_file_path, - ], - ]; + $content_base64 = base64_encode($content); + $this->commands[] = "echo '{$content_base64}' | base64 -d | tee $config_file_path > /dev/null"; } } diff --git a/app/Actions/Database/StartRedis.php b/app/Actions/Database/StartRedis.php index b5962b165..68a1f3fe3 100644 --- a/app/Actions/Database/StartRedis.php +++ b/app/Actions/Database/StartRedis.php @@ -196,12 +196,8 @@ class StartRedis $docker_compose = generateCustomDockerRunOptionsForDatabases($docker_run_options, $docker_compose, $container_name, $this->database->destination->network); $docker_compose = Yaml::dump($docker_compose, 10); - $this->commands[] = [ - 'transfer_file' => [ - 'content' => $docker_compose, - 'destination' => "$this->configuration_dir/docker-compose.yml", - ], - ]; + $docker_compose_base64 = base64_encode($docker_compose); + $this->commands[] = "echo '{$docker_compose_base64}' | base64 -d | tee $this->configuration_dir/docker-compose.yml > /dev/null"; $readme = generate_readme_file($this->database->name, now()); $this->commands[] = "echo '{$readme}' > $this->configuration_dir/README.md"; $this->commands[] = "echo 'Pulling {$database->image} image.'"; diff --git a/app/Actions/Proxy/SaveProxyConfiguration.php b/app/Actions/Proxy/SaveProxyConfiguration.php index 38c9c8def..53fbecce2 100644 --- a/app/Actions/Proxy/SaveProxyConfiguration.php +++ b/app/Actions/Proxy/SaveProxyConfiguration.php @@ -21,12 +21,7 @@ class SaveProxyConfiguration // Transfer the configuration file to the server instant_remote_process([ "mkdir -p $proxy_path", - [ - 'transfer_file' => [ - 'content' => base64_decode($docker_compose_yml_base64), - 'destination' => "$proxy_path/docker-compose.yml", - ], - ], + "echo '$docker_compose_yml_base64' | base64 -d | tee $proxy_path/docker-compose.yml > /dev/null", ], $server); } } diff --git a/app/Actions/Server/ConfigureCloudflared.php b/app/Actions/Server/ConfigureCloudflared.php index e66e7eecb..d21622bc5 100644 --- a/app/Actions/Server/ConfigureCloudflared.php +++ b/app/Actions/Server/ConfigureCloudflared.php @@ -40,12 +40,7 @@ class ConfigureCloudflared $commands = collect([ 'mkdir -p /tmp/cloudflared', 'cd /tmp/cloudflared', - [ - 'transfer_file' => [ - 'content' => base64_decode($docker_compose_yml_base64), - 'destination' => '/tmp/cloudflared/docker-compose.yml', - ], - ], + "echo '$docker_compose_yml_base64' | base64 -d | tee docker-compose.yml > /dev/null", 'echo Pulling latest Cloudflare Tunnel image.', 'docker compose pull', 'echo Stopping existing Cloudflare Tunnel container.', diff --git a/app/Actions/Server/InstallDocker.php b/app/Actions/Server/InstallDocker.php index 33c22b484..5410b1cbd 100644 --- a/app/Actions/Server/InstallDocker.php +++ b/app/Actions/Server/InstallDocker.php @@ -14,7 +14,6 @@ class InstallDocker public function handle(Server $server) { - ray('install docker'); $dockerVersion = config('constants.docker.minimum_required_version'); $supported_os_type = $server->validateOS(); if (! $supported_os_type) { @@ -104,15 +103,8 @@ class InstallDocker "curl https://releases.rancher.com/install-docker/{$dockerVersion}.sh | sh || curl https://get.docker.com | sh -s -- --version {$dockerVersion}", "echo 'Configuring Docker Engine (merging existing configuration with the required)...'", 'test -s /etc/docker/daemon.json && cp /etc/docker/daemon.json "/etc/docker/daemon.json.original-$(date +"%Y%m%d-%H%M%S")"', - [ - 'transfer_file' => [ - 'content' => base64_decode($config), - 'destination' => '/tmp/daemon.json.new', - ], - ], - 'test ! -s /etc/docker/daemon.json && cp /tmp/daemon.json.new /etc/docker/daemon.json', - 'cp /tmp/daemon.json.new /etc/docker/daemon.json.coolify', - 'rm -f /tmp/daemon.json.new', + "test ! -s /etc/docker/daemon.json && echo '{$config}' | base64 -d | tee /etc/docker/daemon.json > /dev/null", + "echo '{$config}' | base64 -d | tee /etc/docker/daemon.json.coolify > /dev/null", 'jq . /etc/docker/daemon.json.coolify | tee /etc/docker/daemon.json.coolify.pretty > /dev/null', 'mv /etc/docker/daemon.json.coolify.pretty /etc/docker/daemon.json.coolify', "jq -s '.[0] * .[1]' /etc/docker/daemon.json.coolify /etc/docker/daemon.json | tee /etc/docker/daemon.json.appended > /dev/null", diff --git a/app/Actions/Server/StartLogDrain.php b/app/Actions/Server/StartLogDrain.php index 3e1dad1c2..f72f23696 100644 --- a/app/Actions/Server/StartLogDrain.php +++ b/app/Actions/Server/StartLogDrain.php @@ -180,30 +180,10 @@ Files: $command = [ "echo 'Saving configuration'", "mkdir -p $config_path", - [ - 'transfer_file' => [ - 'content' => base64_decode($parsers), - 'destination' => $parsers_config, - ], - ], - [ - 'transfer_file' => [ - 'content' => base64_decode($config), - 'destination' => $fluent_bit_config, - ], - ], - [ - 'transfer_file' => [ - 'content' => base64_decode($compose), - 'destination' => $compose_path, - ], - ], - [ - 'transfer_file' => [ - 'content' => base64_decode($readme), - 'destination' => $readme_path, - ], - ], + "echo '{$parsers}' | base64 -d | tee $parsers_config > /dev/null", + "echo '{$config}' | base64 -d | tee $fluent_bit_config > /dev/null", + "echo '{$compose}' | base64 -d | tee $compose_path > /dev/null", + "echo '{$readme}' | base64 -d | tee $readme_path > /dev/null", "test -f $config_path/.env && rm $config_path/.env", ]; if ($type === 'newrelic') { diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php index 49cfd6141..e38ff1c7d 100644 --- a/app/Jobs/ApplicationDeploymentJob.php +++ b/app/Jobs/ApplicationDeploymentJob.php @@ -388,8 +388,11 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue $dockerfile_base64 = base64_encode($this->application->dockerfile); $this->application_deployment_queue->addLogEntry("Starting deployment of {$this->application->name} to {$this->server->name}."); $this->prepare_builder_image(); - $dockerfile_content = base64_decode($dockerfile_base64); - transfer_file_to_container($dockerfile_content, "{$this->workdir}{$this->dockerfile_location}", $this->deployment_uuid, $this->server); + $this->execute_remote_command( + [ + executeInDocker($this->deployment_uuid, "echo '$dockerfile_base64' | base64 -d | tee {$this->workdir}{$this->dockerfile_location} > /dev/null"), + ], + ); $this->generate_image_names(); $this->generate_compose_file(); $this->generate_build_env_variables(); @@ -494,7 +497,10 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue $yaml = Yaml::dump(convertToArray($composeFile), 10); } $this->docker_compose_base64 = base64_encode($yaml); - transfer_file_to_container($yaml, "{$this->workdir}{$this->docker_compose_location}", $this->deployment_uuid, $this->server); + $this->execute_remote_command([ + executeInDocker($this->deployment_uuid, "echo '{$this->docker_compose_base64}' | base64 -d | tee {$this->workdir}{$this->docker_compose_location} > /dev/null"), + 'hidden' => true, + ]); // Build new container to limit downtime. $this->application_deployment_queue->addLogEntry('Pulling & building required images.'); @@ -709,12 +715,13 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue $composeFileName = "$mainDir/".addPreviewDeploymentSuffix('docker-compose', $this->pull_request_id).'.yaml'; $this->docker_compose_location = '/'.addPreviewDeploymentSuffix('docker-compose', $this->pull_request_id).'.yaml'; } - $this->execute_remote_command([ - "mkdir -p $mainDir", - ]); - $docker_compose_content = base64_decode($this->docker_compose_base64); - transfer_file_to_server($docker_compose_content, $composeFileName, $this->server); $this->execute_remote_command( + [ + "mkdir -p $mainDir", + ], + [ + "echo '{$this->docker_compose_base64}' | base64 -d | tee $composeFileName > /dev/null", + ], [ "echo '{$readme}' > $mainDir/README.md", ] @@ -1057,17 +1064,27 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue } $this->env_filename = null; } else { - $envs_content = $envs->implode("\n"); - transfer_file_to_container($envs_content, "/artifacts/{$this->env_filename}", $this->deployment_uuid, $this->server); + $envs_base64 = base64_encode($envs->implode("\n")); + $this->execute_remote_command( + [ + executeInDocker($this->deployment_uuid, "echo '$envs_base64' | base64 -d | tee $this->workdir/{$this->env_filename} > /dev/null"), + ], - // Save the env filename with preview deployment suffix - $env_filename = addPreviewDeploymentSuffix($this->env_filename, $this->pull_request_id); + ); if ($this->use_build_server) { $this->server = $this->original_server; - transfer_file_to_server($envs_content, "$this->configuration_dir/{$env_filename}", $this->server); + $this->execute_remote_command( + [ + "echo '$envs_base64' | base64 -d | tee $this->configuration_dir/{$this->env_filename} > /dev/null", + ] + ); $this->server = $this->build_server; } else { - transfer_file_to_server($envs_content, "$this->configuration_dir/{$env_filename}", $this->server); + $this->execute_remote_command( + [ + "echo '$envs_base64' | base64 -d | tee $this->configuration_dir/{$this->env_filename} > /dev/null", + ] + ); } } $this->environment_variables = $envs; @@ -1460,11 +1477,14 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue } $private_key = data_get($this->application, 'private_key.private_key'); if ($private_key) { - $this->execute_remote_command([ - executeInDocker($this->deployment_uuid, 'mkdir -p /root/.ssh'), - ]); - transfer_file_to_container($private_key, '/root/.ssh/id_rsa', $this->deployment_uuid, $this->server); + $private_key = base64_encode($private_key); $this->execute_remote_command( + [ + executeInDocker($this->deployment_uuid, 'mkdir -p /root/.ssh'), + ], + [ + executeInDocker($this->deployment_uuid, "echo '{$private_key}' | base64 -d | tee /root/.ssh/id_rsa > /dev/null"), + ], [ executeInDocker($this->deployment_uuid, 'chmod 600 /root/.ssh/id_rsa'), ], @@ -2026,7 +2046,7 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue $this->docker_compose = Yaml::dump($docker_compose, 10); $this->docker_compose_base64 = base64_encode($this->docker_compose); - transfer_file_to_container(base64_decode($this->docker_compose_base64), "{$this->workdir}/docker-compose.yaml", $this->deployment_uuid, $this->server); + $this->execute_remote_command([executeInDocker($this->deployment_uuid, "echo '{$this->docker_compose_base64}' | base64 -d | tee {$this->workdir}/docker-compose.yaml > /dev/null"), 'hidden' => true]); } private function generate_local_persistent_volumes() @@ -2154,8 +2174,7 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf"); } else { if ($this->application->build_pack === 'nixpacks') { $this->nixpacks_plan = base64_encode($this->nixpacks_plan); - $nixpacks_content = base64_decode($this->nixpacks_plan); - transfer_file_to_container($nixpacks_content, '/artifacts/thegameplan.json', $this->deployment_uuid, $this->server); + $this->execute_remote_command([executeInDocker($this->deployment_uuid, "echo '{$this->nixpacks_plan}' | base64 -d | tee /artifacts/thegameplan.json > /dev/null"), 'hidden' => true]); if ($this->force_rebuild) { $this->execute_remote_command([ executeInDocker($this->deployment_uuid, "nixpacks build -c /artifacts/thegameplan.json --no-cache --no-error-without-start -n {$this->build_image_name} {$this->workdir} -o {$this->workdir}"), @@ -2179,7 +2198,7 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf"); $base64_build_command = base64_encode($build_command); $this->execute_remote_command( [ - transfer_file_to_container(base64_decode($base64_build_command), '/artifacts/build.sh', $this->deployment_uuid, $this->server), + executeInDocker($this->deployment_uuid, "echo '{$base64_build_command}' | base64 -d | tee /artifacts/build.sh > /dev/null"), 'hidden' => true, ], [ @@ -2202,7 +2221,7 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf"); } $this->execute_remote_command( [ - transfer_file_to_container(base64_decode($base64_build_command), '/artifacts/build.sh', $this->deployment_uuid, $this->server), + executeInDocker($this->deployment_uuid, "echo '{$base64_build_command}' | base64 -d | tee /artifacts/build.sh > /dev/null"), 'hidden' => true, ], [ @@ -2234,13 +2253,13 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf"); $base64_build_command = base64_encode($build_command); $this->execute_remote_command( [ - transfer_file_to_container(base64_decode($dockerfile), "{$this->workdir}/Dockerfile", $this->deployment_uuid, $this->server), + executeInDocker($this->deployment_uuid, "echo '{$dockerfile}' | base64 -d | tee {$this->workdir}/Dockerfile > /dev/null"), ], [ - transfer_file_to_container(base64_decode($nginx_config), "{$this->workdir}/nginx.conf", $this->deployment_uuid, $this->server), + executeInDocker($this->deployment_uuid, "echo '{$nginx_config}' | base64 -d | tee {$this->workdir}/nginx.conf > /dev/null"), ], [ - transfer_file_to_container(base64_decode($base64_build_command), '/artifacts/build.sh', $this->deployment_uuid, $this->server), + executeInDocker($this->deployment_uuid, "echo '{$base64_build_command}' | base64 -d | tee /artifacts/build.sh > /dev/null"), 'hidden' => true, ], [ @@ -2263,7 +2282,7 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf"); $base64_build_command = base64_encode($build_command); $this->execute_remote_command( [ - transfer_file_to_container(base64_decode($base64_build_command), '/artifacts/build.sh', $this->deployment_uuid, $this->server), + executeInDocker($this->deployment_uuid, "echo '{$base64_build_command}' | base64 -d | tee /artifacts/build.sh > /dev/null"), 'hidden' => true, ], [ @@ -2278,8 +2297,7 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf"); } else { if ($this->application->build_pack === 'nixpacks') { $this->nixpacks_plan = base64_encode($this->nixpacks_plan); - $nixpacks_content = base64_decode($this->nixpacks_plan); - transfer_file_to_container($nixpacks_content, '/artifacts/thegameplan.json', $this->deployment_uuid, $this->server); + $this->execute_remote_command([executeInDocker($this->deployment_uuid, "echo '{$this->nixpacks_plan}' | base64 -d | tee /artifacts/thegameplan.json > /dev/null"), 'hidden' => true]); if ($this->force_rebuild) { $this->execute_remote_command([ executeInDocker($this->deployment_uuid, "nixpacks build -c /artifacts/thegameplan.json --no-cache --no-error-without-start -n {$this->production_image_name} {$this->workdir} -o {$this->workdir}"), @@ -2302,7 +2320,7 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf"); $base64_build_command = base64_encode($build_command); $this->execute_remote_command( [ - transfer_file_to_container(base64_decode($base64_build_command), '/artifacts/build.sh', $this->deployment_uuid, $this->server), + executeInDocker($this->deployment_uuid, "echo '{$base64_build_command}' | base64 -d | tee /artifacts/build.sh > /dev/null"), 'hidden' => true, ], [ @@ -2325,7 +2343,7 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf"); } $this->execute_remote_command( [ - transfer_file_to_container(base64_decode($base64_build_command), '/artifacts/build.sh', $this->deployment_uuid, $this->server), + executeInDocker($this->deployment_uuid, "echo '{$base64_build_command}' | base64 -d | tee /artifacts/build.sh > /dev/null"), 'hidden' => true, ], [ @@ -2458,7 +2476,7 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf"); } $dockerfile_base64 = base64_encode($dockerfile->implode("\n")); $this->execute_remote_command([ - transfer_file_to_container(base64_decode($dockerfile_base64), "{$this->workdir}{$this->dockerfile_location}", $this->deployment_uuid, $this->server), + executeInDocker($this->deployment_uuid, "echo '{$dockerfile_base64}' | base64 -d | tee {$this->workdir}{$this->dockerfile_location} > /dev/null"), 'hidden' => true, ]); } diff --git a/app/Models/Server.php b/app/Models/Server.php index ae7f3f6c1..96ba74cde 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -1075,6 +1075,7 @@ $schema://$host { public function validateConnection(bool $justCheckingNewKey = false) { + ray('validateConnection', $this->id); $this->disableSshMux(); if ($this->skipServer()) { @@ -1312,6 +1313,7 @@ $schema://$host { public function generateCaCertificate() { try { + ray('Generating CA certificate for server', $this->id); SslHelper::generateSslCertificate( commonName: 'Coolify CA Certificate', serverId: $this->id, @@ -1319,6 +1321,7 @@ $schema://$host { validityDays: 10 * 365 ); $caCertificate = SslCertificate::where('server_id', $this->id)->where('is_ca_certificate', true)->first(); + ray('CA certificate generated', $caCertificate); if ($caCertificate) { $certificateContent = $caCertificate->ssl_certificate; $caCertPath = config('constants.coolify.base_config_path').'/ssl/'; diff --git a/app/Models/Service.php b/app/Models/Service.php index 615789e64..dd8d0ac7e 100644 --- a/app/Models/Service.php +++ b/app/Models/Service.php @@ -1280,10 +1280,8 @@ class Service extends BaseModel if ($envs->count() === 0) { $commands[] = 'touch .env'; } else { - $envs_content = $envs->implode("\n"); - transfer_file_to_server($envs_content, $this->workdir().'/.env', $this->server); - - return; + $envs_base64 = base64_encode($envs->implode("\n")); + $commands[] = "echo '$envs_base64' | base64 -d | tee .env > /dev/null"; } instant_remote_process($commands, $this->server); diff --git a/bootstrap/helpers/remoteProcess.php b/bootstrap/helpers/remoteProcess.php index bba3a4117..b4f64514b 100644 --- a/bootstrap/helpers/remoteProcess.php +++ b/bootstrap/helpers/remoteProcess.php @@ -47,10 +47,10 @@ function remote_process( } if ($server->isNonRoot()) { - $processed_commands = parseCommandsByLineForSudo(collect($processed_commands), $server); + $command = parseCommandsByLineForSudo(collect($command), $server); } - $command_string = implode("\n", $processed_commands); + $command_string = implode("\n", $command); if (Auth::check()) { $teams = Auth::user()->teams->pluck('id'); @@ -215,9 +215,9 @@ function instant_remote_process(Collection|array $command, Server $server, bool } if ($server->isNonRoot() && ! $no_sudo) { - $processed_commands = parseCommandsByLineForSudo(collect($processed_commands), $server); + $command = parseCommandsByLineForSudo(collect($command), $server); } - $command_string = implode("\n", $processed_commands); + $command_string = implode("\n", $command); return \App\Helpers\SshRetryHandler::retry( function () use ($server, $command_string) { From 133e72336a0c24f6ca6e5d1956037394dd528775 Mon Sep 17 00:00:00 2001 From: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com> Date: Mon, 15 Sep 2025 17:56:48 +0200 Subject: [PATCH 10/12] Revert "refactor(file-transfer): replace base64 encoding with direct file transfer method in various components for improved clarity and efficiency" This reverts commit feacedbb0427ace0154fca5d58e009931aeb2779. --- app/Livewire/Project/Database/Import.php | 8 +--- .../Server/Proxy/NewDynamicConfiguration.php | 5 ++- app/Models/Application.php | 43 +++++++++++-------- app/Models/LocalFileVolume.php | 7 ++- app/Models/Server.php | 13 ++++-- bootstrap/helpers/docker.php | 4 +- bootstrap/helpers/services.php | 3 +- 7 files changed, 48 insertions(+), 35 deletions(-) diff --git a/app/Livewire/Project/Database/Import.php b/app/Livewire/Project/Database/Import.php index 706c6c0cd..3f974f63d 100644 --- a/app/Livewire/Project/Database/Import.php +++ b/app/Livewire/Project/Database/Import.php @@ -232,12 +232,8 @@ EOD; break; } - $this->importCommands[] = [ - 'transfer_file' => [ - 'content' => $restoreCommand, - 'destination' => $scriptPath, - ], - ]; + $restoreCommandBase64 = base64_encode($restoreCommand); + $this->importCommands[] = "echo \"{$restoreCommandBase64}\" | base64 -d > {$scriptPath}"; $this->importCommands[] = "chmod +x {$scriptPath}"; $this->importCommands[] = "docker cp {$scriptPath} {$this->container}:{$scriptPath}"; diff --git a/app/Livewire/Server/Proxy/NewDynamicConfiguration.php b/app/Livewire/Server/Proxy/NewDynamicConfiguration.php index b564e208b..eb2db1cbb 100644 --- a/app/Livewire/Server/Proxy/NewDynamicConfiguration.php +++ b/app/Livewire/Server/Proxy/NewDynamicConfiguration.php @@ -78,7 +78,10 @@ class NewDynamicConfiguration extends Component $yaml = Yaml::dump($yaml, 10, 2); $this->value = $yaml; } - transfer_file_to_server($this->value, $file, $this->server); + $base64_value = base64_encode($this->value); + instant_remote_process([ + "echo '{$base64_value}' | base64 -d | tee {$file} > /dev/null", + ], $this->server); if ($proxy_type === 'CADDY') { $this->server->reloadCaddy(); } diff --git a/app/Models/Application.php b/app/Models/Application.php index 0ae50edca..1f48e0211 100644 --- a/app/Models/Application.php +++ b/app/Models/Application.php @@ -1073,20 +1073,26 @@ class Application extends BaseModel if (is_null($private_key)) { throw new RuntimeException('Private key not found. Please add a private key to the application and try again.'); } + $private_key = base64_encode($private_key); $base_comamnd = "GIT_SSH_COMMAND=\"ssh -o ConnectTimeout=30 -p {$customPort} -o Port={$customPort} -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /root/.ssh/id_rsa\" {$base_command} {$customRepository}"; - $commands = collect([]); + if ($exec_in_docker) { + $commands = collect([ + executeInDocker($deployment_uuid, 'mkdir -p /root/.ssh'), + executeInDocker($deployment_uuid, "echo '{$private_key}' | base64 -d | tee /root/.ssh/id_rsa > /dev/null"), + executeInDocker($deployment_uuid, 'chmod 600 /root/.ssh/id_rsa'), + ]); + } else { + $commands = collect([ + 'mkdir -p /root/.ssh', + "echo '{$private_key}' | base64 -d | tee /root/.ssh/id_rsa > /dev/null", + 'chmod 600 /root/.ssh/id_rsa', + ]); + } if ($exec_in_docker) { - $commands->push(executeInDocker($deployment_uuid, 'mkdir -p /root/.ssh')); - // SSH key transfer handled by ApplicationDeploymentJob, assume key is already in container - $commands->push(executeInDocker($deployment_uuid, 'chmod 600 /root/.ssh/id_rsa')); $commands->push(executeInDocker($deployment_uuid, $base_comamnd)); } else { - $server = $this->destination->server; - $commands->push('mkdir -p /root/.ssh'); - transfer_file_to_server($private_key, '/root/.ssh/id_rsa', $server); - $commands->push('chmod 600 /root/.ssh/id_rsa'); $commands->push($base_comamnd); } @@ -1212,6 +1218,7 @@ class Application extends BaseModel if (is_null($private_key)) { throw new RuntimeException('Private key not found. Please add a private key to the application and try again.'); } + $private_key = base64_encode($private_key); $escapedCustomRepository = escapeshellarg($customRepository); $git_clone_command_base = "GIT_SSH_COMMAND=\"ssh -o ConnectTimeout=30 -p {$customPort} -o Port={$customPort} -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /root/.ssh/id_rsa\" {$git_clone_command} {$escapedCustomRepository} {$escapedBaseDir}"; if ($only_checkout) { @@ -1219,18 +1226,18 @@ class Application extends BaseModel } else { $git_clone_command = $this->setGitImportSettings($deployment_uuid, $git_clone_command_base); } - - $commands = collect([]); - if ($exec_in_docker) { - $commands->push(executeInDocker($deployment_uuid, 'mkdir -p /root/.ssh')); - // SSH key transfer handled by ApplicationDeploymentJob, assume key is already in container - $commands->push(executeInDocker($deployment_uuid, 'chmod 600 /root/.ssh/id_rsa')); + $commands = collect([ + executeInDocker($deployment_uuid, 'mkdir -p /root/.ssh'), + executeInDocker($deployment_uuid, "echo '{$private_key}' | base64 -d | tee /root/.ssh/id_rsa > /dev/null"), + executeInDocker($deployment_uuid, 'chmod 600 /root/.ssh/id_rsa'), + ]); } else { - $server = $this->destination->server; - $commands->push('mkdir -p /root/.ssh'); - transfer_file_to_server($private_key, '/root/.ssh/id_rsa', $server); - $commands->push('chmod 600 /root/.ssh/id_rsa'); + $commands = collect([ + 'mkdir -p /root/.ssh', + "echo '{$private_key}' | base64 -d | tee /root/.ssh/id_rsa > /dev/null", + 'chmod 600 /root/.ssh/id_rsa', + ]); } if ($pull_request_id !== 0) { if ($git_type === 'gitlab') { diff --git a/app/Models/LocalFileVolume.php b/app/Models/LocalFileVolume.php index b19b6aa42..b3e71d75d 100644 --- a/app/Models/LocalFileVolume.php +++ b/app/Models/LocalFileVolume.php @@ -159,7 +159,8 @@ class LocalFileVolume extends BaseModel $chmod = data_get($this, 'chmod'); $chown = data_get($this, 'chown'); if ($content) { - transfer_file_to_server($content, $path, $server); + $content = base64_encode($content); + $commands->push("echo '$content' | base64 -d | tee $path > /dev/null"); } else { $commands->push("touch $path"); } @@ -174,9 +175,7 @@ class LocalFileVolume extends BaseModel $commands->push("mkdir -p $path > /dev/null 2>&1 || true"); } - if ($commands->count() > 0) { - return instant_remote_process($commands, $server); - } + return instant_remote_process($commands, $server); } // Accessor for convenient access diff --git a/app/Models/Server.php b/app/Models/Server.php index 96ba74cde..960091033 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -309,7 +309,10 @@ class Server extends BaseModel $conf = Yaml::dump($dynamic_conf, 12, 2); } $conf = $banner.$conf; - transfer_file_to_server($conf, $default_redirect_file, $this); + $base64 = base64_encode($conf); + instant_remote_process([ + "echo '$base64' | base64 -d | tee $default_redirect_file > /dev/null", + ], $this); } if ($proxy_type === 'CADDY') { @@ -443,10 +446,11 @@ class Server extends BaseModel "# Do not edit it manually (only if you know what are you doing).\n\n". $yaml; + $base64 = base64_encode($yaml); instant_remote_process([ "mkdir -p $dynamic_config_path", + "echo '$base64' | base64 -d | tee $file > /dev/null", ], $this); - transfer_file_to_server($yaml, $file, $this); } } elseif ($this->proxyType() === 'CADDY') { $file = "$dynamic_config_path/coolify.caddy"; @@ -469,7 +473,10 @@ $schema://$host { } reverse_proxy coolify:8080 }"; - transfer_file_to_server($caddy_file, $file, $this); + $base64 = base64_encode($caddy_file); + instant_remote_process([ + "echo '$base64' | base64 -d | tee $file > /dev/null", + ], $this); $this->reloadCaddy(); } } diff --git a/bootstrap/helpers/docker.php b/bootstrap/helpers/docker.php index 5cfddc599..f61abc806 100644 --- a/bootstrap/helpers/docker.php +++ b/bootstrap/helpers/docker.php @@ -1069,9 +1069,9 @@ function validateComposeFile(string $compose, int $server_id): string|Throwable } } } - $compose_content = Yaml::dump($yaml_compose); - transfer_file_to_server($compose_content, "/tmp/{$uuid}.yml", $server); + $base64_compose = base64_encode(Yaml::dump($yaml_compose)); instant_remote_process([ + "echo {$base64_compose} | base64 -d | tee /tmp/{$uuid}.yml > /dev/null", "chmod 600 /tmp/{$uuid}.yml", "docker compose -f /tmp/{$uuid}.yml config --no-interpolate --no-path-resolution -q", "rm /tmp/{$uuid}.yml", diff --git a/bootstrap/helpers/services.php b/bootstrap/helpers/services.php index 41b8857ee..a124272a2 100644 --- a/bootstrap/helpers/services.php +++ b/bootstrap/helpers/services.php @@ -69,11 +69,12 @@ function getFilesystemVolumesFromServer(ServiceApplication|ServiceDatabase|Appli $fileVolume->content = $content; $fileVolume->is_directory = false; $fileVolume->save(); + $content = base64_encode($content); $dir = str($fileLocation)->dirname(); instant_remote_process([ "mkdir -p $dir", + "echo '$content' | base64 -d | tee $fileLocation", ], $server); - transfer_file_to_server($content, $fileLocation, $server); } elseif ($isFile === 'NOK' && $isDir === 'NOK' && $fileVolume->is_directory && $isInit) { // Does not exists (no dir or file), flagged as directory, is init $fileVolume->content = null; From 60e31a13815a0e83439c946521e11e89ba802079 Mon Sep 17 00:00:00 2001 From: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com> Date: Mon, 15 Sep 2025 17:59:35 +0200 Subject: [PATCH 11/12] refactor(remoteProcess): remove file transfer handling from remote_process and instant_remote_process functions to simplify code --- bootstrap/helpers/remoteProcess.php | 34 ----------------------------- 1 file changed, 34 deletions(-) diff --git a/bootstrap/helpers/remoteProcess.php b/bootstrap/helpers/remoteProcess.php index b4f64514b..56386a55f 100644 --- a/bootstrap/helpers/remoteProcess.php +++ b/bootstrap/helpers/remoteProcess.php @@ -29,23 +29,6 @@ function remote_process( $type = $type ?? ActivityTypes::INLINE->value; $command = $command instanceof Collection ? $command->toArray() : $command; - // Process commands and handle file transfers - $processed_commands = []; - foreach ($command as $cmd) { - if (is_array($cmd) && isset($cmd['transfer_file'])) { - // Handle file transfer command - $transfer_data = $cmd['transfer_file']; - $content = $transfer_data['content']; - $destination = $transfer_data['destination']; - - // Execute file transfer immediately - transfer_file_to_server($content, $destination, $server, ! $ignore_errors); - } else { - // Regular string command - $processed_commands[] = $cmd; - } - } - if ($server->isNonRoot()) { $command = parseCommandsByLineForSudo(collect($command), $server); } @@ -197,23 +180,6 @@ function instant_remote_process(Collection|array $command, Server $server, bool { $command = $command instanceof Collection ? $command->toArray() : $command; - // Process commands and handle file transfers - $processed_commands = []; - foreach ($command as $cmd) { - if (is_array($cmd) && isset($cmd['transfer_file'])) { - // Handle file transfer command - $transfer_data = $cmd['transfer_file']; - $content = $transfer_data['content']; - $destination = $transfer_data['destination']; - - // Execute file transfer immediately - transfer_file_to_server($content, $destination, $server, $throwError); - } else { - // Regular string command - $processed_commands[] = $cmd; - } - } - if ($server->isNonRoot() && ! $no_sudo) { $command = parseCommandsByLineForSudo(collect($command), $server); } From 732207251885599e10a5d3f8967fa29adce2a88d Mon Sep 17 00:00:00 2001 From: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com> Date: Mon, 15 Sep 2025 18:05:11 +0200 Subject: [PATCH 12/12] refactor(deployment): update environment file paths in docker compose commands to use working directory for improved consistency --- app/Jobs/ApplicationDeploymentJob.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php index e38ff1c7d..e0e0f519e 100644 --- a/app/Jobs/ApplicationDeploymentJob.php +++ b/app/Jobs/ApplicationDeploymentJob.php @@ -482,7 +482,7 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue if (filled($this->env_filename)) { $services = collect(data_get($composeFile, 'services', [])); $services = $services->map(function ($service, $name) { - $service['env_file'] = ["/artifacts/{$this->env_filename}"]; + $service['env_file'] = [$this->env_filename]; return $service; }); @@ -511,7 +511,7 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue } else { $command = "{$this->coolify_variables} docker compose"; if (filled($this->env_filename)) { - $command .= " --env-file /artifacts/{$this->env_filename}"; + $command .= " --env-file {$this->workdir}/{$this->env_filename}"; } if ($this->force_rebuild) { $command .= " --project-name {$this->application->uuid} --project-directory {$this->workdir} -f {$this->workdir}{$this->docker_compose_location} build --pull --no-cache"; @@ -557,7 +557,7 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue $command = "{$this->coolify_variables} docker compose"; if (filled($this->env_filename)) { - $command .= " --env-file /artifacts/{$this->env_filename}"; + $command .= " --env-file {$server_workdir}/{$this->env_filename}"; } $command .= " --project-directory {$server_workdir} -f {$server_workdir}{$this->docker_compose_location} up -d"; $this->execute_remote_command( @@ -574,7 +574,7 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue $command = "{$this->coolify_variables} docker compose"; if ($this->preserveRepository) { if (filled($this->env_filename)) { - $command .= " --env-file /artifacts/{$this->env_filename}"; + $command .= " --env-file {$server_workdir}/{$this->env_filename}"; } $command .= " --project-name {$this->application->uuid} --project-directory {$server_workdir} -f {$server_workdir}{$this->docker_compose_location} up -d"; $this->write_deployment_configurations(); @@ -584,7 +584,7 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue ); } else { if (filled($this->env_filename)) { - $command .= " --env-file /artifacts/{$this->env_filename}"; + $command .= " --env-file {$this->workdir}/{$this->env_filename}"; } $command .= " --project-name {$this->application->uuid} --project-directory {$this->workdir} -f {$this->workdir}{$this->docker_compose_location} up -d"; $this->execute_remote_command( @@ -1889,7 +1889,7 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue ], ]; if (filled($this->env_filename)) { - $docker_compose['services'][$this->container_name]['env_file'] = ["/artifacts/{$this->env_filename}"]; + $docker_compose['services'][$this->container_name]['env_file'] = [$this->env_filename]; } $docker_compose['services'][$this->container_name]['healthcheck'] = [ 'test' => [