mirror of
https://github.com/tiennm99/coolify.git
synced 2026-10-13 22:15:35 +00:00
fix(proxy): set Traefik network labels for compose services
Add the Coolify network label when no user-selected Traefik network exists, while preserving custom labels for applications and services.
This commit is contained in:
1 parent
006b1b2b74
commit
1c25b58dc8
4 files changed
+154
No files matched your search
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Environment;
|
||||
use App\Models\Project;
|
||||
use App\Models\Server;
|
||||
use App\Models\Service;
|
||||
use App\Models\ServiceApplication;
|
||||
use App\Models\StandaloneDocker;
|
||||
use App\Models\Team;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Bus;
|
||||
|
||||
uses(RefreshDatabase::class);
|
||||
|
||||
it('selects the Coolify service network for Traefik routed compose services', function () {
|
||||
Bus::fake();
|
||||
|
||||
$team = Team::factory()->create();
|
||||
$server = Server::factory()->create(['team_id' => $team->id]);
|
||||
$destination = StandaloneDocker::where('server_id', $server->id)->firstOrFail();
|
||||
$project = Project::factory()->create(['team_id' => $team->id]);
|
||||
$environment = Environment::factory()->create(['project_id' => $project->id]);
|
||||
$service = Service::factory()->create([
|
||||
'environment_id' => $environment->id,
|
||||
'server_id' => $server->id,
|
||||
'destination_id' => $destination->id,
|
||||
'destination_type' => $destination->getMorphClass(),
|
||||
'docker_compose_raw' => <<<'YAML'
|
||||
services:
|
||||
app:
|
||||
image: nginx:latest
|
||||
networks:
|
||||
- custom-network
|
||||
networks:
|
||||
custom-network: {}
|
||||
YAML,
|
||||
]);
|
||||
|
||||
ServiceApplication::create([
|
||||
'name' => 'app',
|
||||
'service_id' => $service->id,
|
||||
'fqdn' => 'https://example.com',
|
||||
]);
|
||||
|
||||
$parsedCompose = serviceParser($service);
|
||||
$labels = collect(data_get($parsedCompose, 'services.app.labels'));
|
||||
|
||||
expect($labels->values()->all())->toContain("traefik.docker.network={$service->uuid}");
|
||||
});
|
||||
Reference in new issue
Block a user