From 2e4fd1530cc50f09ddd99f589c607d03d4ce1f14 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Mon, 10 Jun 2024 21:57:13 +0200 Subject: [PATCH] fix: multiline build args --- app/Jobs/ApplicationDeploymentJob.php | 34 +++++++++++---------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php index 35d6aad0a..fa362875f 100644 --- a/app/Jobs/ApplicationDeploymentJob.php +++ b/app/Jobs/ApplicationDeploymentJob.php @@ -244,13 +244,13 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted } else { $this->write_deployment_configurations(); } - $this->execute_remote_command( - [ - "docker rm -f {$this->deployment_uuid} >/dev/null 2>&1", - "hidden" => true, - "ignore_errors" => true, - ] - ); + // $this->execute_remote_command( + // [ + // "docker rm -f {$this->deployment_uuid} >/dev/null 2>&1", + // "hidden" => true, + // "ignore_errors" => true, + // ] + // ); // $this->execute_remote_command( @@ -1949,22 +1949,17 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf"); if ($this->pull_request_id === 0) { foreach ($this->application->build_environment_variables as $env) { $value = escapeshellarg($env->real_value); - if (str($value)->contains("\n") && data_get($env, 'is_multiline') === true) { - $value = str_replace("\n", "\\\n", $value); - } $this->build_args->push("--build-arg {$env->key}={$value}"); } } else { foreach ($this->application->build_environment_variables_preview as $env) { $value = escapeshellarg($env->real_value); - if (str($value)->contains("\n") && data_get($env, 'is_multiline') === true) { - $value = str_replace("\n", "\\\n", $value); - } $this->build_args->push("--build-arg {$env->key}={$value}"); } } $this->build_args = $this->build_args->implode(' '); + ray($this->build_args); } private function add_build_env_variables_to_dockerfile() @@ -1975,19 +1970,18 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf"); $dockerfile = collect(Str::of($this->saved_outputs->get('dockerfile'))->trim()->explode("\n")); if ($this->pull_request_id === 0) { foreach ($this->application->build_environment_variables as $env) { - if (str($env->real_value)->contains("\n") && data_get($env, 'is_multiline') === true) { - $value = str_replace("\n", "\\\n", $env->real_value); + if (data_get($env, 'is_multiline') === true) { + $dockerfile->splice(1, 0, "ARG {$env->key}"); } else { - $value = $env->real_value; + $dockerfile->splice(1, 0, "ARG {$env->key}={$env->real_value}"); } - $dockerfile->splice(1, 0, "ARG {$env->key}={$value}"); } } else { foreach ($this->application->build_environment_variables_preview as $env) { - if (str($env->real_value)->contains("\n") && data_get($env, 'is_multiline') === true) { - $value = str_replace("\n", "\\\n", $env->real_value); + if (data_get($env, 'is_multiline') === true) { + $dockerfile->splice(1, 0, "ARG {$env->key}"); } else { - $value = $env->real_value; + $dockerfile->splice(1, 0, "ARG {$env->key}={$env->real_value}"); } $dockerfile->splice(1, 0, "ARG {$env->key}={$env->real_value}"); }