Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

refactor(deployment): remove commented-out code and streamline environment variable handling in ApplicationDeploymentJob

Andras Bacsai249ab06295bf
diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php
index b3dae9f41f..62fbe2df57 100644
--- a/app/Jobs/ApplicationDeploymentJob.php
+++ b/app/Jobs/ApplicationDeploymentJob.php
@@ -1792,22 +1792,11 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue
$created_new = true;
}
- // Always refresh the relationships to ensure we have the latest data
- // This is critical for the first deployment where variables were just created
if ($this->pull_request_id === 0) {
$this->application->load(['nixpacks_environment_variables', 'environment_variables']);
} else {
$this->application->load(['nixpacks_environment_variables_preview', 'environment_variables_preview']);
}
-
- // // Export these variables to /etc/environment in the helper container
- // $this->execute_remote_command([
- // executeInDocker($this->deployment_uuid, "echo 'NIXPACKS_PHP_FALLBACK_PATH=\"{$nixpacks_php_fallback_path->value}\"' >> /etc/environment"),
- // 'hidden' => true,
- // ], [
- // executeInDocker($this->deployment_uuid, "echo 'NIXPACKS_PHP_ROOT_DIR=\"{$nixpacks_php_root_dir->value}\"' >> /etc/environment"),
- // 'hidden' => true,
- // ]);
}
private function cleanup_git()
@@ -2530,16 +2519,7 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue
}
}
- // if ($this->dockerBuildkitSupported && $this->application->settings->use_build_secrets) {
- // $build_script = "#!/bin/bash\n";
- // $build_script .= "set -a\n";
- // $build_script .= "source /etc/environment 2>/dev/null || true\n";
- // $build_script .= "set +a\n";
- // $build_script .= $build_command;
- // $base64_build_command = base64_encode($build_script);
- // } else {
$base64_build_command = base64_encode($build_command);
- // }
$this->execute_remote_command(
[
executeInDocker($this->deployment_uuid, "echo '{$base64_build_command}' | base64 -d | tee /artifacts/build.sh > /dev/null"),
@@ -2605,16 +2585,7 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf");
}
}
$build_command = "docker build {$this->addHosts} --network host -f {$this->workdir}/Dockerfile {$this->build_args} --progress plain -t {$this->production_image_name} {$this->workdir}";
- // if ($this->dockerBuildkitSupported && $this->application->settings->use_build_secrets) {
- // $build_script = "#!/bin/bash\n";
- // $build_script .= "set -a\n";
- // $build_script .= "source /etc/environment 2>/dev/null || true\n";
- // $build_script .= "set +a\n";
- // $build_script .= $build_command;
- // $base64_build_command = base64_encode($build_script);
- // } else {
$base64_build_command = base64_encode($build_command);
- // }
$this->execute_remote_command(
[
executeInDocker($this->deployment_uuid, "echo '{$dockerfile}' | base64 -d | tee {$this->workdir}/Dockerfile > /dev/null"),
@@ -2655,16 +2626,7 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf");
$build_command = "docker build --pull {$this->buildTarget} {$this->addHosts} --network host -f {$this->workdir}{$this->dockerfile_location} {$this->build_args} --progress plain -t {$this->production_image_name} {$this->workdir}";
}
}
- // if ($this->dockerBuildkitSupported && $this->application->settings->use_build_secrets) {
- // $build_script = "#!/bin/bash\n";
- // $build_script .= "set -a\n";
- // $build_script .= "source /etc/environment 2>/dev/null || true\n";
- // $build_script .= "set +a\n";
- // $build_script .= $build_command;
- // $base64_build_command = base64_encode($build_script);
- // } else {
$base64_build_command = base64_encode($build_command);
- // }
$this->execute_remote_command(
[
executeInDocker($this->deployment_uuid, "echo '{$base64_build_command}' | base64 -d | tee /artifacts/build.sh > /dev/null"),
@@ -2716,17 +2678,7 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf");
$build_command = "docker build {$this->addHosts} --network host -f {$this->workdir}/.nixpacks/Dockerfile --progress plain -t {$this->production_image_name} {$this->build_args} {$this->workdir}";
}
}
- // If using build secrets, prepend source of /etc/environment to the build script
- // if ($this->dockerBuildkitSupported && $this->application->settings->use_build_secrets) {
- // $build_script = "#!/bin/bash\n";
- // $build_script .= "set -a\n";
- // $build_script .= "source /etc/environment 2>/dev/null || true\n";
- // $build_script .= "set +a\n";
- // $build_script .= $build_command;
- // $base64_build_command = base64_encode($build_script);
- // } else {
$base64_build_command = base64_encode($build_command);
- // }
$this->execute_remote_command(
[
executeInDocker($this->deployment_uuid, "echo '{$base64_build_command}' | base64 -d | tee /artifacts/build.sh > /dev/null"),
@@ -2760,17 +2712,7 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf");
$build_command = "docker build {$this->buildTarget} {$this->addHosts} --network host -f {$this->workdir}{$this->dockerfile_location} {$this->build_args} --progress plain -t {$this->production_image_name} {$this->workdir}";
}
}
- // If using build secrets, prepend source of /etc/environment to the build script
- // if ($this->dockerBuildkitSupported && $this->application->settings->use_build_secrets) {
- // $build_script = "#!/bin/bash\n";
- // $build_script .= "set -a\n";
- // $build_script .= "source /etc/environment 2>/dev/null || true\n";
- // $build_script .= "set +a\n";
- // $build_script .= $build_command;
- // $base64_build_command = base64_encode($build_script);
- // } else {
$base64_build_command = base64_encode($build_command);
- // }
$this->execute_remote_command(
[
executeInDocker($this->deployment_uuid, "echo '{$base64_build_command}' | base64 -d | tee /artifacts/build.sh > /dev/null"),