qiaofeng1227 2 年之前
父节点
当前提交
4ade655f34
共有 3 个文件被更改,包括 16 次插入4 次删除
  1. 2 2
      appmanage/Dockerfile
  2. 3 2
      appmanage/api/service/manage.py
  3. 11 0
      appmanage/api/utils/docker.py

+ 2 - 2
appmanage/Dockerfile

@@ -10,7 +10,7 @@ COPY static ./static
 COPY requirements.txt main.py  ./
 RUN apt update
 
-# Install supervisordss
+# Install supervisord
 RUN apt install -y supervisor
 COPY config/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
 COPY config/cmd.sh /cmd.sh
@@ -18,5 +18,5 @@ RUN chmod +x /etc/supervisor/conf.d/supervisord.conf /cmd.sh
 RUN pip install -r requirements.txt
 RUN mkdir /data
 
-# Expose the port in which the application will be deployed
+# Expose the port in which the application will be deployeds
 EXPOSE 5000

+ 3 - 2
appmanage/api/service/manage.py

@@ -326,7 +326,7 @@ def get_apps_from_compose():
         default_domain = ""
         if customer_name in ['w9appmanage', 'w9nginxproxymanager','w9redis','w9portainer'] and app_path == '/data/apps/stackhub/docker/' + customer_name:
             continue
-        # get code
+    
         status = app_info["Status"].split("(")[0]
         if status == "running" or status == "exited" or status == "restarting":
             myLogger.info_logger("ok")
@@ -352,8 +352,9 @@ def get_apps_from_compose():
             image_url = get_Image_url(app_name)
             # get env info
             path = app_path + "/.env"
+            env_map = docker.get_map(path)
             try:
-                domain = list(docker.read_env(path, "APP_URL").values())[0]
+                domain = env_map.get("APP_URL")
                 if "appname.example.com" in domain or ip in domain:
                     default_domain = ""
                 else:

+ 11 - 0
appmanage/api/utils/docker.py

@@ -177,6 +177,17 @@ def check_app_url(customer_app_name):
     myLogger.info_logger("App url check complete")
     return
 
+def get_map(path):
+    myLogger.info_logger("Read env_dic" + path)
+    output = shell_execute.execute_command_output_all("cat " + path)
+    code = output["code"]
+    env_dic = {}
+    if int(code) == 0:
+        ret = output["result"]
+        env_list = ret.split("\n")
+        for env in env_list:
+            env_dic[env.split("=")[0]] = env.split("=")[1]
+    return env_dic
 
 def read_env(path, key):
     myLogger.info_logger("Read " + path)