diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php
index 532b1ae27..3024bf393 100644
--- a/app/Jobs/ApplicationDeploymentJob.php
+++ b/app/Jobs/ApplicationDeploymentJob.php
@@ -157,6 +157,8 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue
private ?string $coolify_variables = null;
+ private bool $preserveRepository = true;
+
public $tries = 1;
public function __construct(int $application_deployment_queue_id)
@@ -187,6 +189,7 @@ public function __construct(int $application_deployment_queue_id)
$this->server = $this->mainServer = $this->destination->server;
$this->serverUser = $this->server->user;
$this->is_this_additional_server = $this->application->additional_servers()->wherePivot('server_id', $this->server->id)->count() > 0;
+ $this->preserveRepository = $this->application->settings->is_preserve_repository_enabled;
$this->basedir = $this->application->generateBaseDir($this->deployment_uuid);
$this->workdir = "{$this->basedir}".rtrim($this->application->base_directory, '/');
@@ -296,13 +299,13 @@ public function handle(): void
} else {
$this->write_deployment_configurations();
}
- $this->execute_remote_command(
- [
- "docker rm -f {$this->deployment_uuid} >/dev/null 2>&1",
- 'hidden' => true,
- 'ignore_errors' => true,
- ]
- );
+ // $this->execute_remote_command(
+ // [
+ // "docker rm -f {$this->deployment_uuid} >/dev/null 2>&1",
+ // 'hidden' => true,
+ // 'ignore_errors' => true,
+ // ]
+ // );
// $this->execute_remote_command(
// [
@@ -517,6 +520,8 @@ private function deploy_docker_compose_buildpack()
$command .= " --env-file {$this->workdir}/{$this->env_filename}";
}
$command .= " --project-name {$this->application->uuid} --project-directory {$this->workdir} -f {$this->workdir}{$this->docker_compose_location} up -d";
+ ray($command);
+
$this->execute_remote_command(
[executeInDocker($this->deployment_uuid, $command), 'hidden' => true],
);
@@ -605,6 +610,28 @@ private function deploy_static_buildpack()
private function write_deployment_configurations()
{
+ if ($this->preserveRepository) {
+ if ($this->use_build_server) {
+ $this->server = $this->original_server;
+ }
+ if (str($this->configuration_dir)->isNotEmpty()) {
+ ray("docker cp {$this->deployment_uuid}:{$this->workdir} {$this->configuration_dir}");
+ $this->execute_remote_command(
+ [
+ "mkdir -p $this->configuration_dir",
+ ],
+ [
+ "rm -rf $this->configuration_dir/{*,.*}",
+ ],
+ [
+ "docker cp {$this->deployment_uuid}:{$this->workdir}/. {$this->configuration_dir}",
+ ],
+ );
+ }
+ if ($this->use_build_server) {
+ $this->server = $this->build_server;
+ }
+ }
if (isset($this->docker_compose_base64)) {
if ($this->use_build_server) {
$this->server = $this->original_server;
diff --git a/app/Livewire/Project/Application/General.php b/app/Livewire/Project/Application/General.php
index ac603f331..7dfd9bad4 100644
--- a/app/Livewire/Project/Application/General.php
+++ b/app/Livewire/Project/Application/General.php
@@ -85,6 +85,7 @@ class General extends Component
'application.settings.is_build_server_enabled' => 'boolean|required',
'application.settings.is_container_label_escape_enabled' => 'boolean|required',
'application.settings.is_container_label_readonly_enabled' => 'boolean|required',
+ 'application.settings.is_preserve_repository_enabled' => 'boolean|required',
'application.watch_paths' => 'nullable',
'application.redirect' => 'string|required',
];
@@ -121,6 +122,7 @@ class General extends Component
'application.settings.is_build_server_enabled' => 'Is build server enabled',
'application.settings.is_container_label_escape_enabled' => 'Is container label escape enabled',
'application.settings.is_container_label_readonly_enabled' => 'Is container label readonly',
+ 'application.settings.is_preserve_repository_enabled' => 'Is preserve repository enabled',
'application.watch_paths' => 'Watch paths',
'application.redirect' => 'Redirect',
];
diff --git a/database/migrations/2024_07_18_110424_create_application_settings_is_preserve_repository_enabled.php b/database/migrations/2024_07_18_110424_create_application_settings_is_preserve_repository_enabled.php
new file mode 100644
index 000000000..25dd0ef16
--- /dev/null
+++ b/database/migrations/2024_07_18_110424_create_application_settings_is_preserve_repository_enabled.php
@@ -0,0 +1,28 @@
+boolean('is_preserve_repository_enabled')->default(false);
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down(): void
+ {
+ Schema::table('application_settings', function (Blueprint $table) {
+ $table->dropColumn('is_preserve_repository_enabled');
+ });
+ }
+};
diff --git a/resources/views/livewire/project/application/advanced.blade.php b/resources/views/livewire/project/application/advanced.blade.php
index 19cb64a05..dc3f135db 100644
--- a/resources/views/livewire/project/application/advanced.blade.php
+++ b/resources/views/livewire/project/application/advanced.blade.php
@@ -16,12 +16,13 @@