File size: 3,382 Bytes
e828090
 
 
 
 
 
 
 
9f2bb01
e828090
 
 
9f2bb01
e828090
9f2bb01
e828090
 
 
 
 
83199db
9f2bb01
 
 
 
 
e828090
 
 
16d7ff8
 
9f2bb01
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e828090
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
FROM python:3.10-slim

WORKDIR /app

# 安装系统依赖
RUN apt-get update && apt-get install -y \
    wget \
    curl \
    libgl1 \
    libglib2.0-0 \
    libsm6 \
    libxext6 \
    libxrender1 \
    libgomp1 \
    ffmpeg \
    && rm -rf /var/lib/apt/lists/*

ENV PYTHONUNBUFFERED=1
ENV FILE_LINK=""

COPY ./deps.txt deps.txt

# 安装依赖
RUN pip install --no-cache-dir -r /app/deps.txt

# 安装 Playwright
RUN playwright install chromium && \
    playwright install-deps chromium

RUN camoufox fetch

# 创建 entrypoint
RUN echo '#!/bin/bash' > /entrypoint.sh && \
    echo 'set -e' >> /entrypoint.sh && \
    echo '' >> /entrypoint.sh && \
    echo 'echo "==========================================="' >> /entrypoint.sh && \
    echo 'echo "🚀 ReCAPTCHA Solver API Server"' >> /entrypoint.sh && \
    echo 'echo "==========================================="' >> /entrypoint.sh && \
    echo '' >> /entrypoint.sh && \
    echo 'if [ -z "$FILE_LINK" ]; then' >> /entrypoint.sh && \
    echo '    echo "❌ 错误: 未设置 FILE_LINK 环境变量"' >> /entrypoint.sh && \
    echo '    echo "用法: docker run -e FILE_LINK=https://example.com/code.py ..."' >> /entrypoint.sh && \
    echo '    exit 1' >> /entrypoint.sh && \
    echo 'fi' >> /entrypoint.sh && \
    echo '' >> /entrypoint.sh && \
    echo 'echo "📥 下载代码: $FILE_LINK"' >> /entrypoint.sh && \
    echo '' >> /entrypoint.sh && \
    echo 'if wget -q --show-progress "$FILE_LINK" -O /app/recaptcha_api_server.py 2>&1; then' >> /entrypoint.sh && \
    echo '    echo "✅ wget 下载成功"' >> /entrypoint.sh && \
    echo 'elif curl -fSL "$FILE_LINK" -o /app/recaptcha_api_server.py 2>&1; then' >> /entrypoint.sh && \
    echo '    echo "✅ curl 下载成功"' >> /entrypoint.sh && \
    echo 'else' >> /entrypoint.sh && \
    echo '    echo "❌ 下载失败,请检查 FILE_LINK"' >> /entrypoint.sh && \
    echo '    exit 1' >> /entrypoint.sh && \
    echo 'fi' >> /entrypoint.sh && \
    echo '' >> /entrypoint.sh && \
    echo 'FILE_SIZE=$(stat -c%s /app/recaptcha_api_server.py 2>/dev/null || echo 0)' >> /entrypoint.sh && \
    echo 'echo "📊 文件大小: $FILE_SIZE bytes"' >> /entrypoint.sh && \
    echo '' >> /entrypoint.sh && \
    echo 'if [ "$FILE_SIZE" -lt 1000 ]; then' >> /entrypoint.sh && \
    echo '    echo "⚠️  文件太小,可能无效"' >> /entrypoint.sh && \
    echo 'fi' >> /entrypoint.sh && \
    echo '' >> /entrypoint.sh && \
    echo 'echo "🔧 安装依赖..."' >> /entrypoint.sh && \
    echo 'pip install --no-cache-dir -r /app/deps.txt -q 2>&1 || true' >> /entrypoint.sh && \
    echo '' >> /entrypoint.sh && \
    echo 'echo ""' >> /entrypoint.sh && \
    echo 'echo "==========================================="' >> /entrypoint.sh && \
    echo 'echo "🎯 启动服务器"' >> /entrypoint.sh && \
    echo 'echo "==========================================="' >> /entrypoint.sh && \
    echo 'echo "📡 地址: http://0.0.0.0:8000"' >> /entrypoint.sh && \
    echo 'echo "📝 文档: http://localhost:8000/docs"' >> /entrypoint.sh && \
    echo 'echo "==========================================="' >> /entrypoint.sh && \
    echo 'echo ""' >> /entrypoint.sh && \
    echo '' >> /entrypoint.sh && \
    echo 'exec python /app/recaptcha_api_server.py' >> /entrypoint.sh && \
    chmod +x /entrypoint.sh

EXPOSE 8000

ENTRYPOINT ["/entrypoint.sh"]