Browse Source

fix(docker): xcat not load env

Indexyz 5 years ago
parent
commit
0de9c945f7
2 changed files with 13 additions and 10 deletions
  1. 12 10
      app/envload.php
  2. 1 0
      xcat

+ 12 - 10
app/envload.php

@@ -13,16 +13,18 @@ function findKeyName($name)
     return NULL;
 }
 
-foreach (getenv() as $envKey => $envValue) {
-    global $_ENV;
-    $envUpKey = strtoupper($envKey);
-    // Key starts with UIM_
-    if (substr($envUpKey, 0, 4) == "UIM_") {
-        // Vaild env key, set to _ENV
-        $configKey = substr($envUpKey, 4);
-        $realKey = findKeyName($configKey);
-        if ($realKey != NULL) {
-            $_ENV[$realKey] = $envValue;
+if (getenv('UIM_ENV_REPLACE_ENABLE')) {
+    foreach (getenv() as $envKey => $envValue) {
+        global $_ENV;
+        $envUpKey = strtoupper($envKey);
+        // Key starts with UIM_
+        if (substr($envUpKey, 0, 4) == "UIM_") {
+            // Vaild env key, set to _ENV
+            $configKey = substr($envUpKey, 4);
+            $realKey = findKeyName($configKey);
+            if ($realKey != NULL) {
+                $_ENV[$realKey] = $envValue;
+            }
         }
     }
 }

+ 1 - 0
xcat

@@ -8,6 +8,7 @@ use App\Services\Boot;
 require __DIR__ . '/app/predefine.php';
 require __DIR__ . '/vendor/autoload.php';
 require __DIR__ . '/config/.config.php';
+require __DIR__ . '/app/envload.php';
 
 Boot::setTime();
 Boot::bootDb();