File size: 1,729 Bytes
d09ff05
 
 
 
 
96cbe01
 
87aa947
96cbe01
406067c
285afa0
406067c
96cbe01
 
87aa947
 
 
 
406067c
 
 
96cbe01
 
4ea3a39
 
 
 
406067c
4ea3a39
406067c
75dc612
 
87aa947
75dc612
 
d09ff05
 
96cbe01
 
 
 
 
 
d09ff05
96cbe01
 
 
406067c
1265a74
406067c
96cbe01
 
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
# Read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
# you will also find guides on how best to write your Dockerfile

FROM python:3.9

WORKDIR /app

# Install system dependencies
RUN apt-get update && apt-get install -y \
    wget \
    unzip \
    gnupg2 \
    libgl1-mesa-glx \
    libglib2.0-0 \
    && rm -rf /var/lib/apt/lists/*

# Install Chrome
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
    && echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list \
    && apt-get update \
    && apt-get install -y google-chrome-stable \
    && rm -rf /var/lib/apt/lists/*

# Install specific ChromeDriver version for Chrome 131
RUN wget -q "https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/131.0.6778.88/linux64/chromedriver-linux64.zip" \
    && unzip chromedriver-linux64.zip \
    && mv chromedriver-linux64/chromedriver /usr/local/bin/ \
    && chmod +x /usr/local/bin/chromedriver \
    && rm -rf chromedriver-linux64.zip chromedriver-linux64

# Create necessary directories and set permissions
RUN mkdir -p /app/static/screenshots /app/static/uploads /app/static/masks /app/templates \
    && useradd -m -u 1000 user \
    && chown -R user:user /app

USER user

# Install Python dependencies
COPY --chown=user requirements.txt requirements.txt
RUN pip install --user -r requirements.txt

# Copy application files
COPY --chown=user . .

# Set environment variables
ENV PATH="/home/user/.local/bin:${PATH}"
ENV PYTHONPATH="/home/user/.local/lib/python3.9/site-packages:${PYTHONPATH}"
ENV CHROME_BINARY_LOCATION="/usr/bin/google-chrome"
ENV PORT=7860

# Run the application
CMD ["python", "main.py"]