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.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
feat: preserve git repository
Andras Bacsai2529496594a4
diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.phpindex 532b1ae27e..3024bf393a 100644--- a/app/Jobs/ApplicationDeploymentJob.php+++ b/app/Jobs/ApplicationDeploymentJob.php@@ -157,6 +157,8 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueueprivate ?string $coolify_variables = null;+ private bool $preserveRepository = true;+public $tries = 1;public function __construct(int $application_deployment_queue_id)@@ -187,6 +189,7 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue$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 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue} 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 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue$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 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueueprivate 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.phpindex ac603f331c..7dfd9bad47 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.phpnew file mode 100644index 0000000000..25dd0ef162--- /dev/null+++ b/database/migrations/2024_07_18_110424_create_application_settings_is_preserve_repository_enabled.php@@ -0,0 +1,28 @@+<?php++use Illuminate\Database\Migrations\Migration;+use Illuminate\Database\Schema\Blueprint;+use Illuminate\Support\Facades\Schema;++return new class extends Migration+{+ /**+ * Run the migrations.+ */+ public function up(): void+ {+ Schema::table('application_settings', function (Blueprint $table) {+ $table->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.phpindex 19cb64a05b..dc3f135dbc 100644--- a/resources/views/livewire/project/application/advanced.blade.php+++ b/resources/views/livewire/project/application/advanced.blade.php@@ -16,12 +16,13 @@<x-forms.checkboxhelper="Your application will be available only on https if your domain starts with https://..."instantSave id="is_force_https_enabled" label="Force Https" />- <x-forms.checkbox label="Enable gzip compression"+ <x-forms.checkbox label="Enable Gzip Compression"helper="You can disable gzip compression if you want. Some services are compressing data by default. In this case, you do not need this."instantSave id="is_gzip_enabled" /><x-forms.checkbox helper="Strip Prefix is used to remove prefixes from paths. Like /api/ to /api."instantSave id="is_stripprefix_enabled" label="Strip Prefixes" />@if ($application->build_pack === 'dockercompose')+ <h3>Docker Compose</h3><x-forms.checkbox instantSave id="application.settings.is_raw_compose_deployment_enabled"label="Raw Compose Deployment"helper="WARNING: Advanced use cases only. Your docker compose file will be deployed as-is. Nothing is modified by Coolify. You need to configure the proxy parts. More info in the <a class='underline dark:text-white' href='https://coolify.io/docs/knowledge-base/docker/compose#raw-docker-compose-deployment'>documentation.</a>" />diff --git a/resources/views/livewire/project/application/general.blade.php b/resources/views/livewire/project/application/general.blade.phpindex 3b6c300399..4f68b6d8e3 100644--- a/resources/views/livewire/project/application/general.blade.php+++ b/resources/views/livewire/project/application/general.blade.php@@ -166,6 +166,11 @@id="application.docker_compose_location" label="Docker Compose Location"helper="It is calculated together with the Base Directory:<br><span class='dark:text-warning'>{{ Str::start($application->base_directory . $application->docker_compose_location, '/') }}</span>" /></div>+ <div class="w-96">+ <x-forms.checkbox instantSave id="application.settings.is_preserve_repository_enabled"+ label="Preserve Repository During Deployment"+ helper="Git repository (based on the base directory settings) will be copied to the deployment directory." />+ </div><div class="pt-4">The following commands are for advanced use cases. Only modify them if youknow what areyou doing.</div>