refactor(deployment): optimize BuildKit capabilities detection and remove unnecessary comments for cleaner deployment logic
This commit is contained in:
parent
c1bee32f09
commit
d7a7bac3f1
1 changed files with 3 additions and 6 deletions
|
|
@ -276,9 +276,6 @@ public function handle(): void
|
||||||
try {
|
try {
|
||||||
// Make sure the private key is stored in the filesystem
|
// Make sure the private key is stored in the filesystem
|
||||||
$this->server->privateKey->storeInFileSystem();
|
$this->server->privateKey->storeInFileSystem();
|
||||||
|
|
||||||
$this->detectBuildKitCapabilities();
|
|
||||||
|
|
||||||
// Generate custom host<->ip mapping
|
// Generate custom host<->ip mapping
|
||||||
$allContainers = instant_remote_process(["docker network inspect {$this->destination->network} -f '{{json .Containers}}' "], $this->server);
|
$allContainers = instant_remote_process(["docker network inspect {$this->destination->network} -f '{{json .Containers}}' "], $this->server);
|
||||||
|
|
||||||
|
|
@ -334,6 +331,7 @@ public function handle(): void
|
||||||
$this->build_server = $this->server;
|
$this->build_server = $this->server;
|
||||||
$this->original_server = $this->server;
|
$this->original_server = $this->server;
|
||||||
}
|
}
|
||||||
|
$this->detectBuildKitCapabilities();
|
||||||
$this->decide_what_to_do();
|
$this->decide_what_to_do();
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
if ($this->pull_request_id !== 0 && $this->application->is_github_based()) {
|
if ($this->pull_request_id !== 0 && $this->application->is_github_based()) {
|
||||||
|
|
@ -1421,7 +1419,6 @@ private function deploy_pull_request()
|
||||||
}
|
}
|
||||||
$this->build_image();
|
$this->build_image();
|
||||||
$this->push_to_docker_registry();
|
$this->push_to_docker_registry();
|
||||||
// $this->stop_running_container();
|
|
||||||
$this->rolling_update();
|
$this->rolling_update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1466,7 +1463,7 @@ private function prepare_builder_image()
|
||||||
$this->dockerConfigFileExists = instant_remote_process(["test -f {$this->serverUserHomeDir}/.docker/config.json && echo 'OK' || echo 'NOK'"], $this->server);
|
$this->dockerConfigFileExists = instant_remote_process(["test -f {$this->serverUserHomeDir}/.docker/config.json && echo 'OK' || echo 'NOK'"], $this->server);
|
||||||
|
|
||||||
$env_flags = $this->generate_docker_env_flags_for_secrets();
|
$env_flags = $this->generate_docker_env_flags_for_secrets();
|
||||||
ray($env_flags);
|
|
||||||
if ($this->use_build_server) {
|
if ($this->use_build_server) {
|
||||||
if ($this->dockerConfigFileExists === 'NOK') {
|
if ($this->dockerConfigFileExists === 'NOK') {
|
||||||
throw new RuntimeException('Docker config file (~/.docker/config.json) not found on the build server. Please run "docker login" to login to the docker registry on the server.');
|
throw new RuntimeException('Docker config file (~/.docker/config.json) not found on the build server. Please run "docker login" to login to the docker registry on the server.');
|
||||||
|
|
@ -2713,7 +2710,7 @@ private function generate_build_secrets(Collection $variables)
|
||||||
private function add_build_env_variables_to_dockerfile()
|
private function add_build_env_variables_to_dockerfile()
|
||||||
{
|
{
|
||||||
if ($this->dockerBuildkitSupported) {
|
if ($this->dockerBuildkitSupported) {
|
||||||
// $this->add_buildkit_secrets_to_dockerfile();
|
// We dont need to add build secrets to dockerfile for buildkit, as we already added them with --secret flag in function generate_docker_env_flags_for_secrets
|
||||||
} else {
|
} else {
|
||||||
$this->execute_remote_command([
|
$this->execute_remote_command([
|
||||||
executeInDocker($this->deployment_uuid, "cat {$this->workdir}{$this->dockerfile_location}"),
|
executeInDocker($this->deployment_uuid, "cat {$this->workdir}{$this->dockerfile_location}"),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue