Sync current branch with next branch
This commit is contained in:
@@ -484,6 +484,11 @@ class DatabaseBackupJob implements ShouldBeEncrypted, ShouldQueue
|
|||||||
|
|
||||||
$fullImageName = $this->getFullImageName();
|
$fullImageName = $this->getFullImageName();
|
||||||
|
|
||||||
|
$containerExists = instant_remote_process(["docker ps -a -q -f name=backup-of-{$this->backup->uuid}"], $this->server, false);
|
||||||
|
if (filled($containerExists)) {
|
||||||
|
instant_remote_process(["docker rm -f backup-of-{$this->backup->uuid}"], $this->server, false);
|
||||||
|
}
|
||||||
|
|
||||||
if (isDev()) {
|
if (isDev()) {
|
||||||
if ($this->database->name === 'coolify-db') {
|
if ($this->database->name === 'coolify-db') {
|
||||||
$backup_location_from = '/var/lib/docker/volumes/coolify_dev_backups_data/_data/coolify/coolify-db-'.$this->server->ip.$this->backup_file;
|
$backup_location_from = '/var/lib/docker/volumes/coolify_dev_backups_data/_data/coolify/coolify-db-'.$this->server->ip.$this->backup_file;
|
||||||
|
@@ -9,8 +9,8 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|||||||
class LocalFileVolume extends BaseModel
|
class LocalFileVolume extends BaseModel
|
||||||
{
|
{
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
'fs_path' => 'encrypted',
|
// 'fs_path' => 'encrypted',
|
||||||
'mount_path' => 'encrypted',
|
// 'mount_path' => 'encrypted',
|
||||||
'content' => 'encrypted',
|
'content' => 'encrypted',
|
||||||
'is_directory' => 'boolean',
|
'is_directory' => 'boolean',
|
||||||
];
|
];
|
||||||
|
@@ -1363,15 +1363,21 @@ function parseServiceVolumes($serviceVolumes, $resource, $topLevelVolumes, $pull
|
|||||||
$source = $source."-pr-$pull_request_id";
|
$source = $source."-pr-$pull_request_id";
|
||||||
}
|
}
|
||||||
if (! $resource?->settings?->is_preserve_repository_enabled || $foundConfig?->is_based_on_git) {
|
if (! $resource?->settings?->is_preserve_repository_enabled || $foundConfig?->is_based_on_git) {
|
||||||
$volume = LocalFileVolume::wherePlainMountPath($target)->first() ?? new LocalFileVolume;
|
LocalFileVolume::updateOrCreate(
|
||||||
$volume->fill([
|
[
|
||||||
|
'mount_path' => $target,
|
||||||
|
'resource_id' => $resource->id,
|
||||||
|
'resource_type' => get_class($resource),
|
||||||
|
],
|
||||||
|
[
|
||||||
'fs_path' => $source,
|
'fs_path' => $source,
|
||||||
'mount_path' => $target,
|
'mount_path' => $target,
|
||||||
'content' => $content,
|
'content' => $content,
|
||||||
'is_directory' => $isDirectory,
|
'is_directory' => $isDirectory,
|
||||||
'resource_id' => $resource->id,
|
'resource_id' => $resource->id,
|
||||||
'resource_type' => get_class($resource),
|
'resource_type' => get_class($resource),
|
||||||
])->save();
|
]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} elseif ($type->value() === 'volume') {
|
} elseif ($type->value() === 'volume') {
|
||||||
if ($topLevelVolumes->has($source->value())) {
|
if ($topLevelVolumes->has($source->value())) {
|
||||||
@@ -1670,27 +1676,21 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal
|
|||||||
return $volume;
|
return $volume;
|
||||||
}
|
}
|
||||||
|
|
||||||
$existingVolume = LocalFileVolume::wherePlainMountPath($target)->first();
|
LocalFileVolume::updateOrCreate(
|
||||||
|
[
|
||||||
if ($existingVolume) {
|
'mount_path' => $target,
|
||||||
$existingVolume->update([
|
'resource_id' => $savedService->id,
|
||||||
|
'resource_type' => get_class($savedService),
|
||||||
|
],
|
||||||
|
[
|
||||||
'fs_path' => $source,
|
'fs_path' => $source,
|
||||||
'mount_path' => $target,
|
'mount_path' => $target,
|
||||||
'content' => $content,
|
'content' => $content,
|
||||||
'is_directory' => $isDirectory,
|
'is_directory' => $isDirectory,
|
||||||
'resource_id' => $savedService->id,
|
'resource_id' => $savedService->id,
|
||||||
'resource_type' => get_class($savedService),
|
'resource_type' => get_class($savedService),
|
||||||
]);
|
]
|
||||||
} else {
|
);
|
||||||
LocalFileVolume::create([
|
|
||||||
'fs_path' => $source,
|
|
||||||
'mount_path' => $target,
|
|
||||||
'content' => $content,
|
|
||||||
'is_directory' => $isDirectory,
|
|
||||||
'resource_id' => $savedService->id,
|
|
||||||
'resource_type' => get_class($savedService),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
} elseif ($type->value() === 'volume') {
|
} elseif ($type->value() === 'volume') {
|
||||||
if ($topLevelVolumes->has($source->value())) {
|
if ($topLevelVolumes->has($source->value())) {
|
||||||
$v = $topLevelVolumes->get($source->value());
|
$v = $topLevelVolumes->get($source->value());
|
||||||
@@ -3328,15 +3328,21 @@ function newParser(Application|Service $resource, int $pull_request_id = 0, ?int
|
|||||||
if ($isApplication && $isPullRequest) {
|
if ($isApplication && $isPullRequest) {
|
||||||
$source = $source."-pr-$pullRequestId";
|
$source = $source."-pr-$pullRequestId";
|
||||||
}
|
}
|
||||||
$volume = LocalFileVolume::wherePlainMountPath($target)->first() ?? new LocalFileVolume;
|
LocalFileVolume::updateOrCreate(
|
||||||
$volume->fill([
|
[
|
||||||
|
'mount_path' => $target,
|
||||||
|
'resource_id' => $originalResource->id,
|
||||||
|
'resource_type' => get_class($originalResource),
|
||||||
|
],
|
||||||
|
[
|
||||||
'fs_path' => $source,
|
'fs_path' => $source,
|
||||||
'mount_path' => $target,
|
'mount_path' => $target,
|
||||||
'content' => $content,
|
'content' => $content,
|
||||||
'is_directory' => $isDirectory,
|
'is_directory' => $isDirectory,
|
||||||
'resource_id' => $originalResource->id,
|
'resource_id' => $originalResource->id,
|
||||||
'resource_type' => get_class($originalResource),
|
'resource_type' => get_class($originalResource),
|
||||||
])->save();
|
]
|
||||||
|
);
|
||||||
if (isDev()) {
|
if (isDev()) {
|
||||||
if ((int) $resource->compose_parsing_version >= 4) {
|
if ((int) $resource->compose_parsing_version >= 4) {
|
||||||
if ($isApplication) {
|
if ($isApplication) {
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
'coolify' => [
|
'coolify' => [
|
||||||
'version' => '4.0.0-beta.401',
|
'version' => '4.0.0-beta.402',
|
||||||
'helper_version' => '1.0.7',
|
'helper_version' => '1.0.7',
|
||||||
'realtime_version' => '1.0.6',
|
'realtime_version' => '1.0.6',
|
||||||
'self_hosted' => env('SELF_HOSTED', true),
|
'self_hosted' => env('SELF_HOSTED', true),
|
||||||
|
@@ -0,0 +1,139 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Support\Facades\Crypt;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
if (DB::table('local_file_volumes')->exists()) {
|
||||||
|
// First, get all volumes and decrypt their values
|
||||||
|
$decryptedVolumes = collect();
|
||||||
|
|
||||||
|
DB::table('local_file_volumes')
|
||||||
|
->orderBy('id')
|
||||||
|
->chunk(100, function ($volumes) use (&$decryptedVolumes) {
|
||||||
|
foreach ($volumes as $volume) {
|
||||||
|
try {
|
||||||
|
$fs_path = $volume->fs_path;
|
||||||
|
$mount_path = $volume->mount_path;
|
||||||
|
|
||||||
|
try {
|
||||||
|
if ($fs_path) {
|
||||||
|
$fs_path = Crypt::decryptString($fs_path);
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if ($mount_path) {
|
||||||
|
$mount_path = Crypt::decryptString($mount_path);
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
$decryptedVolumes->push([
|
||||||
|
'id' => $volume->id,
|
||||||
|
'fs_path' => $fs_path,
|
||||||
|
'mount_path' => $mount_path,
|
||||||
|
'resource_id' => $volume->resource_id,
|
||||||
|
'resource_type' => $volume->resource_type,
|
||||||
|
]);
|
||||||
|
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
echo "Error decrypting volume {$volume->id}: {$e->getMessage()}\n";
|
||||||
|
Log::error("Error decrypting volume {$volume->id}: ".$e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Group by the unique constraint fields and keep only the first occurrence
|
||||||
|
$uniqueVolumes = $decryptedVolumes->groupBy(function ($volume) {
|
||||||
|
return $volume['mount_path'].'|'.$volume['resource_id'].'|'.$volume['resource_type'];
|
||||||
|
})->map(function ($group) {
|
||||||
|
return $group->first();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Get IDs to delete (all except the ones we're keeping)
|
||||||
|
$idsToKeep = $uniqueVolumes->pluck('id')->toArray();
|
||||||
|
$idsToDelete = $decryptedVolumes->pluck('id')->diff($idsToKeep)->toArray();
|
||||||
|
|
||||||
|
// Delete duplicate records
|
||||||
|
if (! empty($idsToDelete)) {
|
||||||
|
// Show details of volumes being deleted
|
||||||
|
$volumesToDelete = $decryptedVolumes->whereIn('id', $idsToDelete);
|
||||||
|
echo "\nVolumes to be deleted:\n";
|
||||||
|
foreach ($volumesToDelete as $volume) {
|
||||||
|
echo "ID: {$volume['id']}, Mount Path: {$volume['mount_path']}, Resource ID: {$volume['resource_id']}, Resource Type: {$volume['resource_type']}\n";
|
||||||
|
echo "FS Path: {$volume['fs_path']}\n";
|
||||||
|
echo "-------------------\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::table('local_file_volumes')->whereIn('id', $idsToDelete)->delete();
|
||||||
|
echo 'Deleted '.count($idsToDelete)." duplicate volume(s)\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the remaining records with decrypted values
|
||||||
|
foreach ($uniqueVolumes as $volume) {
|
||||||
|
try {
|
||||||
|
DB::table('local_file_volumes')->where('id', $volume['id'])->update([
|
||||||
|
'fs_path' => $volume['fs_path'],
|
||||||
|
'mount_path' => $volume['mount_path'],
|
||||||
|
]);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
echo "Error updating volume {$volume['id']}: {$e->getMessage()}\n";
|
||||||
|
Log::error("Error updating volume {$volume['id']}: ".$e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
if (DB::table('local_file_volumes')->exists()) {
|
||||||
|
DB::table('local_file_volumes')
|
||||||
|
->orderBy('id')
|
||||||
|
->chunk(100, function ($volumes) {
|
||||||
|
foreach ($volumes as $volume) {
|
||||||
|
DB::beginTransaction();
|
||||||
|
try {
|
||||||
|
$fs_path = $volume->fs_path;
|
||||||
|
$mount_path = $volume->mount_path;
|
||||||
|
try {
|
||||||
|
if ($fs_path) {
|
||||||
|
$fs_path = Crypt::encrypt($fs_path);
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if ($mount_path) {
|
||||||
|
$mount_path = Crypt::encrypt($mount_path);
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::table('local_file_volumes')->where('id', $volume->id)->update([
|
||||||
|
'fs_path' => $fs_path,
|
||||||
|
'mount_path' => $mount_path,
|
||||||
|
]);
|
||||||
|
echo "Updated volume {$volume->id}\n";
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
echo "Error decrypting local file volume fields: {$e->getMessage()}\n";
|
||||||
|
Log::error('Error decrypting local file volume fields: '.$e->getMessage());
|
||||||
|
}
|
||||||
|
DB::commit();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
@@ -1,10 +1,10 @@
|
|||||||
{
|
{
|
||||||
"coolify": {
|
"coolify": {
|
||||||
"v4": {
|
"v4": {
|
||||||
"version": "4.0.0-beta.401"
|
"version": "4.0.0-beta.402"
|
||||||
},
|
},
|
||||||
"nightly": {
|
"nightly": {
|
||||||
"version": "4.0.0-beta.402"
|
"version": "4.0.0-beta.403"
|
||||||
},
|
},
|
||||||
"helper": {
|
"helper": {
|
||||||
"version": "1.0.7"
|
"version": "1.0.7"
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
{
|
{
|
||||||
"coolify": {
|
"coolify": {
|
||||||
"v4": {
|
"v4": {
|
||||||
"version": "4.0.0-beta.401"
|
"version": "4.0.0-beta.402"
|
||||||
},
|
},
|
||||||
"nightly": {
|
"nightly": {
|
||||||
"version": "4.0.0-beta.402"
|
"version": "4.0.0-beta.403"
|
||||||
},
|
},
|
||||||
"helper": {
|
"helper": {
|
||||||
"version": "1.0.7"
|
"version": "1.0.7"
|
||||||
|
Reference in New Issue
Block a user