StarrySkyWorld commited on
Commit
df577d6
·
1 Parent(s): 86d4562

fix: 修正Dockerfile中的路径和启动命令

Browse files

- 修改工作目录从 `/opt/app` 为 `/app`。
- 移除旧的 `entrypoint.sh` 脚本内容,改为直接复制当前目录下的所有文件到 `/app`。
- 添加 `*.pyc`, `*.log`, `*.zip`, `*.json`, `tool.*` 到 `.gitignore` 以忽略这些文件。
- 增加新的 `startup.sh` 脚本到 `.gitignore` 中。
- 使用 `CMD` 替代 `ENTRYPOINT` 以指定容器启动时执行的命令,改为 `/app/startup.sh`。

Files changed (2) hide show
  1. .gitignore +7 -4
  2. Dockerfile +5 -54
.gitignore CHANGED
@@ -1,4 +1,7 @@
1
- *
2
- !.gitignore
3
- !Dockerfile
4
- !README.md
 
 
 
 
1
+ gemini_accounts/
2
+ screenshots/
3
+ *.pyc
4
+ *.log
5
+ *.zip
6
+ *.json
7
+ tool.*
Dockerfile CHANGED
@@ -1,6 +1,6 @@
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
@@ -9,7 +9,7 @@ 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 \
@@ -20,57 +20,8 @@ RUN apt-get update -y \
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
- rm -rf *.py
62
-
63
- # 6. 解压
64
- echo "[entrypoint] Extracting..." >&2
65
- unzip -oq "$ARCHIVE_FILE" 2>/dev/null || tar -xzf "$ARCHIVE_FILE" 2>/dev/null
66
- rm -f "$ARCHIVE_FILE"
67
-
68
- # 7. 启动
69
- echo "[entrypoint] Starting app..." >&2
70
- rm -rf config.json example.config.json
71
- exec uvicorn server:app --host 0.0.0.0 --port 7860
72
- EOF
73
- RUN chmod +x /entrypoint.sh
74
 
75
  EXPOSE 7860
76
- ENTRYPOINT ["/entrypoint.sh"]
 
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
 
9
 
10
  RUN apt-get update -y \
11
  && apt-get install -y \
12
+ 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 \
 
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
+ COPY . .
24
+ RUN chmod +x /app/startup.sh
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
 
26
  EXPOSE 7860
27
+ CMD ["/app/startup.sh"]