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"]