Dockerfile 部署

This commit is contained in:
hjq
2026-06-12 16:16:07 +08:00
parent cb5baf809e
commit 9d31b37c7a

View File

@@ -37,6 +37,8 @@ COPY . .
# 暴露 Flask 服务的 5050 端口
EXPOSE 5050
# 启动脚本:使用 xvfb-run 虚拟出一个屏幕来运行 Python 程序
# --server-args="-screen 0 1920x1080x24" 设置虚拟屏幕的分辨率
CMD ["xvfb-run", "--server-args=-screen 0 1920x1080x24", "gunicorn", "-w", "4", "-b", "0.0.0.0:5050", "--timeout", "120", "web_ui.app:app"]
# 启动脚本:
# 1. 清理可能因异常重启遗留的虚拟屏幕锁文件(防止 xvfb 报错退出)
# 2. 切换到 web_ui 目录执行 gunicorn
# 3. 使用 xvfb-run -a 自动分配空闲的虚拟屏幕
CMD sh -c "rm -f /tmp/.X*-lock && cd web_ui && xvfb-run -a --server-args='-screen 0 1920x1080x24' gunicorn -w 4 -b 0.0.0.0:5050 --timeout 120 app:app"