From 32d58940ffea60fb461f7a11050323b6097f2799 Mon Sep 17 00:00:00 2001 From: Rixuan Shao <2023311022@bipt.edu.cn> Date: Sat, 11 Jul 2026 15:42:34 +0800 Subject: [PATCH] fix: provision Node runtime in server image --- .env.example | 1 + CHANGELOG.md | 2 ++ DouYinSparkFlow/.dockerignore | 12 ++++++++++++ DouYinSparkFlow/Dockerfile.server | 4 ++++ DouYinSparkFlow/tests/test_deployment_contract.py | 7 +++++++ deploy/install-server.sh | 2 +- docker-compose.yml | 1 + 7 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 DouYinSparkFlow/.dockerignore diff --git a/.env.example b/.env.example index da29075..01234e4 100644 --- a/.env.example +++ b/.env.example @@ -26,6 +26,7 @@ PROXY_USER_AGENT=clash-verge/1.7.7 # If the mirror is unavailable, change it back to: # PLAYWRIGHT_BASE_IMAGE=mcr.microsoft.com/playwright/python:v1.56.0-jammy PLAYWRIGHT_BASE_IMAGE=swr.cn-north-4.myhuaweicloud.com/ddn-k8s/mcr.microsoft.com/playwright/python:v1.56.0-jammy +NODE_RUNTIME_IMAGE=node:22-bookworm-slim # Optional build-time proxy. Leave empty unless your Docker build needs a proxy. HTTP_PROXY_BUILD= diff --git a/CHANGELOG.md b/CHANGELOG.md index 9732b51..3155ae5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## 2026-07-11 +- Fixed the server image to provision Node.js 22 explicitly for protocol mode and excluded runtime logs/configuration from the Docker build context. + - Reworked the Web console into a responsive unified operations dashboard with local Lucide icons, clearer account/target status, and safer confirmation dialogs. - Added strong send-confirmation state handling, retryable unconfirmed targets, failure categorization, account cooldowns, and focused manual retry modes. - Improved friend-list discovery, persistent browser profiles, Cookie synchronization, and browser/protocol failure persistence. diff --git a/DouYinSparkFlow/.dockerignore b/DouYinSparkFlow/.dockerignore new file mode 100644 index 0000000..465bd53 --- /dev/null +++ b/DouYinSparkFlow/.dockerignore @@ -0,0 +1,12 @@ +__pycache__/ +*.py[cod] +.pytest_cache/ +.ruff_cache/ +.git/ +.github/ +tests/ +logs/ +config.json +usersData.json +webui_settings.json +*.log diff --git a/DouYinSparkFlow/Dockerfile.server b/DouYinSparkFlow/Dockerfile.server index 99eef73..743a5da 100644 --- a/DouYinSparkFlow/Dockerfile.server +++ b/DouYinSparkFlow/Dockerfile.server @@ -1,6 +1,10 @@ ARG PLAYWRIGHT_BASE_IMAGE=mcr.microsoft.com/playwright/python:v1.56.0-jammy +ARG NODE_RUNTIME_IMAGE=node:22-bookworm-slim +FROM ${NODE_RUNTIME_IMAGE} AS node-runtime FROM ${PLAYWRIGHT_BASE_IMAGE} +COPY --from=node-runtime /usr/local/bin/node /usr/local/bin/node + WORKDIR /app ARG HTTP_PROXY diff --git a/DouYinSparkFlow/tests/test_deployment_contract.py b/DouYinSparkFlow/tests/test_deployment_contract.py index abc5fc6..d268125 100644 --- a/DouYinSparkFlow/tests/test_deployment_contract.py +++ b/DouYinSparkFlow/tests/test_deployment_contract.py @@ -88,11 +88,18 @@ class DeploymentContractTests(unittest.TestCase): def test_playwright_base_image_argument_is_used(self): dockerfile = (SOURCE_ROOT / "Dockerfile.server").read_text(encoding="utf-8") self.assertTrue(dockerfile.startswith("ARG PLAYWRIGHT_BASE_IMAGE=")) + self.assertIn("FROM ${NODE_RUNTIME_IMAGE} AS node-runtime", dockerfile) self.assertIn("FROM ${PLAYWRIGHT_BASE_IMAGE}", dockerfile) + self.assertIn("COPY --from=node-runtime /usr/local/bin/node", dockerfile) self.assertIn("docker.io", dockerfile) self.assertIn("node --version", dockerfile) self.assertNotIn("github.com/docker/compose", dockerfile) + def test_docker_build_context_excludes_runtime_data(self): + dockerignore = (SOURCE_ROOT / ".dockerignore").read_text(encoding="utf-8") + for entry in ("logs/", "config.json", "usersData.json", "webui_settings.json"): + self.assertIn(entry, dockerignore) + def test_legacy_unused_entrypoints_are_removed(self): self.assertFalse((SOURCE_ROOT / "webui" / "login_sessions.py").exists()) self.assertFalse((SOURCE_ROOT / "relogin_worker.py").exists()) diff --git a/deploy/install-server.sh b/deploy/install-server.sh index aaf4a3e..dbc087f 100755 --- a/deploy/install-server.sh +++ b/deploy/install-server.sh @@ -156,7 +156,7 @@ prepare_runtime_files() { set_env_value "$env_file" "APP_ROOT" "$APP_ROOT" set_env_value "$env_file" "DEFAULT_SCHEDULE" "$DEFAULT_SCHEDULE" - for key in TZ WEB_BIND_ADDRESS WEB_PORT SPARKFLOW_SESSION_COOKIE_SECURE LOGIN_DESKTOP_BIND_ADDRESS LOGIN_DESKTOP_WEB_PORT LOGIN_DESKTOP_PUBLIC_URL PROXY_BIND_ADDRESS PROXY_HTTP_PORT PROXY_CONTROLLER_PORT PROXY_SUB_URL PROXY_USER_AGENT PLAYWRIGHT_BASE_IMAGE HTTP_PROXY_BUILD HTTPS_PROXY_BUILD ALL_PROXY_BUILD PIP_INDEX_URL PIP_TRUSTED_HOST; do + for key in TZ WEB_BIND_ADDRESS WEB_PORT SPARKFLOW_SESSION_COOKIE_SECURE LOGIN_DESKTOP_BIND_ADDRESS LOGIN_DESKTOP_WEB_PORT LOGIN_DESKTOP_PUBLIC_URL PROXY_BIND_ADDRESS PROXY_HTTP_PORT PROXY_CONTROLLER_PORT PROXY_SUB_URL PROXY_USER_AGENT PLAYWRIGHT_BASE_IMAGE NODE_RUNTIME_IMAGE HTTP_PROXY_BUILD HTTPS_PROXY_BUILD ALL_PROXY_BUILD PIP_INDEX_URL PIP_TRUSTED_HOST; do if [ -n "${!key:-}" ]; then set_env_value "$env_file" "$key" "${!key}" fi diff --git a/docker-compose.yml b/docker-compose.yml index ba071da..c31debb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -21,6 +21,7 @@ services: network: host args: PLAYWRIGHT_BASE_IMAGE: ${PLAYWRIGHT_BASE_IMAGE:-swr.cn-north-4.myhuaweicloud.com/ddn-k8s/mcr.microsoft.com/playwright/python:v1.56.0-jammy} + NODE_RUNTIME_IMAGE: ${NODE_RUNTIME_IMAGE:-node:22-bookworm-slim} HTTP_PROXY: ${HTTP_PROXY_BUILD:-} HTTPS_PROXY: ${HTTPS_PROXY_BUILD:-} ALL_PROXY: ${ALL_PROXY_BUILD:-}