mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-06 13:10:37 -04:00
Merge remote-tracking branch 'origin/main'
This commit is contained in:
@@ -54,10 +54,13 @@ class ApplicationPreview extends BaseModel
|
||||
|
||||
if (data_get($preview, 'application.build_pack') === 'dockercompose') {
|
||||
$composeFile = $application->parse(pull_request_id: $preview->pull_request_id);
|
||||
foreach ($preview->generatedComposeVolumeNames($application, collect(data_get($composeFile, 'volumes', []))) as $volumeName) {
|
||||
$volumeNames = $preview->generatedComposeVolumeNames($application, collect(data_get($composeFile, 'volumes', [])));
|
||||
foreach ($volumeNames as $volumeName) {
|
||||
// Docker does not remove a volume that a container still uses, also with -f.
|
||||
instant_remote_process(['docker volume rm -f '.escapeshellarg($volumeName)], $server, false);
|
||||
}
|
||||
// The compose parser stores preview volumes on the application, not on the preview
|
||||
$application->persistentStorages()->whereIn('name', $volumeNames)->delete();
|
||||
$preview->removeComposePreviewNetwork($application, $server);
|
||||
} else {
|
||||
// Regular application volume cleanup
|
||||
|
||||
@@ -913,7 +913,7 @@ services:
|
||||
kong: 'contains(string!(.appname), "supabase-kong")'
|
||||
auth: 'contains(string!(.appname), "supabase-auth")'
|
||||
rest: 'contains(string!(.appname), "supabase-rest")'
|
||||
realtime: 'contains(string!(.appname), "supabase-realtime")'
|
||||
realtime: 'contains(string!(.appname), "realtime-dev")'
|
||||
storage: 'contains(string!(.appname), "supabase-storage")'
|
||||
functions: 'contains(string!(.appname), "supabase-edge-functions")'
|
||||
db: 'contains(string!(.appname), "supabase-db")'
|
||||
@@ -1297,7 +1297,7 @@ services:
|
||||
- DB_AFTER_CONNECT_QUERY=SET search_path TO _realtime
|
||||
- DB_ENC_KEY=supabaserealtime
|
||||
- API_JWT_SECRET=${SERVICE_PASSWORD_JWT}
|
||||
- SECRET_KEY_BASE=${SECRET_PASSWORD_REALTIME}
|
||||
- SECRET_KEY_BASE=${SERVICE_PASSWORD_64_REALTIME}
|
||||
- METRICS_JWT_SECRET=${SERVICE_PASSWORD_JWT}
|
||||
- ERL_AFLAGS=-proto_dist inet_tcp
|
||||
- DNS_NODES=''
|
||||
|
||||
@@ -11,6 +11,7 @@ use App\Models\StandaloneDocker;
|
||||
use App\Models\Team;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Process;
|
||||
use Illuminate\Support\Facades\Queue;
|
||||
|
||||
uses(RefreshDatabase::class);
|
||||
|
||||
@@ -118,3 +119,48 @@ it('continues removing preview volumes when an earlier volume is already absent'
|
||||
Process::assertRan(fn ($process) => str_contains($process->command, "docker volume rm -f 'app-data-pr-42'"));
|
||||
expect(ApplicationPreview::find($this->preview->id))->toBeNull();
|
||||
});
|
||||
|
||||
it('deletes the persistent storage records of a docker compose preview', function () {
|
||||
Queue::fake();
|
||||
$this->application->update([
|
||||
'build_pack' => 'dockercompose',
|
||||
'compose_parsing_version' => '5',
|
||||
'docker_compose_raw' => <<<'YAML'
|
||||
services:
|
||||
app:
|
||||
image: nginx:alpine
|
||||
volumes:
|
||||
- files:/app/files
|
||||
- db:/var/lib/mysql
|
||||
volumes:
|
||||
files:
|
||||
db:
|
||||
YAML,
|
||||
]);
|
||||
$this->application->refresh();
|
||||
$uuid = $this->application->uuid;
|
||||
|
||||
// Deploying the application, this preview and another preview creates the storage records
|
||||
$this->application->parse();
|
||||
$this->application->parse(pull_request_id: 42);
|
||||
$this->application->parse(pull_request_id: 43);
|
||||
expect($this->application->persistentStorages()->pluck('name')->sort()->values()->all())->toBe([
|
||||
"{$uuid}_db",
|
||||
"{$uuid}_db-pr-42",
|
||||
"{$uuid}_db-pr-43",
|
||||
"{$uuid}_files",
|
||||
"{$uuid}_files-pr-42",
|
||||
"{$uuid}_files-pr-43",
|
||||
]);
|
||||
Process::fake(['*' => Process::result(output: '')]);
|
||||
|
||||
$this->preview->forceDelete();
|
||||
|
||||
Process::assertRan(fn ($process) => str_contains($process->command, "docker volume rm -f '{$uuid}_db-pr-42'"));
|
||||
expect($this->application->persistentStorages()->pluck('name')->sort()->values()->all())->toBe([
|
||||
"{$uuid}_db",
|
||||
"{$uuid}_db-pr-43",
|
||||
"{$uuid}_files",
|
||||
"{$uuid}_files-pr-43",
|
||||
]);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user