mirror of
https://github.com/coollabsio/coolify.git
synced 2026-10-08 06:56:02 -04:00
Caddy 2.7.6, shipped in the caddy-docker-proxy 2.8 image, rejects the whole Caddyfile when it contains log_append. Add Server::caddySupportsLogAppend(), which reads the image from the applied proxy configuration. Traffic analytics labels now add log_append only when the server runs 2.9 or newer and has no pending proxy change. - Change the default Caddy proxy image from 2.8-alpine to 2.13-alpine - ProxyPortParser now validates Docker Compose port ranges and random host ports. It returns only fixed host ports for the availability check and has a clearer validation message - After mkdir, chown only root-owned files and remove other-user access from the top directory only. Files owned by container users and the modes of mounted files no longer change - Add tests for log_append support and the new parser/sudo behaviour - Note in the lessons file that tests must flush the Server identity map between dataset cases
61 lines
2.4 KiB
PHP
61 lines
2.4 KiB
PHP
<?php
|
|
|
|
use App\Models\PrivateKey;
|
|
use App\Models\Server;
|
|
use App\Models\User;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Support\Facades\Process;
|
|
use Symfony\Component\Yaml\Yaml;
|
|
|
|
uses(RefreshDatabase::class);
|
|
|
|
beforeEach(function () {
|
|
// generateDefaultProxyConfiguration() synchronously persists the config to the
|
|
// server over SSH (SaveProxyConfiguration); fake the process layer so tests
|
|
// don't attempt a real SSH connection.
|
|
Process::fake();
|
|
|
|
$user = User::factory()->create();
|
|
$this->team = $user->teams()->first();
|
|
|
|
$this->privateKey = PrivateKey::factory()->create(['team_id' => $this->team->id]);
|
|
});
|
|
|
|
it('does not mount the traffic volume for caddy when traffic analytics is disabled', function () {
|
|
$server = Server::factory()->create(['team_id' => $this->team->id, 'private_key_id' => $this->privateKey->id]);
|
|
$server->proxy->set('type', 'CADDY');
|
|
$server->save();
|
|
$server->settings->is_traffic_analytics_enabled = false;
|
|
$server->settings->save();
|
|
|
|
$config = Yaml::parse(generateDefaultProxyConfiguration($server->fresh()));
|
|
|
|
expect($config['services']['caddy']['volumes'])
|
|
->not->toContain($server->proxyPath().':/traffic');
|
|
});
|
|
|
|
it('mounts the traffic volume for caddy when traffic analytics is enabled', function () {
|
|
$server = Server::factory()->create(['team_id' => $this->team->id, 'private_key_id' => $this->privateKey->id]);
|
|
$server->proxy->set('type', 'CADDY');
|
|
$server->save();
|
|
$server->settings->is_traffic_analytics_enabled = true;
|
|
$server->settings->save();
|
|
|
|
$config = Yaml::parse(generateDefaultProxyConfiguration($server->fresh()));
|
|
|
|
expect($config['services']['caddy']['volumes'])
|
|
->toContain($server->proxyPath().':/traffic');
|
|
});
|
|
|
|
it('uses a default caddy image that supports per-app traffic attribution', function () {
|
|
$server = Server::factory()->create(['team_id' => $this->team->id, 'private_key_id' => $this->privateKey->id]);
|
|
$server->proxy->set('type', 'CADDY');
|
|
$server->save();
|
|
|
|
$config = Yaml::parse(generateDefaultProxyConfiguration($server->fresh()));
|
|
|
|
// caddy-docker-proxy 2.13 ships Caddy 2.11, which knows log_append; the old 2.8 default shipped Caddy 2.7.6.
|
|
expect($config['services']['caddy']['image'])->toBe('lucaslorentz/caddy-docker-proxy:2.13-alpine')
|
|
->and($server->fresh()->caddySupportsLogAppend())->toBeTrue();
|
|
});
|