refactor(file-transfer): replace base64 encoding with direct file transfer method across multiple database actions for improved clarity and efficiency
This commit is contained in:
@@ -40,7 +40,12 @@ class ConfigureCloudflared
|
||||
$commands = collect([
|
||||
'mkdir -p /tmp/cloudflared',
|
||||
'cd /tmp/cloudflared',
|
||||
"echo '$docker_compose_yml_base64' | base64 -d | tee docker-compose.yml > /dev/null",
|
||||
[
|
||||
'transfer_file' => [
|
||||
'content' => base64_decode($docker_compose_yml_base64),
|
||||
'destination' => '/tmp/cloudflared/docker-compose.yml',
|
||||
],
|
||||
],
|
||||
'echo Pulling latest Cloudflare Tunnel image.',
|
||||
'docker compose pull',
|
||||
'echo Stopping existing Cloudflare Tunnel container.',
|
||||
|
||||
@@ -14,6 +14,7 @@ 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) {
|
||||
@@ -103,8 +104,15 @@ 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")"',
|
||||
"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",
|
||||
[
|
||||
'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',
|
||||
'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",
|
||||
|
||||
@@ -180,10 +180,30 @@ Files:
|
||||
$command = [
|
||||
"echo 'Saving configuration'",
|
||||
"mkdir -p $config_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",
|
||||
[
|
||||
'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,
|
||||
],
|
||||
],
|
||||
"test -f $config_path/.env && rm $config_path/.env",
|
||||
];
|
||||
if ($type === 'newrelic') {
|
||||
|
||||
Reference in New Issue
Block a user