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
fix: local dev s3 uploads fix: hetzner s3 uploads (mc alias instead of mc host)
Andras Bacsaidd782e75f5a9
diff --git a/app/Jobs/DatabaseBackupJob.php b/app/Jobs/DatabaseBackupJob.phpindex 7109fda3be..9369eaaf9f 100644--- a/app/Jobs/DatabaseBackupJob.php+++ b/app/Jobs/DatabaseBackupJob.php@@ -237,7 +237,6 @@ class DatabaseBackupJob implements ShouldBeEncrypted, ShouldQueue}}$this->backup_dir = backup_dir().'/databases/'.str($this->team->name)->slug().'-'.$this->team->id.'/'.$this->directory_name;-if ($this->database->name === 'coolify-db') {$databasesToBackup = ['coolify'];$this->directory_name = $this->container_name = 'coolify-db';@@ -515,10 +514,27 @@ class DatabaseBackupJob implements ShouldBeEncrypted, ShouldQueue$this->ensureHelperImageAvailable();$fullImageName = $this->getFullImageName();- $commands[] = "docker run -d --network {$network} --name backup-of-{$this->backup->uuid} --rm -v $this->backup_location:$this->backup_location:ro {$fullImageName}";- $commands[] = "docker exec backup-of-{$this->backup->uuid} mc config host add temporary {$endpoint} $key $secret";++ if (isDev()) {+ if ($this->database->name === 'coolify-db') {+ $backup_location_from = '/var/lib/docker/volumes/coolify_dev_backups_data/_data/databases/coolify/coolify-db-'.$this->server->ip.$this->backup_file;+ $commands[] = "docker run -d --network {$network} --name backup-of-{$this->backup->uuid} --rm -v $backup_location_from:$this->backup_location:ro {$fullImageName}";+ } else {+ $backup_location_from = '/var/lib/docker/volumes/coolify_dev_backups_data/_data/databases/'.str($this->team->name)->slug().'-'.$this->team->id.'/'.$this->directory_name.$this->backup_file;+ $commands[] = "docker run -d --network {$network} --name backup-of-{$this->backup->uuid} --rm -v $backup_location_from:$this->backup_location:ro {$fullImageName}";+ }+ } else {+ $commands[] = "docker run -d --network {$network} --name backup-of-{$this->backup->uuid} --rm -v $this->backup_location:$this->backup_location:ro {$fullImageName}";+ }+ if ($this->s3->isHetzner()) {+ $endpointWithoutBucket = 'https://'.str($endpoint)->after('https://')->after('.')->value();+ $commands[] = "docker exec backup-of-{$this->backup->uuid} mc alias set --path=off --api=S3v4 temporary {$endpointWithoutBucket} $key $secret";+ } else {+ $commands[] = "docker exec backup-of-{$this->backup->uuid} mc config host add temporary {$endpoint} $key $secret";+ }$commands[] = "docker exec backup-of-{$this->backup->uuid} mc cp $this->backup_location temporary/$bucket{$this->backup_dir}/";instant_remote_process($commands, $this->server);+$this->add_to_backup_output('Uploaded to S3.');} catch (\Throwable $e) {$this->add_to_backup_output($e->getMessage());diff --git a/app/Models/S3Storage.php b/app/Models/S3Storage.phpindex 4c7faaa6fa..a432a6e9c3 100644--- a/app/Models/S3Storage.php+++ b/app/Models/S3Storage.php@@ -40,6 +40,16 @@ class S3Storage extends BaseModelreturn "{$this->endpoint}/{$this->bucket}";}+ public function isHetzner()+ {+ return str($this->endpoint)->contains('your-objectstorage.com');+ }++ public function isDigitalOcean()+ {+ return str($this->endpoint)->contains('digitaloceanspaces.com');+ }+public function testConnection(bool $shouldSave = false){try {diff --git a/bootstrap/helpers/s3.php b/bootstrap/helpers/s3.phpindex e4469cd6b2..2ee7bf44a0 100644--- a/bootstrap/helpers/s3.php+++ b/bootstrap/helpers/s3.php@@ -1,15 +1,11 @@<?phpuse App\Models\S3Storage;-use Illuminate\Support\Str;function set_s3_target(S3Storage $s3){$is_digital_ocean = false;- if ($s3->endpoint) {- $is_digital_ocean = Str::contains($s3->endpoint, 'digitaloceanspaces.com');- $is_hetzner = Str::contains($s3->endpoint, 'your-objectstorage.com');- }+config()->set('filesystems.disks.custom-s3', ['driver' => 's3','region' => $s3['region'],@@ -18,7 +14,7 @@ function set_s3_target(S3Storage $s3)'bucket' => $s3['bucket'],'endpoint' => $s3['endpoint'],'use_path_style_endpoint' => true,- 'bucket_endpoint' => $is_digital_ocean || $is_hetzner,+ 'bucket_endpoint' => $s3->isHetzner() || $s3->isDigitalOcean(),'aws_url' => $s3->awsUrl(),]);}diff --git a/resources/views/components/modal-confirmation.blade.php b/resources/views/components/modal-confirmation.blade.phpindex d82a046d37..81a4b808bf 100644--- a/resources/views/components/modal-confirmation.blade.php+++ b/resources/views/components/modal-confirmation.blade.php@@ -296,9 +296,8 @@</template><template x-if="step === 1">- @if(isDev() && $submitAction === 'delete')- <x-forms.button class="w-auto" isError- @click="$wire.delete('hello')">+ @if(isDev() && str($submitAction)->contains('delete'))+ <x-forms.button class="w-auto" isError wire:click="{{ $submitAction }}('hello')"><span x-text="step3ButtonText"></span></x-forms.button>@else@@ -309,7 +308,7 @@</template><template x-if="step === 2">- <x-forms.button x-bind:disabled="confirmationText !== '' && confirmWithText && userConfirmationText !== confirmationText"+ <x-forms.button x-bind:disabled="confirmationText !== '' && userConfirmationText !== confirmationText"class="w-auto" isError@click="if (dispatchEvent) {diff --git a/resources/views/livewire/project/database/backup-executions.blade.php b/resources/views/livewire/project/database/backup-executions.blade.phpindex 5491a5129f..ff2bc15b2d 100644--- a/resources/views/livewire/project/database/backup-executions.blade.php+++ b/resources/views/livewire/project/database/backup-executions.blade.php@@ -45,20 +45,11 @@<x-forms.button class="dark:hover:bg-coolgray-400"x-on:click="download_file('{{ data_get($execution, 'id') }}')">Download</x-forms.button>@endif- <x-modal-confirmation- title="Confirm Backup Deletion?"- buttonTitle="Delete"- isErrorButton- submitAction="deleteBackup({{ data_get($execution, 'id') }})"- {{-- :checkboxes="$checkboxes" --}}- :actions="[- 'This backup will be permanently deleted from local storage.'- ]"- confirmationText="{{ data_get($execution, 'filename') }}"- confirmationLabel="Please confirm the execution of the actions by entering the Backup Filename below"- shortConfirmationLabel="Backup Filename"- step3ButtonText="Permanently Delete"- />+ <x-modal-confirmation title="Confirm Backup Deletion?" buttonTitle="Delete" isErrorButton+ submitAction="deleteBackup({{ data_get($execution, 'id') }})"+ :actions="['This backup will be permanently deleted from local storage.']" confirmationText="{{ data_get($execution, 'filename') }}"+ confirmationLabel="Please confirm the execution of the actions by entering the Backup Filename below"+ shortConfirmationLabel="Backup Filename" step3ButtonText="Permanently Delete" /></div></div>@emptydiff --git a/resources/views/livewire/project/database/create-scheduled-backup.blade.php b/resources/views/livewire/project/database/create-scheduled-backup.blade.phpindex d5c5ff99c3..492bb9f27f 100644--- a/resources/views/livewire/project/database/create-scheduled-backup.blade.php+++ b/resources/views/livewire/project/database/create-scheduled-backup.blade.php@@ -2,16 +2,18 @@<x-forms.input placeholder="0 0 * * * or daily" id="frequency"helper="You can use every_minute, hourly, daily, weekly, monthly, yearly or a cron expression." label="Frequency"required />- <x-forms.checkbox id="save_s3" label="Save to S3" />- <x-forms.select id="selected_storage_id">- @if ($s3s->count() === 0)- <option value="0">No S3 Storages found.</option>- @else- @foreach ($s3s as $s3)- <option value="{{ $s3->id }}">{{ $s3->name }}</option>- @endforeach+ @if ($s3s->count() === 0)+ <div class="text-red-500">No validated S3 Storages found.</div>+ @else+ <x-forms.checkbox wire:model.live="save_s3" label="Save to S3" />+ @if ($save_s3)+ <x-forms.select id="selected_storage_id" label="Select a validated S3 storage">+ @foreach ($s3s as $s3)+ <option value="{{ $s3->id }}">{{ $s3->name }}</option>+ @endforeach+ </x-forms.select>@endif- </x-forms.select>+ @endif<x-forms.button type="submit" @click="modalOpen=false">Save</x-forms.button>