diff --git a/app/Http/Livewire/Project/Application/General.php b/app/Http/Livewire/Project/Application/General.php
index 810c7cc42..71d75a7c5 100644
--- a/app/Http/Livewire/Project/Application/General.php
+++ b/app/Http/Livewire/Project/Application/General.php
@@ -22,6 +22,7 @@ class General extends Component
public $customLabels;
public bool $labelsChanged = false;
+ public bool $isConfigurationChanged = false;
public bool $is_static;
public bool $is_git_submodules_enabled;
@@ -79,6 +80,7 @@ class General extends Component
public function mount()
{
+ $this->isConfigurationChanged = $this->application->isConfigurationChanged();
if (is_null(data_get($this->application, 'custom_labels'))) {
$this->customLabels = str(implode(",", generateLabelsApplication($this->application)))->replace(',', "\n");
} else {
@@ -131,6 +133,7 @@ class General extends Component
$this->application->refresh();
$this->emit('success', 'Application settings updated!');
$this->checkLabelUpdates();
+ $this->isConfigurationChanged = $this->application->isConfigurationChanged();
}
public function getWildcardDomain()
@@ -192,6 +195,7 @@ class General extends Component
return handleError($e, $this);
} finally {
$this->checkLabelUpdates();
+ $this->isConfigurationChanged = $this->application->isConfigurationChanged();
}
}
}
diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php
index 636adb35a..a6d6050bf 100644
--- a/app/Jobs/ApplicationDeploymentJob.php
+++ b/app/Jobs/ApplicationDeploymentJob.php
@@ -78,7 +78,7 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
public $tries = 1;
public function __construct(int $application_deployment_queue_id)
{
- ray()->clearScreen();
+ // ray()->clearScreen();
$this->application_deployment_queue = ApplicationDeploymentQueue::find($application_deployment_queue_id);
$this->log_model = $this->application_deployment_queue;
$this->application = Application::find($this->application_deployment_queue->application_id);
@@ -185,6 +185,7 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
dispatch(new ContainerStatusJob($this->server));
}
$this->next(ApplicationDeploymentStatus::FINISHED->value);
+ $this->application->isConfigurationChanged(true);
} catch (Exception $e) {
ray($e);
$this->fail($e);
@@ -353,14 +354,19 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
$this->execute_remote_command([
"docker images -q {$this->production_image_name} 2>/dev/null", "hidden" => true, "save" => "local_image_found"
]);
- if (Str::of($this->saved_outputs->get('local_image_found'))->isNotEmpty()) {
+ if (Str::of($this->saved_outputs->get('local_image_found'))->isNotEmpty() && !$this->application->isConfigurationChanged()) {
$this->execute_remote_command([
- "echo 'Docker Image found locally with the same Git Commit SHA {$this->application->uuid}:{$this->commit}. Build step skipped...'"
+ "echo 'No configuration changed & Docker Image found locally with the same Git Commit SHA {$this->application->uuid}:{$this->commit}. Build step skipped.'",
]);
$this->generate_compose_file();
$this->rolling_update();
return;
}
+ if ($this->application->isConfigurationChanged()) {
+ $this->execute_remote_command([
+ "echo 'Configuration changed. Rebuilding image.'",
+ ]);
+ }
}
$this->cleanup_git();
$this->generate_nixpacks_confs();
diff --git a/app/Models/Application.php b/app/Models/Application.php
index e5bf9db07..2e6c2814d 100644
--- a/app/Models/Application.php
+++ b/app/Models/Application.php
@@ -277,4 +277,31 @@ class Application extends BaseModel
}
return false;
}
+ public function isConfigurationChanged($save = false)
+ {
+ $newConfigHash = $this->fqdn . $this->git_repository . $this->git_branch . $this->git_commit_sha . $this->build_pack . $this->static_image . $this->install_command . $this->build_command . $this->start_command . $this->port_exposes . $this->port_mappings . $this->base_directory . $this->publish_directory . $this->health_check_path . $this->health_check_port . $this->health_check_host . $this->health_check_method . $this->health_check_return_code . $this->health_check_scheme . $this->health_check_response_text . $this->health_check_interval . $this->health_check_timeout . $this->health_check_retries . $this->health_check_start_period . $this->health_check_enabled . $this->limits_memory . $this->limits_swap . $this->limits_swappiness . $this->limits_reservation . $this->limits_cpus . $this->limits_cpuset . $this->limits_cpu_shares . $this->dockerfile . $this->dockerfile_location . $this->custom_labels;
+ if ($this->pull_request_id === 0) {
+ $newConfigHash .= json_encode($this->environment_variables->all());
+ } else {
+ $newConfigHash .= json_encode($this->environment_variables_preview->all());
+ }
+ $newConfigHash = md5($newConfigHash);
+ $oldConfigHash = data_get($this, 'config_hash');
+ if ($oldConfigHash === null) {
+ if ($save) {
+ $this->config_hash = $newConfigHash;
+ $this->save();
+ }
+ return true;
+ }
+ if ($oldConfigHash === $newConfigHash) {
+ return false;
+ } else {
+ if ($save) {
+ $this->config_hash = $newConfigHash;
+ $this->save();
+ }
+ return true;
+ }
+ }
}
diff --git a/resources/views/livewire/project/application/general.blade.php b/resources/views/livewire/project/application/general.blade.php
index b554b8ff5..71a63248b 100644
--- a/resources/views/livewire/project/application/general.blade.php
+++ b/resources/views/livewire/project/application/general.blade.php
@@ -5,8 +5,12 @@