FROM python:3.12-slim

LABEL description="Sora curl_cffi sidecar - Chrome TLS fingerprint for Cloudflare bypass"

WORKDIR /app

# 安装依赖（curl_cffi 需要编译环境）
RUN apt-get update && apt-get install -y --no-install-recommends \
    gcc libffi-dev && \
    rm -rf /var/lib/apt/lists/*

COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

COPY app.py .

ENV PORT=8080
ENV IMPERSONATE=chrome131
ENV TIMEOUT_SECONDS=60
ENV SESSION_TTL_SECONDS=3600

EXPOSE 8080

HEALTHCHECK --interval=30s --timeout=5s --retries=3 --start-period=10s \
  CMD python -c "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8080/health')" || exit 1

CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:8080", "--timeout", "120", "app:app"]
