@@ -1282,7 +1282,7 @@ private function generate_runtime_environment_variables()
12821282 });
12831283
12841284 foreach ($ runtime_environment_variables as $ env ) {
1285- $ envs ->push ($ env ->key .'= ' .$ env ->real_value );
1285+ $ envs ->push ($ env ->key .'= ' .$ env ->getResolvedValueWithServer ( $ this -> mainServer ) );
12861286 }
12871287
12881288 // Check for PORT environment variable mismatch with ports_exposes
@@ -1348,7 +1348,7 @@ private function generate_runtime_environment_variables()
13481348 });
13491349
13501350 foreach ($ runtime_environment_variables_preview as $ env ) {
1351- $ envs ->push ($ env ->key .'= ' .$ env ->real_value );
1351+ $ envs ->push ($ env ->key .'= ' .$ env ->getResolvedValueWithServer ( $ this -> mainServer ) );
13521352 }
13531353
13541354 // Fall back to production env vars for keys not overridden by preview vars,
@@ -1362,7 +1362,7 @@ private function generate_runtime_environment_variables()
13621362 return $ env ->is_runtime && ! in_array ($ env ->key , $ previewKeys );
13631363 });
13641364 foreach ($ fallback_production_vars as $ env ) {
1365- $ envs ->push ($ env ->key .'= ' .$ env ->real_value );
1365+ $ envs ->push ($ env ->key .'= ' .$ env ->getResolvedValueWithServer ( $ this -> mainServer ) );
13661366 }
13671367 }
13681368
@@ -1604,10 +1604,11 @@ private function generate_buildtime_environment_variables()
16041604 }
16051605
16061606 foreach ($ sorted_environment_variables as $ env ) {
1607+ $ resolvedValue = $ env ->getResolvedValueWithServer ($ this ->mainServer );
16071608 // For literal/multiline vars, real_value includes quotes that we need to remove
16081609 if ($ env ->is_literal || $ env ->is_multiline ) {
16091610 // Strip outer quotes from real_value and apply proper bash escaping
1610- $ value = trim ($ env -> real_value , "' " );
1611+ $ value = trim ($ resolvedValue , "' " );
16111612 $ escapedValue = escapeBashEnvValue ($ value );
16121613
16131614 if (isDev () && isset ($ envs_dict [$ env ->key ])) {
@@ -1619,13 +1620,13 @@ private function generate_buildtime_environment_variables()
16191620 if (isDev ()) {
16201621 $ this ->application_deployment_queue ->addLogEntry ("[DEBUG] Build-time env: {$ env ->key }" );
16211622 $ this ->application_deployment_queue ->addLogEntry ('[DEBUG] Type: literal/multiline ' );
1622- $ this ->application_deployment_queue ->addLogEntry ("[DEBUG] raw real_value: {$ env -> real_value }" );
1623+ $ this ->application_deployment_queue ->addLogEntry ("[DEBUG] raw real_value: {$ resolvedValue }" );
16231624 $ this ->application_deployment_queue ->addLogEntry ("[DEBUG] stripped value: {$ value }" );
16241625 $ this ->application_deployment_queue ->addLogEntry ("[DEBUG] final escaped: {$ escapedValue }" );
16251626 }
16261627 } else {
16271628 // For normal vars, use double quotes to allow $VAR expansion
1628- $ escapedValue = escapeBashDoubleQuoted ($ env -> real_value );
1629+ $ escapedValue = escapeBashDoubleQuoted ($ resolvedValue );
16291630
16301631 if (isDev () && isset ($ envs_dict [$ env ->key ])) {
16311632 $ this ->application_deployment_queue ->addLogEntry ("[DEBUG] User override: {$ env ->key } (was: {$ envs_dict [$ env ->key ]}, now: {$ escapedValue }) " );
@@ -1636,7 +1637,7 @@ private function generate_buildtime_environment_variables()
16361637 if (isDev ()) {
16371638 $ this ->application_deployment_queue ->addLogEntry ("[DEBUG] Build-time env: {$ env ->key }" );
16381639 $ this ->application_deployment_queue ->addLogEntry ('[DEBUG] Type: normal (allows expansion) ' );
1639- $ this ->application_deployment_queue ->addLogEntry ("[DEBUG] real_value: {$ env -> real_value }" );
1640+ $ this ->application_deployment_queue ->addLogEntry ("[DEBUG] real_value: {$ resolvedValue }" );
16401641 $ this ->application_deployment_queue ->addLogEntry ("[DEBUG] final escaped: {$ escapedValue }" );
16411642 }
16421643 }
@@ -1655,10 +1656,11 @@ private function generate_buildtime_environment_variables()
16551656 }
16561657
16571658 foreach ($ sorted_environment_variables as $ env ) {
1659+ $ resolvedValue = $ env ->getResolvedValueWithServer ($ this ->mainServer );
16581660 // For literal/multiline vars, real_value includes quotes that we need to remove
16591661 if ($ env ->is_literal || $ env ->is_multiline ) {
16601662 // Strip outer quotes from real_value and apply proper bash escaping
1661- $ value = trim ($ env -> real_value , "' " );
1663+ $ value = trim ($ resolvedValue , "' " );
16621664 $ escapedValue = escapeBashEnvValue ($ value );
16631665
16641666 if (isDev () && isset ($ envs_dict [$ env ->key ])) {
@@ -1670,13 +1672,13 @@ private function generate_buildtime_environment_variables()
16701672 if (isDev ()) {
16711673 $ this ->application_deployment_queue ->addLogEntry ("[DEBUG] Build-time env: {$ env ->key }" );
16721674 $ this ->application_deployment_queue ->addLogEntry ('[DEBUG] Type: literal/multiline ' );
1673- $ this ->application_deployment_queue ->addLogEntry ("[DEBUG] raw real_value: {$ env -> real_value }" );
1675+ $ this ->application_deployment_queue ->addLogEntry ("[DEBUG] raw real_value: {$ resolvedValue }" );
16741676 $ this ->application_deployment_queue ->addLogEntry ("[DEBUG] stripped value: {$ value }" );
16751677 $ this ->application_deployment_queue ->addLogEntry ("[DEBUG] final escaped: {$ escapedValue }" );
16761678 }
16771679 } else {
16781680 // For normal vars, use double quotes to allow $VAR expansion
1679- $ escapedValue = escapeBashDoubleQuoted ($ env -> real_value );
1681+ $ escapedValue = escapeBashDoubleQuoted ($ resolvedValue );
16801682
16811683 if (isDev () && isset ($ envs_dict [$ env ->key ])) {
16821684 $ this ->application_deployment_queue ->addLogEntry ("[DEBUG] User override: {$ env ->key } (was: {$ envs_dict [$ env ->key ]}, now: {$ escapedValue }) " );
@@ -1687,7 +1689,7 @@ private function generate_buildtime_environment_variables()
16871689 if (isDev ()) {
16881690 $ this ->application_deployment_queue ->addLogEntry ("[DEBUG] Build-time env: {$ env ->key }" );
16891691 $ this ->application_deployment_queue ->addLogEntry ('[DEBUG] Type: normal (allows expansion) ' );
1690- $ this ->application_deployment_queue ->addLogEntry ("[DEBUG] real_value: {$ env -> real_value }" );
1692+ $ this ->application_deployment_queue ->addLogEntry ("[DEBUG] real_value: {$ resolvedValue }" );
16911693 $ this ->application_deployment_queue ->addLogEntry ("[DEBUG] final escaped: {$ escapedValue }" );
16921694 }
16931695 }
@@ -2392,15 +2394,17 @@ private function generate_nixpacks_env_variables()
23922394 $ this ->env_nixpacks_args = collect ([]);
23932395 if ($ this ->pull_request_id === 0 ) {
23942396 foreach ($ this ->application ->nixpacks_environment_variables as $ env ) {
2395- if (! is_null ($ env ->real_value ) && $ env ->real_value !== '' ) {
2396- $ value = ($ env ->is_literal || $ env ->is_multiline ) ? trim ($ env ->real_value , "' " ) : $ env ->real_value ;
2397+ $ resolvedValue = $ env ->getResolvedValueWithServer ($ this ->mainServer );
2398+ if (! is_null ($ resolvedValue ) && $ resolvedValue !== '' ) {
2399+ $ value = ($ env ->is_literal || $ env ->is_multiline ) ? trim ($ resolvedValue , "' " ) : $ resolvedValue ;
23972400 $ this ->env_nixpacks_args ->push ('--env ' .escapeShellValue ("{$ env ->key }= {$ value }" ));
23982401 }
23992402 }
24002403 } else {
24012404 foreach ($ this ->application ->nixpacks_environment_variables_preview as $ env ) {
2402- if (! is_null ($ env ->real_value ) && $ env ->real_value !== '' ) {
2403- $ value = ($ env ->is_literal || $ env ->is_multiline ) ? trim ($ env ->real_value , "' " ) : $ env ->real_value ;
2405+ $ resolvedValue = $ env ->getResolvedValueWithServer ($ this ->mainServer );
2406+ if (! is_null ($ resolvedValue ) && $ resolvedValue !== '' ) {
2407+ $ value = ($ env ->is_literal || $ env ->is_multiline ) ? trim ($ resolvedValue , "' " ) : $ resolvedValue ;
24042408 $ this ->env_nixpacks_args ->push ('--env ' .escapeShellValue ("{$ env ->key }= {$ value }" ));
24052409 }
24062410 }
@@ -2539,8 +2543,9 @@ private function generate_env_variables()
25392543 ->get ();
25402544
25412545 foreach ($ envs as $ env ) {
2542- if (! is_null ($ env ->real_value )) {
2543- $ this ->env_args ->put ($ env ->key , $ env ->real_value );
2546+ $ resolvedValue = $ env ->getResolvedValueWithServer ($ this ->mainServer );
2547+ if (! is_null ($ resolvedValue )) {
2548+ $ this ->env_args ->put ($ env ->key , $ resolvedValue );
25442549 }
25452550 }
25462551 } else {
@@ -2550,8 +2555,9 @@ private function generate_env_variables()
25502555 ->get ();
25512556
25522557 foreach ($ envs as $ env ) {
2553- if (! is_null ($ env ->real_value )) {
2554- $ this ->env_args ->put ($ env ->key , $ env ->real_value );
2558+ $ resolvedValue = $ env ->getResolvedValueWithServer ($ this ->mainServer );
2559+ if (! is_null ($ resolvedValue )) {
2560+ $ this ->env_args ->put ($ env ->key , $ resolvedValue );
25552561 }
25562562 }
25572563 }
@@ -3566,7 +3572,7 @@ private function generate_secrets_hash($variables)
35663572 } else {
35673573 $ secrets_string = $ variables
35683574 ->map (function ($ env ) {
3569- return "{$ env ->key }= {$ env ->real_value }" ;
3575+ return "{$ env ->key }= {$ env ->getResolvedValueWithServer ( $ this -> mainServer ) }" ;
35703576 })
35713577 ->sort ()
35723578 ->implode ('| ' );
@@ -3632,7 +3638,7 @@ private function add_build_env_variables_to_dockerfile()
36323638 if (data_get ($ env , 'is_multiline ' ) === true ) {
36333639 $ argsToInsert ->push ("ARG {$ env ->key }" );
36343640 } else {
3635- $ argsToInsert ->push ("ARG {$ env ->key }= {$ env ->real_value }" );
3641+ $ argsToInsert ->push ("ARG {$ env ->key }= {$ env ->getResolvedValueWithServer ( $ this -> mainServer ) }" );
36363642 }
36373643 }
36383644 // Add Coolify variables as ARGs
@@ -3654,7 +3660,7 @@ private function add_build_env_variables_to_dockerfile()
36543660 if (data_get ($ env , 'is_multiline ' ) === true ) {
36553661 $ argsToInsert ->push ("ARG {$ env ->key }" );
36563662 } else {
3657- $ argsToInsert ->push ("ARG {$ env ->key }= {$ env ->real_value }" );
3663+ $ argsToInsert ->push ("ARG {$ env ->key }= {$ env ->getResolvedValueWithServer ( $ this -> mainServer ) }" );
36583664 }
36593665 }
36603666 // Add Coolify variables as ARGs
@@ -3690,7 +3696,7 @@ private function add_build_env_variables_to_dockerfile()
36903696 }
36913697 }
36923698 $ envs_mapped = $ envs ->mapWithKeys (function ($ env ) {
3693- return [$ env ->key => $ env ->real_value ];
3699+ return [$ env ->key => $ env ->getResolvedValueWithServer ( $ this -> mainServer ) ];
36943700 });
36953701 $ secrets_hash = $ this ->generate_secrets_hash ($ envs_mapped );
36963702 $ argsToInsert ->push ("ARG COOLIFY_BUILD_SECRETS_HASH= {$ secrets_hash }" );
0 commit comments