File size: 2,134 Bytes
865f055
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86a6810
 
 
865f055
86a6810
 
865f055
 
 
86a6810
865f055
 
 
86a6810
865f055
86a6810
 
865f055
 
 
 
86a6810
 
4874383
86a6810
4874383
86a6810
865f055
 
 
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
FROM python:3.13-slim-bookworm AS builder

# Build dummy packages to skip installing heavy UI dependencies
RUN apt-get update \
    && apt-get install -y --no-install-recommends equivs \
    && equivs-control libgl1-mesa-dri \
    && printf 'Section: misc\nPriority: optional\nStandards-Version: 3.9.2\nPackage: libgl1-mesa-dri\nVersion: 99.0.0\nDescription: Dummy package for libgl1-mesa-dri\n' >> libgl1-mesa-dri \
    && equivs-build libgl1-mesa-dri \
    && mv libgl1-mesa-dri_*.deb /libgl1-mesa-dri.deb \
    && equivs-control adwaita-icon-theme \
    && printf 'Section: misc\nPriority: optional\nStandards-Version: 3.9.2\nPackage: adwaita-icon-theme\nVersion: 99.0.0\nDescription: Dummy package for adwaita-icon-theme\n' >> adwaita-icon-theme \
    && equivs-build adwaita-icon-theme \
    && mv adwaita-icon-theme_*.deb /adwaita-icon-theme.deb

FROM python:3.13-slim-bookworm

# Copy dummy packages
COPY --from=builder /*.deb /

# Install Chromium and XVFB virtual display
RUN dpkg -i /libgl1-mesa-dri.deb \
    && dpkg -i /adwaita-icon-theme.deb \
    && apt-get update \
    && apt-get install -y --no-install-recommends chromium chromium-common chromium-driver xvfb dumb-init git procps curl xvfb xauth \
    && rm -rf /var/lib/apt/lists/* \
    && mv /usr/bin/chromedriver /usr/bin/chromedriver-system

# Create HuggingFace mandatory user: UID 1000
RUN useradd -m -u 1000 user 

WORKDIR /app

# Clone the FlareSolverr codebase
RUN git clone https://github.com/FlareSolverr/FlareSolverr.git .

# Relocate chromedriver inward and set ownership
RUN mv /usr/bin/chromedriver-system chromedriver \
    && chown -R user:user /app

# Install Python dependencies
RUN pip install -r requirements.txt --no-cache-dir \
    && rm -rf /root/.cache

# Switch to standard HF user
USER user

# Ensure crash folder exists as HF prevents root-level creation dynamically
RUN mkdir -p "/app/.config/chromium/Crash Reports/pending"

# Set environment
ENV LOG_LEVEL=info
ENV HEADLESS=true
ENV PORT=7860

EXPOSE 7860

# Start virtual display & Python solver
ENTRYPOINT ["dumb-init", "xvfb-run", "-a"]
CMD ["python", "-u", "src/flaresolverr.py"]