mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-06 13:10:37 -04:00
BuildKit keys every RUN step on the --add-host names, so a container that joins or leaves the network between two builds rebuilt all layers. Leave out database backup and S3 import helpers, Sentinel, and the proxy error page container. Closes #12452 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
57 lines
2.5 KiB
PHP
57 lines
2.5 KiB
PHP
<?php
|
|
|
|
use App\Jobs\ApplicationDeploymentJob;
|
|
use App\Models\ApplicationDeploymentQueue;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
|
|
uses(RefreshDatabase::class);
|
|
|
|
function addHostFlagsFor(array $containers): string
|
|
{
|
|
$job = (new ReflectionClass(ApplicationDeploymentJob::class))->newInstanceWithoutConstructor();
|
|
|
|
return (new ReflectionMethod(ApplicationDeploymentJob::class, 'addHostFlags'))->invoke($job, collect($containers));
|
|
}
|
|
|
|
it('keeps build helper containers of other deployments out of --add-host', function () {
|
|
ApplicationDeploymentQueue::create(['application_id' => '1', 'deployment_uuid' => 'k0s8g4wc4c8gkkso0gk4cgww']);
|
|
|
|
$flags = addHostFlagsFor([
|
|
'a' => ['Name' => 'redis-db', 'IPv4Address' => '10.0.1.5/24'],
|
|
'b' => ['Name' => 'k0s8g4wc4c8gkkso0gk4cgww', 'IPv4Address' => '10.0.1.9/24'],
|
|
'c' => ['Name' => 'coolify-proxy', 'IPv4Address' => '10.0.1.2/24'],
|
|
'd' => ['Name' => 'app-uuid-20260908T141530', 'IPv4Address' => '10.0.1.7/24'],
|
|
]);
|
|
|
|
expect($flags)->toBe('--add-host redis-db:10.0.1.5');
|
|
});
|
|
|
|
it('keeps the --add-host set stable whether or not a build helper is running', function () {
|
|
ApplicationDeploymentQueue::create(['application_id' => '1', 'deployment_uuid' => 'helper-deployment-uuid']);
|
|
$database = ['Name' => 'postgres-main', 'IPv4Address' => '10.0.1.3/24'];
|
|
|
|
expect(addHostFlagsFor([$database, ['Name' => 'helper-deployment-uuid', 'IPv4Address' => '10.0.1.4/24']]))
|
|
->toBe(addHostFlagsFor([$database]))
|
|
->toBe('--add-host postgres-main:10.0.1.3');
|
|
});
|
|
|
|
it('keeps database backup and S3 import helpers out of --add-host', function () {
|
|
$database = ['Name' => 'postgres-main', 'IPv4Address' => '10.0.1.3/24'];
|
|
|
|
expect(addHostFlagsFor([
|
|
$database,
|
|
['Name' => 'backup-of-bk7f2c9d0a1e4b5c6d7e8f9a0', 'IPv4Address' => '10.0.1.11/24'],
|
|
['Name' => 's3-restore-k4b2x9q1', 'IPv4Address' => '10.0.1.12/24'],
|
|
]))->toBe(addHostFlagsFor([$database]))
|
|
->toBe('--add-host postgres-main:10.0.1.3');
|
|
});
|
|
|
|
it('keeps the Coolify proxy, Sentinel, and error page containers out of --add-host', function () {
|
|
expect(addHostFlagsFor([
|
|
['Name' => 'coolify-proxy', 'IPv4Address' => '10.0.1.2/24'],
|
|
['Name' => 'coolify-sentinel', 'IPv4Address' => '10.0.1.3/24'],
|
|
['Name' => 'coolify-proxy-error-pages', 'IPv4Address' => '10.0.1.4/24'],
|
|
['Name' => 'postgres-main', 'IPv4Address' => '10.0.1.5/24'],
|
|
]))->toBe('--add-host postgres-main:10.0.1.5');
|
|
});
|