Revert "refactor(file-transfer): replace base64 encoding with direct file transfer method in various components for improved clarity and efficiency"
This reverts commit feacedbb04
.
This commit is contained in:
@@ -232,12 +232,8 @@ EOD;
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->importCommands[] = [
|
$restoreCommandBase64 = base64_encode($restoreCommand);
|
||||||
'transfer_file' => [
|
$this->importCommands[] = "echo \"{$restoreCommandBase64}\" | base64 -d > {$scriptPath}";
|
||||||
'content' => $restoreCommand,
|
|
||||||
'destination' => $scriptPath,
|
|
||||||
],
|
|
||||||
];
|
|
||||||
$this->importCommands[] = "chmod +x {$scriptPath}";
|
$this->importCommands[] = "chmod +x {$scriptPath}";
|
||||||
$this->importCommands[] = "docker cp {$scriptPath} {$this->container}:{$scriptPath}";
|
$this->importCommands[] = "docker cp {$scriptPath} {$this->container}:{$scriptPath}";
|
||||||
|
|
||||||
|
@@ -78,7 +78,10 @@ class NewDynamicConfiguration extends Component
|
|||||||
$yaml = Yaml::dump($yaml, 10, 2);
|
$yaml = Yaml::dump($yaml, 10, 2);
|
||||||
$this->value = $yaml;
|
$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') {
|
if ($proxy_type === 'CADDY') {
|
||||||
$this->server->reloadCaddy();
|
$this->server->reloadCaddy();
|
||||||
}
|
}
|
||||||
|
@@ -1073,20 +1073,26 @@ class Application extends BaseModel
|
|||||||
if (is_null($private_key)) {
|
if (is_null($private_key)) {
|
||||||
throw new RuntimeException('Private key not found. Please add a private key to the application and try again.');
|
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}";
|
$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) {
|
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));
|
$commands->push(executeInDocker($deployment_uuid, $base_comamnd));
|
||||||
} else {
|
} 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);
|
$commands->push($base_comamnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1212,6 +1218,7 @@ class Application extends BaseModel
|
|||||||
if (is_null($private_key)) {
|
if (is_null($private_key)) {
|
||||||
throw new RuntimeException('Private key not found. Please add a private key to the application and try again.');
|
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);
|
$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}";
|
$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) {
|
if ($only_checkout) {
|
||||||
@@ -1219,18 +1226,18 @@ class Application extends BaseModel
|
|||||||
} else {
|
} else {
|
||||||
$git_clone_command = $this->setGitImportSettings($deployment_uuid, $git_clone_command_base);
|
$git_clone_command = $this->setGitImportSettings($deployment_uuid, $git_clone_command_base);
|
||||||
}
|
}
|
||||||
|
|
||||||
$commands = collect([]);
|
|
||||||
|
|
||||||
if ($exec_in_docker) {
|
if ($exec_in_docker) {
|
||||||
$commands->push(executeInDocker($deployment_uuid, 'mkdir -p /root/.ssh'));
|
$commands = collect([
|
||||||
// SSH key transfer handled by ApplicationDeploymentJob, assume key is already in container
|
executeInDocker($deployment_uuid, 'mkdir -p /root/.ssh'),
|
||||||
$commands->push(executeInDocker($deployment_uuid, 'chmod 600 /root/.ssh/id_rsa'));
|
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 {
|
} else {
|
||||||
$server = $this->destination->server;
|
$commands = collect([
|
||||||
$commands->push('mkdir -p /root/.ssh');
|
'mkdir -p /root/.ssh',
|
||||||
transfer_file_to_server($private_key, '/root/.ssh/id_rsa', $server);
|
"echo '{$private_key}' | base64 -d | tee /root/.ssh/id_rsa > /dev/null",
|
||||||
$commands->push('chmod 600 /root/.ssh/id_rsa');
|
'chmod 600 /root/.ssh/id_rsa',
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
if ($pull_request_id !== 0) {
|
if ($pull_request_id !== 0) {
|
||||||
if ($git_type === 'gitlab') {
|
if ($git_type === 'gitlab') {
|
||||||
|
@@ -159,7 +159,8 @@ class LocalFileVolume extends BaseModel
|
|||||||
$chmod = data_get($this, 'chmod');
|
$chmod = data_get($this, 'chmod');
|
||||||
$chown = data_get($this, 'chown');
|
$chown = data_get($this, 'chown');
|
||||||
if ($content) {
|
if ($content) {
|
||||||
transfer_file_to_server($content, $path, $server);
|
$content = base64_encode($content);
|
||||||
|
$commands->push("echo '$content' | base64 -d | tee $path > /dev/null");
|
||||||
} else {
|
} else {
|
||||||
$commands->push("touch $path");
|
$commands->push("touch $path");
|
||||||
}
|
}
|
||||||
@@ -174,10 +175,8 @@ class LocalFileVolume extends BaseModel
|
|||||||
$commands->push("mkdir -p $path > /dev/null 2>&1 || true");
|
$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
|
// Accessor for convenient access
|
||||||
protected function plainMountPath(): Attribute
|
protected function plainMountPath(): Attribute
|
||||||
|
@@ -309,7 +309,10 @@ class Server extends BaseModel
|
|||||||
$conf = Yaml::dump($dynamic_conf, 12, 2);
|
$conf = Yaml::dump($dynamic_conf, 12, 2);
|
||||||
}
|
}
|
||||||
$conf = $banner.$conf;
|
$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') {
|
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".
|
"# Do not edit it manually (only if you know what are you doing).\n\n".
|
||||||
$yaml;
|
$yaml;
|
||||||
|
|
||||||
|
$base64 = base64_encode($yaml);
|
||||||
instant_remote_process([
|
instant_remote_process([
|
||||||
"mkdir -p $dynamic_config_path",
|
"mkdir -p $dynamic_config_path",
|
||||||
|
"echo '$base64' | base64 -d | tee $file > /dev/null",
|
||||||
], $this);
|
], $this);
|
||||||
transfer_file_to_server($yaml, $file, $this);
|
|
||||||
}
|
}
|
||||||
} elseif ($this->proxyType() === 'CADDY') {
|
} elseif ($this->proxyType() === 'CADDY') {
|
||||||
$file = "$dynamic_config_path/coolify.caddy";
|
$file = "$dynamic_config_path/coolify.caddy";
|
||||||
@@ -469,7 +473,10 @@ $schema://$host {
|
|||||||
}
|
}
|
||||||
reverse_proxy coolify:8080
|
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();
|
$this->reloadCaddy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1069,9 +1069,9 @@ function validateComposeFile(string $compose, int $server_id): string|Throwable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$compose_content = Yaml::dump($yaml_compose);
|
$base64_compose = base64_encode(Yaml::dump($yaml_compose));
|
||||||
transfer_file_to_server($compose_content, "/tmp/{$uuid}.yml", $server);
|
|
||||||
instant_remote_process([
|
instant_remote_process([
|
||||||
|
"echo {$base64_compose} | base64 -d | tee /tmp/{$uuid}.yml > /dev/null",
|
||||||
"chmod 600 /tmp/{$uuid}.yml",
|
"chmod 600 /tmp/{$uuid}.yml",
|
||||||
"docker compose -f /tmp/{$uuid}.yml config --no-interpolate --no-path-resolution -q",
|
"docker compose -f /tmp/{$uuid}.yml config --no-interpolate --no-path-resolution -q",
|
||||||
"rm /tmp/{$uuid}.yml",
|
"rm /tmp/{$uuid}.yml",
|
||||||
|
@@ -69,11 +69,12 @@ function getFilesystemVolumesFromServer(ServiceApplication|ServiceDatabase|Appli
|
|||||||
$fileVolume->content = $content;
|
$fileVolume->content = $content;
|
||||||
$fileVolume->is_directory = false;
|
$fileVolume->is_directory = false;
|
||||||
$fileVolume->save();
|
$fileVolume->save();
|
||||||
|
$content = base64_encode($content);
|
||||||
$dir = str($fileLocation)->dirname();
|
$dir = str($fileLocation)->dirname();
|
||||||
instant_remote_process([
|
instant_remote_process([
|
||||||
"mkdir -p $dir",
|
"mkdir -p $dir",
|
||||||
|
"echo '$content' | base64 -d | tee $fileLocation",
|
||||||
], $server);
|
], $server);
|
||||||
transfer_file_to_server($content, $fileLocation, $server);
|
|
||||||
} elseif ($isFile === 'NOK' && $isDir === 'NOK' && $fileVolume->is_directory && $isInit) {
|
} elseif ($isFile === 'NOK' && $isDir === 'NOK' && $fileVolume->is_directory && $isInit) {
|
||||||
// Does not exists (no dir or file), flagged as directory, is init
|
// Does not exists (no dir or file), flagged as directory, is init
|
||||||
$fileVolume->content = null;
|
$fileVolume->content = null;
|
||||||
|
Reference in New Issue
Block a user