File size: 899 Bytes
9b6bfae
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
FROM python:3.12-slim

# System deps for Pillow + audio + tesseract
RUN apt-get update && apt-get install -y --no-install-recommends \
    build-essential \
    libjpeg-dev \
    zlib1g-dev \
    libpng-dev \
    ffmpeg \
    tesseract-ocr \
    && rm -rf /var/lib/apt/lists/*

# Working dir
WORKDIR /app

# Install Python deps first (better caching)
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Copy code
COPY captcha_solver/ ./captcha_solver/
COPY scripts/ ./scripts/

# Expose port (HF Spaces uses PORT env var, default 7860)
ENV PORT=7860
EXPOSE ${PORT}

# Healthcheck
HEALTHCHECK --interval=30s --timeout=10s --start-period=120s --retries=3 \
    CMD python -c "import httpx; httpx.get('http://localhost:${PORT:-7860}/health', timeout=5).raise_for_status()" || exit 1

# Run with configurable port
CMD sh -c "python -m captcha_solver.main --port ${PORT:-7860}"