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.

fix(deployment): save runtime environment variables when skipping build

Andras Bacsaibc8cf8ed8475
diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php
index 580d1743e7..8ffaabde53 100644
--- a/app/Jobs/ApplicationDeploymentJob.php
+++ b/app/Jobs/ApplicationDeploymentJob.php
@@ -1005,6 +1005,10 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue
$this->skip_build = true;
$this->application_deployment_queue->addLogEntry("Image found ({$this->production_image_name}) with the same Git Commit SHA. Build step skipped.");
$this->generate_compose_file();
+
+ // Save runtime environment variables even when skipping build
+ $this->save_runtime_environment_variables();
+
$this->push_to_docker_registry();
$this->rolling_update();
@@ -1014,6 +1018,10 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue
$this->application_deployment_queue->addLogEntry("No configuration changed & image found ({$this->production_image_name}) with the same Git Commit SHA. Build step skipped.");
$this->skip_build = true;
$this->generate_compose_file();
+
+ // Save runtime environment variables even when skipping build
+ $this->save_runtime_environment_variables();
+
$this->push_to_docker_registry();
$this->rolling_update();
@@ -1694,7 +1702,7 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue
}
}
- private function prepare_builder_image()
+ private function prepare_builder_image(bool $firstTry = true)
{
$this->checkForCancellation();
$settings = instanceSettings();
@@ -1717,7 +1725,12 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue
$runCommand = "docker run -d --network {$this->destination->network} --name {$this->deployment_uuid} {$env_flags} --rm -v /var/run/docker.sock:/var/run/docker.sock {$helperImage}";
}
}
- $this->application_deployment_queue->addLogEntry("Preparing container with helper image: $helperImage.");
+ if ($firstTry) {
+ $this->application_deployment_queue->addLogEntry("Preparing container with helper image: $helperImage");
+ } else {
+ $this->application_deployment_queue->addLogEntry('Preparing container with helper image with updated envs.');
+ }
+
$this->graceful_shutdown_container($this->deployment_uuid);
$this->execute_remote_command(
[
@@ -1740,7 +1753,7 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue
$this->env_args = null;
// Restart the helper container with updated environment variables (including actual SOURCE_COMMIT)
- $this->prepare_builder_image();
+ $this->prepare_builder_image(firstTry: false);
}
private function deploy_to_additional_destinations()