Dockerfile 部署

This commit is contained in:
hjq
2026-06-12 16:59:21 +08:00
parent 81e2659b3a
commit dd0e09a34f

View File

@@ -50,7 +50,15 @@ def get_page(headless: bool = False, port: int = 9222) -> ChromiumPage:
co.set_argument("--no-sandbox") co.set_argument("--no-sandbox")
co.set_argument("--disable-dev-shm-usage") # 增加这个参数防止容器内存不足 co.set_argument("--disable-dev-shm-usage") # 增加这个参数防止容器内存不足
co.set_argument("--window-size=1440,900") co.set_argument("--window-size=1440,900")
if is_docker:
# 在 Docker 生产环境中,为了防止僵尸进程占用固定端口导致 404 握手失败
# 我们使用 auto_port(True) 让它每次都随机分配一个空闲端口,完全隔离
co.auto_port(True)
else:
# 本地开发环境保持使用固定端口,方便复用已经打开的浏览器
co.set_local_port(port) co.set_local_port(port)
return ChromiumPage(co) return ChromiumPage(co)