mirror of
https://github.com/Websoft9/websoft9.git
synced 2025-01-24 10:17:15 +08:00
new need
This commit is contained in:
parent
c0d6673455
commit
c393a7b75a
@ -10,7 +10,7 @@ COPY static ./static
|
|||||||
COPY requirements.txt main.py ./
|
COPY requirements.txt main.py ./
|
||||||
RUN apt update
|
RUN apt update
|
||||||
|
|
||||||
# Install supervisord
|
# Install supervisords
|
||||||
RUN apt install -y supervisor
|
RUN apt install -y supervisor
|
||||||
COPY config/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
COPY config/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
||||||
COPY config/cmd.sh /cmd.sh
|
COPY config/cmd.sh /cmd.sh
|
||||||
|
@ -10,5 +10,11 @@ class App(BaseModel):
|
|||||||
status: str
|
status: str
|
||||||
status_reason: StatusReason = None
|
status_reason: StatusReason = None
|
||||||
official_app: bool
|
official_app: bool
|
||||||
|
app_version: str
|
||||||
|
create_time: str
|
||||||
|
volume_data = []
|
||||||
|
config_path = str
|
||||||
image_url: str
|
image_url: str
|
||||||
|
app_https: bool
|
||||||
|
app_replace_url: bool
|
||||||
config: Config = None
|
config: Config = None
|
||||||
|
@ -5,7 +5,6 @@ class Config(BaseModel):
|
|||||||
compose_file: str
|
compose_file: str
|
||||||
url: str
|
url: str
|
||||||
admin_url: str
|
admin_url: str
|
||||||
user_name: str
|
admin_username: str
|
||||||
password: str
|
admin_password: str
|
||||||
default_domain: str
|
default_domain: str
|
||||||
set_domain: str
|
|
||||||
|
@ -297,7 +297,13 @@ def get_apps_from_compose():
|
|||||||
user_name = ""
|
user_name = ""
|
||||||
password = ""
|
password = ""
|
||||||
official_app = False
|
official_app = False
|
||||||
|
app_version = ""
|
||||||
|
create_time = ""
|
||||||
|
volume_data = []
|
||||||
|
config_path = app_path
|
||||||
|
app_https = False
|
||||||
|
app_replace_url = False
|
||||||
|
default_domain = ""
|
||||||
if customer_name in ['w9appmanage', 'w9nginxproxymanager','w9redis','w9portainer'] and app_path == '/data/apps/stackhub/docker/' + customer_name:
|
if customer_name in ['w9appmanage', 'w9nginxproxymanager','w9redis','w9portainer'] and app_path == '/data/apps/stackhub/docker/' + customer_name:
|
||||||
continue
|
continue
|
||||||
# get code
|
# get code
|
||||||
@ -319,47 +325,67 @@ def get_apps_from_compose():
|
|||||||
image_url = get_Image_url(app_name)
|
image_url = get_Image_url(app_name)
|
||||||
# get env info
|
# get env info
|
||||||
path = app_path + "/.env"
|
path = app_path + "/.env"
|
||||||
# get port and url
|
|
||||||
try:
|
try:
|
||||||
http_port = list(docker.read_env(
|
domain = list(docker.read_env(path, "APP_URL").values())[0]
|
||||||
path, "APP_HTTP_PORT").values())[0]
|
if "appname.example.com" in domain or ip in domain:
|
||||||
port = int(http_port)
|
default_domain = ""
|
||||||
easy_url = "http://" + ip + ":" + str(port)
|
else:
|
||||||
url = get_url(app_name, easy_url)
|
default_domain = domain
|
||||||
admin_url = get_admin_url(app_name, url)
|
|
||||||
except IndexError:
|
except IndexError:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
app_version = list(docker.read_env(path, "APP_VERSION").values())[0]
|
||||||
|
volume_data = ["/var/lib/docker/volumes"]
|
||||||
|
user_name = list(docker.read_env(path, "APP_USER").values())[0]
|
||||||
|
password = list(docker.read_env(path, "POWER_PASSWORD").values())[0]
|
||||||
|
|
||||||
|
except IndexError:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
replace = list(docker.read_env(path, "APP_URL_REPLACE").values())[0]
|
||||||
|
if replace == "true":
|
||||||
|
app_replace_url = True
|
||||||
|
https = list(docker.read_env(path, "APP_HTTPS_ACCESS").values())[0]
|
||||||
|
if https == "true":
|
||||||
|
app_https = True
|
||||||
|
except IndexError:
|
||||||
|
pass
|
||||||
|
if user_name != "":
|
||||||
|
try:
|
||||||
|
http_port = list(docker.read_env(path, "APP_HTTP_PORT").values())[0]
|
||||||
|
port = int(http_port)
|
||||||
|
if app_https:
|
||||||
|
easy_url = "https://" + ip + ":" + str(port)
|
||||||
|
else:
|
||||||
|
easy_url = "http://" + ip + ":" + str(port)
|
||||||
|
url = easy_url
|
||||||
|
admin_url = get_admin_url(customer_name, url)
|
||||||
|
except IndexError:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
try:
|
try:
|
||||||
db_port = list(docker.read_env(path, "APP_DB.*_PORT").values())[0]
|
db_port = list(docker.read_env(path, "APP_DB.*_PORT").values())[0]
|
||||||
port = int(db_port)
|
port = int(db_port)
|
||||||
except IndexError:
|
except IndexError:
|
||||||
pass
|
pass
|
||||||
# get user_name
|
|
||||||
try:
|
|
||||||
user_name = list(docker.read_env(path, "APP_USER").values())[0]
|
|
||||||
except IndexError:
|
|
||||||
pass
|
|
||||||
# get password
|
|
||||||
try:
|
|
||||||
password = list(docker.read_env(path, "POWER_PASSWORD").values())[0]
|
|
||||||
except IndexError:
|
|
||||||
pass
|
|
||||||
else:
|
else:
|
||||||
app_name = customer_name
|
app_name = customer_name
|
||||||
app_id = customer_name + "_" + customer_name
|
app_id = customer_name + "_" + customer_name
|
||||||
|
|
||||||
if status in ['running', 'exited']:
|
if status in ['running', 'exited']:
|
||||||
config = Config(port=port, compose_file=volume, url=url, admin_url=admin_url,
|
config = Config(port=port, compose_file=volume, url=url, admin_url=admin_url,
|
||||||
user_name=user_name, password=password, default_domain="", set_domain="")
|
app_username=user_name, app_password=password, default_domain=default_domain)
|
||||||
else:
|
else:
|
||||||
config = None
|
config = None
|
||||||
if status == "failed":
|
if status == "failed":
|
||||||
status_reason = StatusReason(Code=const.ERROR_SERVER_SYSTEM, Message="system original error", Detail="unknown error")
|
status_reason = StatusReason(Code=const.ERROR_SERVER_SYSTEM, Message="system original error", Detail="unknown error")
|
||||||
else:
|
else:
|
||||||
status_reason = None
|
status_reason = None
|
||||||
|
app = App(app_id=id, app_name=app_name, customer_name=customer_name, trade_mark=trade_mark,
|
||||||
|
app_version=app_version,create_time=create_time,volume_data=volume_data,config_path=config_path,
|
||||||
|
status=status, status_reason=status_reason, official_app=official_app, image_url=image_url,
|
||||||
|
app_https=app_https,app_replace_url=app_https,config=config)
|
||||||
|
|
||||||
app = App(app_id=app_id, app_name=app_name, customer_name=customer_name, trade_mark=trade_mark, status=status,
|
|
||||||
status_reason=status_reason, official_app=official_app, image_url=image_url,
|
|
||||||
config=config)
|
|
||||||
app_list.append(app.dict())
|
app_list.append(app.dict())
|
||||||
return app_list
|
return app_list
|
||||||
|
|
||||||
@ -466,7 +492,10 @@ def get_rq_app(id, status, code, message, detail):
|
|||||||
customer_name = id.split('_')[1]
|
customer_name = id.split('_')[1]
|
||||||
# 当app还在RQ时,可能文件夹还没创建,无法获取trade_mark
|
# 当app还在RQ时,可能文件夹还没创建,无法获取trade_mark
|
||||||
trade_mark = ""
|
trade_mark = ""
|
||||||
|
app_version = ""
|
||||||
|
create_time = ""
|
||||||
|
volume_data = []
|
||||||
|
config_path = ""
|
||||||
image_url = get_Image_url(app_name)
|
image_url = get_Image_url(app_name)
|
||||||
config = None
|
config = None
|
||||||
if status == "installing" :
|
if status == "installing" :
|
||||||
@ -475,8 +504,9 @@ def get_rq_app(id, status, code, message, detail):
|
|||||||
status_reason = StatusReason(Code=code, Message=message, Detail=detail)
|
status_reason = StatusReason(Code=code, Message=message, Detail=detail)
|
||||||
|
|
||||||
app = App(app_id=id, app_name=app_name, customer_name=customer_name, trade_mark=trade_mark,
|
app = App(app_id=id, app_name=app_name, customer_name=customer_name, trade_mark=trade_mark,
|
||||||
|
app_version=app_version,create_time=create_time,volume_data=volume_data,config_path=config_path,
|
||||||
status=status, status_reason=status_reason, official_app=True, image_url=image_url,
|
status=status, status_reason=status_reason, official_app=True, image_url=image_url,
|
||||||
config=config)
|
app_https=False,app_replace_url=False,config=config)
|
||||||
return app.dict()
|
return app.dict()
|
||||||
|
|
||||||
def get_Image_url(app_name):
|
def get_Image_url(app_name):
|
||||||
@ -486,23 +516,16 @@ def get_Image_url(app_name):
|
|||||||
|
|
||||||
def get_url(app_name, easy_url):
|
def get_url(app_name, easy_url):
|
||||||
url = easy_url
|
url = easy_url
|
||||||
if app_name == "joomla":
|
|
||||||
url = easy_url + "/administrator"
|
|
||||||
elif app_name == "other":
|
|
||||||
url = easy_url + "/administrator"
|
|
||||||
else:
|
|
||||||
url = easy_url
|
|
||||||
return url
|
return url
|
||||||
|
|
||||||
|
def get_admin_url(customer_name, url):
|
||||||
def get_admin_url(app_name, url):
|
|
||||||
admin_url = ""
|
|
||||||
if app_name == "wordpress":
|
|
||||||
admin_url = url + "/wp-admin"
|
|
||||||
elif app_name == "other":
|
|
||||||
admin_url = url + "/admin"
|
|
||||||
else:
|
|
||||||
admin_url = ""
|
admin_url = ""
|
||||||
|
path = "/data/apps/" + customer_name
|
||||||
|
try:
|
||||||
|
admin_path = list(docker.read_env(path, "APP_ADMIN_PATH").values())[0]
|
||||||
|
admin_url = url + admin_path
|
||||||
|
except IndexError:
|
||||||
|
pass
|
||||||
return admin_url
|
return admin_url
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user