refactor(deployment): optimize BuildKit capabilities detection and remove unnecessary comments for cleaner deployment logic

This commit is contained in:
Andras Bacsai 2025-09-17 15:18:26 +02:00
parent c1bee32f09
commit d7a7bac3f1

View file

@ -276,9 +276,6 @@ public function handle(): void
try {
// Make sure the private key is stored in the filesystem
$this->server->privateKey->storeInFileSystem();
$this->detectBuildKitCapabilities();
// Generate custom host<->ip mapping
$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->original_server = $this->server;
}
$this->detectBuildKitCapabilities();
$this->decide_what_to_do();
} catch (Exception $e) {
if ($this->pull_request_id !== 0 && $this->application->is_github_based()) {
@ -1421,7 +1419,6 @@ private function deploy_pull_request()
}
$this->build_image();
$this->push_to_docker_registry();
// $this->stop_running_container();
$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);
$env_flags = $this->generate_docker_env_flags_for_secrets();
ray($env_flags);
if ($this->use_build_server) {
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.');
@ -2713,7 +2710,7 @@ private function generate_build_secrets(Collection $variables)
private function add_build_env_variables_to_dockerfile()
{
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 {
$this->execute_remote_command([
executeInDocker($this->deployment_uuid, "cat {$this->workdir}{$this->dockerfile_location}"),