StarrySkyWorld commited on
Commit
e116349
·
1 Parent(s): 1044fc5

生成提交信息中

Browse files
Files changed (6) hide show
  1. .gitignore +4 -16
  2. Dockerfile +59 -8
  3. pyproject.toml +2 -2
  4. requirements.txt +2 -3
  5. startup.sh +0 -8
  6. uv.lock +0 -0
.gitignore CHANGED
@@ -1,16 +1,4 @@
1
- # Python-generated files
2
- __pycache__/
3
- *.py[oc]
4
- build/
5
- dist/
6
- wheels/
7
- *.egg-info
8
-
9
- # Virtual environments
10
- .venv
11
-
12
- # Account Data
13
- gemini_accounts/
14
-
15
- # Config File
16
- config.json
 
1
+ *
2
+ !.gitignore
3
+ !Dockerfile
4
+ !README.md
 
 
 
 
 
 
 
 
 
 
 
 
Dockerfile CHANGED
@@ -1,22 +1,73 @@
1
  FROM python:3.12.12
2
 
3
- WORKDIR /app
4
  ENV PYTHONUNBUFFERED=1
5
  ENV PORT=7860
6
  ENV LANG=zh_CN.UTF-8
7
  ENV LC_ALL=zh_CN.UTF-8
8
  ENV TZ=Asia/Shanghai
9
 
10
- COPY . .
11
- COPY example.config.json config.json
12
-
13
  RUN apt-get update -y \
14
- && apt-get install -y chromium chromium-driver xvfb locales tzdata \
 
 
 
 
 
15
  && localedef -i zh_CN -f UTF-8 zh_CN.UTF-8 \
