mirror of
https://github.com/cnlimiter/codex-register.git
synced 2026-07-02 12:52:20 +08:00
feat: 支持 Docker 部署和环境变量配置
- webui.py 支持从环境变量读取配置 (WEBUI_HOST, WEBUI_PORT 等) - 添加 Dockerfile 与 docker-compose.yml 方便本地与容器化部署 - 添加 GitHub Actions 配置,支持推送到 GitHub Container Registry (GHCR)
This commit is contained in:
42
webui.py
42
webui.py
@@ -112,30 +112,42 @@ def start_webui():
|
||||
def main():
|
||||
"""主函数"""
|
||||
import argparse
|
||||
import os
|
||||
|
||||
parser = argparse.ArgumentParser(description="OpenAI/Codex CLI 自动注册系统 Web UI")
|
||||
parser.add_argument("--host", help="监听主机")
|
||||
parser.add_argument("--port", type=int, help="监听端口")
|
||||
parser.add_argument("--debug", action="store_true", help="启用调试模式")
|
||||
parser.add_argument("--host", help="监听主机 (也可通过 WEBUI_HOST 环境变量设置)")
|
||||
parser.add_argument("--port", type=int, help="监听端口 (也可通过 WEBUI_PORT 环境变量设置)")
|
||||
parser.add_argument("--debug", action="store_true", help="启用调试模式 (也可通过 DEBUG=1 环境变量设置)")
|
||||
parser.add_argument("--reload", action="store_true", help="启用热重载")
|
||||
parser.add_argument("--log-level", help="日志级别")
|
||||
parser.add_argument("--access-password", help="Web UI 访问密钥")
|
||||
parser.add_argument("--log-level", help="日志级别 (也可通过 LOG_LEVEL 环境变量设置)")
|
||||
parser.add_argument("--access-password", help="Web UI 访问密钥 (也可通过 WEBUI_ACCESS_PASSWORD 环境变量设置)")
|
||||
args = parser.parse_args()
|
||||
|
||||
# 更新配置
|
||||
from src.config.settings import update_settings
|
||||
|
||||
updates = {}
|
||||
if args.host:
|
||||
updates["webui_host"] = args.host
|
||||
if args.port:
|
||||
updates["webui_port"] = args.port
|
||||
if args.debug:
|
||||
updates["debug"] = args.debug
|
||||
if args.log_level:
|
||||
updates["log_level"] = args.log_level
|
||||
if args.access_password:
|
||||
updates["webui_access_password"] = args.access_password
|
||||
|
||||
# 优先使用命令行参数,如果没有则尝试从环境变量获取
|
||||
host = args.host or os.environ.get("WEBUI_HOST")
|
||||
if host:
|
||||
updates["webui_host"] = host
|
||||
|
||||
port = args.port or os.environ.get("WEBUI_PORT")
|
||||
if port:
|
||||
updates["webui_port"] = int(port)
|
||||
|
||||
debug = args.debug or os.environ.get("DEBUG", "").lower() in ("1", "true", "yes")
|
||||
if debug:
|
||||
updates["debug"] = debug
|
||||
|
||||
log_level = args.log_level or os.environ.get("LOG_LEVEL")
|
||||
if log_level:
|
||||
updates["log_level"] = log_level
|
||||
|
||||
access_password = args.access_password or os.environ.get("WEBUI_ACCESS_PASSWORD")
|
||||
if access_password:
|
||||
updates["webui_access_password"] = access_password
|
||||
|
||||
if updates:
|
||||
update_settings(**updates)
|
||||
|
||||
Reference in New Issue
Block a user