mirror of
https://github.com/tiennm99/coolify.git
synced 2026-04-17 21:20:29 +00:00
feat: add automated PORT environment variable detection and UI warnings
Add detection system for PORT environment variable to help users configure applications correctly: - Add detectPortFromEnvironment() method to Application model to detect PORT env var - Add getDetectedPortInfoProperty() computed property in General Livewire component - Display contextual info banners in UI when PORT is detected: - Warning when PORT exists but ports_exposes is empty - Warning when PORT doesn't match ports_exposes configuration - Info message when PORT matches ports_exposes - Add deployment logging to warn about PORT/ports_exposes mismatches - Include comprehensive unit tests for port detection logic The ports_exposes field remains authoritative for proxy configuration, while PORT detection provides helpful suggestions to users.
This commit is contained in:
@@ -1146,6 +1146,15 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue
|
||||
foreach ($runtime_environment_variables as $env) {
|
||||
$envs->push($env->key.'='.$env->real_value);
|
||||
}
|
||||
|
||||
// Check for PORT environment variable mismatch with ports_exposes
|
||||
if ($this->build_pack !== 'dockercompose') {
|
||||
$detectedPort = $this->application->detectPortFromEnvironment(false);
|
||||
if ($detectedPort && ! empty($ports) && ! in_array($detectedPort, $ports)) {
|
||||
ray()->orange("PORT environment variable ({$detectedPort}) does not match configured ports_exposes: ".implode(',', $ports));
|
||||
}
|
||||
}
|
||||
|
||||
// Add PORT if not exists, use the first port as default
|
||||
if ($this->build_pack !== 'dockercompose') {
|
||||
if ($this->application->environment_variables->where('key', 'PORT')->isEmpty()) {
|
||||
|
||||
Reference in New Issue
Block a user