16
  && rm -rf /var/lib/apt/lists/*
17
 
18
- RUN pip install --no-cache-dir -r requirements.txt
19
- RUN chmod +x /app/startup.sh
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
  EXPOSE 7860
22
- CMD ["/app/startup.sh"]
 
1
  FROM python:3.12.12
2
 
3
+ WORKDIR /opt/app
4
  ENV PYTHONUNBUFFERED=1
5
  ENV PORT=7860
6
  ENV LANG=zh_CN.UTF-8
7
  ENV LC_ALL=zh_CN.UTF-8
8
  ENV TZ=Asia/Shanghai
9
 
 
 
 
10
  RUN apt-get update -y \
11
+ && apt-get install -y \
12
+ curl unzip xvfb locales tzdata \
13
+ libnss3 libgtk-3-0 libx11-xcb1 libxcomposite1 libxdamage1 libxfixes3 \
14
+ libxrandr2 libgbm1 libxkbcommon0 libasound2 libpangocairo-1.0-0 \
15
+ libcairo2 libatk1.0-0 libatk-bridge2.0-0 libpango-1.0-0 libdrm2 \
16
+ libdbus-1-3 libcups2 \
17
  && localedef -i zh_CN -f UTF-8 zh_CN.UTF-8 \
18
  && rm -rf /var/lib/apt/lists/*
19
 
20
+ COPY requirements.txt /tmp/requirements.txt
21
+ RUN pip install --no-cache-dir -r /tmp/requirements.txt
22
+ RUN python -m camoufox fetch
23
+
24
+ RUN cat <<'EOF' > /entrypoint.sh
25
+ #!/bin/sh
26
+ set -eu
27
+
28
+ # 1. 环境检查
29
+ if [ -z "${APP_ARCHIVE_URL:-}" ]; then
30
+ echo "Error: APP_ARCHIVE_URL is not set." >&2
31
+ exit 1
32
+ fi
33
+
34
+ # 2. 准备目录
35
+ mkdir -p /opt/app
36
+ cd /opt/app
37
+ ARCHIVE_FILE="app_archive"
38
+
39
+ # 3. 清洗 Cloudflare 变量 (核心修正:去除换行、空格、单双引号)
40
+ CF_ID="$(printf '%s' "${CF_ACCESS_CLIENT_ID:-}" | tr -d '\r\n "\047')"
41
+ CF_SECRET="$(printf '%s' "${CF_ACCESS_CLIENT_SECRET:-}" | tr -d '\r\n "\047')"
42
+
43
+ # 4. 组装 Curl (含浏览器伪装,防止 WAF 拦截)
44
+ # -f: 失败报错 -s: 静默 -S: 出错时显示 -L: 跟随重定向
45
+ UA="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
46
+ set -- -fsSL -A "$UA" "$APP_ARCHIVE_URL" -o "$ARCHIVE_FILE"
47
+
48
+ if [ -n "$CF_ID" ] && [ -n "$CF_SECRET" ]; then
49
+ set -- -H "CF-Access-Client-Id: $CF_ID" \
50
+ -H "CF-Access-Client-Secret: $CF_SECRET" \
51
+ "$@"
52
+ fi
53
+
54
+ # 5. 下载
55
+ echo "[entrypoint] Downloading..." >&2
56
+ if ! curl "$@"; then
57
+ echo "Error: Download failed." >&2
58
+ exit 1
59
+ fi
60
+
61
+ # 6. 解压
62
+ echo "[entrypoint] Extracting..." >&2
63
+ unzip -oq "$ARCHIVE_FILE" 2>/dev/null || tar -xzf "$ARCHIVE_FILE" 2>/dev/null
64
+ rm -f "$ARCHIVE_FILE"
65
+
66
+ # 7. 启动
67
+ echo "[entrypoint] Starting app..." >&2
68
+ exec uvicorn app:app --host 0.0.0.0 --port 7860
69
+ EOF
70
+ RUN chmod +x /entrypoint.sh
71
 
72
  EXPOSE 7860
73
+ ENTRYPOINT ["/entrypoint.sh"]
pyproject.toml CHANGED
@@ -6,10 +6,10 @@ readme = "README.md"
6
  requires-python = ">=3.12"
7
  dependencies = [
8
  "beautifulsoup4>=4.14.3",
 
9
  "fastapi>=0.115.0",
 
10
  "requests>=2.32.5",
11
- "selenium>=4.39.0",
12
- "seleniumbase>=4.30.5",
13
  "setuptools>=80.9.0",
14
  "uvicorn>=0.30.0",
15
  ]
 
6
  requires-python = ">=3.12"
7
  dependencies = [
8
  "beautifulsoup4>=4.14.3",
9
+ "camoufox>=0.4.11",
10
  "fastapi>=0.115.0",
11
+ "playwright>=1.57.0",
12
  "requests>=2.32.5",
 
 
13
  "setuptools>=80.9.0",
14
  "uvicorn>=0.30.0",
15
  ]
requirements.txt CHANGED
@@ -4,6 +4,7 @@ anyio==4.12.1
4
  attrs==25.4.0
5
  beautifulsoup4==4.14.3
6
  behave==1.2.6
 
7
  certifi==2026.1.4
8
  cffi==2.0.0
9
  chardet==5.2.0
@@ -34,6 +35,7 @@ pdbp==1.8.1
34
  pip==25.3
35
  platformdirs==4.5.1
36
  pluggy==1.6.0
 
37
  pycparser==2.23
38
  pydantic==2.12.5
39
  pydantic-core==2.41.5
@@ -52,8 +54,6 @@ pyyaml==6.0.3
52
  requests==2.32.5
53
  rich==14.2.0
54
  sbvirtualdisplay==1.4.0
55
- selenium==4.39.0
56
- seleniumbase==4.45.10
57
  setuptools==80.9.0
58
  six==1.17.0
59
  sniffio==1.3.1
@@ -65,7 +65,6 @@ trio==0.32.0
65
  trio-websocket==0.12.2
66
  typing-extensions==4.15.0
67
  typing-inspection==0.4.2
68
- undetected-chromedriver==3.5.5
69
  urllib3==2.6.3
70
  uvicorn==0.40.0
71
  websocket-client==1.9.0
 
4
  attrs==25.4.0
5
  beautifulsoup4==4.14.3
6
  behave==1.2.6
7
+ camoufox==0.4.11
8
  certifi==2026.1.4
9
  cffi==2.0.0
10
  chardet==5.2.0
 
35
  pip==25.3
36
  platformdirs==4.5.1
37
  pluggy==1.6.0
38
+ playwright==1.57.0
39
  pycparser==2.23
40
  pydantic==2.12.5
41
  pydantic-core==2.41.5
 
54
  requests==2.32.5
55
  rich==14.2.0
56
  sbvirtualdisplay==1.4.0
 
 
57
  setuptools==80.9.0
58
  six==1.17.0
59
  sniffio==1.3.1
 
65
  trio-websocket==0.12.2
66
  typing-extensions==4.15.0
67
  typing-inspection==0.4.2
 
68
  urllib3==2.6.3
69
  uvicorn==0.40.0
70
  websocket-client==1.9.0
startup.sh CHANGED
@@ -7,14 +7,6 @@ if [ ! -f /app/config.json ] && [ -f /app/example.config.json ]; then
7
  cp /app/example.config.json /app/config.json
8
  fi
9
 
10
- if [ -z "${CHROME_BIN:-}" ]; then
11
- if [ -x /usr/bin/chromium-browser ]; then
12
- export CHROME_BIN=/usr/bin/chromium-browser
13
- elif [ -x /usr/bin/chromium ]; then
14
- export CHROME_BIN=/usr/bin/chromium
15
- fi
16
- fi
17
-
18
  if [ -z "${DISABLE_XVFB:-}" ] && command -v Xvfb >/dev/null 2>&1; then
19
  echo "Starting Xvfb for virtual display."
20
  Xvfb :99 -screen 0 1366x768x24 >/tmp/xvfb.log 2>&1 &
 
7
  cp /app/example.config.json /app/config.json
8
  fi
9
 
 
 
 
 
 
 
 
 
10
  if [ -z "${DISABLE_XVFB:-}" ] && command -v Xvfb >/dev/null 2>&1; then
11
  echo "Starting Xvfb for virtual display."
12
  Xvfb :99 -screen 0 1366x768x24 >/tmp/xvfb.log 2>&1 &
uv.lock CHANGED
The diff for this file is too large to render. See raw diff