fix: build server dirs not created on main server

This commit is contained in:
Andras Bacsai 2024-05-29 11:17:16 +02:00
parent e26f4ce707
commit aaa06f4120

View File

@ -817,7 +817,6 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
$this->env_filename = null; $this->env_filename = null;
if ($this->use_build_server) { if ($this->use_build_server) {
$this->server = $this->original_server; $this->server = $this->original_server;
}
$this->execute_remote_command( $this->execute_remote_command(
[ [
"command" => "rm -f $this->configuration_dir/{$this->env_filename}", "command" => "rm -f $this->configuration_dir/{$this->env_filename}",
@ -825,8 +824,22 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
"ignore_errors" => true "ignore_errors" => true
] ]
); );
if ($this->use_build_server) {
$this->server = $this->build_server; $this->server = $this->build_server;
$this->execute_remote_command(
[
"command" => "rm -f $this->configuration_dir/{$this->env_filename}",
"hidden" => true,
"ignore_errors" => true
]
);
} else {
$this->execute_remote_command(
[
"command" => "rm -f $this->configuration_dir/{$this->env_filename}",
"hidden" => true,
"ignore_errors" => true
]
);
} }
} else { } else {
$envs_base64 = base64_encode($envs->implode("\n")); $envs_base64 = base64_encode($envs->implode("\n"));
@ -838,39 +851,22 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
); );
if ($this->use_build_server) { if ($this->use_build_server) {
$this->server = $this->original_server; $this->server = $this->original_server;
}
$this->execute_remote_command( $this->execute_remote_command(
[ [
"echo '$envs_base64' | base64 -d | tee $this->configuration_dir/{$this->env_filename} > /dev/null" "echo '$envs_base64' | base64 -d | tee $this->configuration_dir/{$this->env_filename} > /dev/null"
] ]
); );
if ($this->use_build_server) {
$this->server = $this->build_server; $this->server = $this->build_server;
} else {
$this->execute_remote_command(
[
"echo '$envs_base64' | base64 -d | tee $this->configuration_dir/{$this->env_filename} > /dev/null"
]
);
} }
}
// $this->execute_remote_command([
// executeInDocker($this->deployment_uuid, "cat $this->workdir/.env 2>/dev/null || true"),
// "hidden" => true,
// "save" => "dotenv"
// ]);
// if (str($this->saved_outputs->get('dotenv'))->isNotEmpty()) {
// $base64_dotenv = base64_encode($this->saved_outputs->get('dotenv')->value());
// $this->execute_remote_command(
// [
// "echo '{$base64_dotenv}' | base64 -d | tee $this->configuration_dir/.env > /dev/null"
// ]
// );
// } else {
// $this->execute_remote_command(
// [
// "command" => "rm -f $this->configuration_dir/.env",
// "hidden" => true,
// "ignore_errors" => true
// ]
// );
// }
} }
}
private function framework_based_notification() private function framework_based_notification()
@ -1052,6 +1048,14 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
} }
private function create_workdir() private function create_workdir()
{ {
if ($this->use_build_server) {
$this->server = $this->original_server;
$this->execute_remote_command(
[
"command" => "mkdir -p {$this->configuration_dir}"
],
);
$this->server = $this->build_server;
$this->execute_remote_command( $this->execute_remote_command(
[ [
"command" => executeInDocker($this->deployment_uuid, "mkdir -p {$this->workdir}") "command" => executeInDocker($this->deployment_uuid, "mkdir -p {$this->workdir}")
@ -1060,6 +1064,16 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
"command" => "mkdir -p {$this->configuration_dir}" "command" => "mkdir -p {$this->configuration_dir}"
], ],
); );
} else {
$this->execute_remote_command(
[
"command" => executeInDocker($this->deployment_uuid, "mkdir -p {$this->workdir}")
],
[
"command" => "mkdir -p {$this->configuration_dir}"
],
);
}
} }
private function prepare_builder_image() private function prepare_builder_image()
{ {