File size: 825 Bytes
66f849f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
FROM python:3.13-slim

# install system requirements for OpenCV to work
RUN apt-get update && apt-get install -y \
    libgl1 \
    libglib2.0-0 && rm -rf /var/lib/apt/lists/*


# setup non-root user that HF spaces require
RUN useradd -m -u 1000 appuser

USER appuser

ENV HOME=/home/appuser \
    PATH=/home/appuser/.local/bin:$PATH

WORKDIR $HOME/app

# copy requirements and assign ownership
COPY --chown=appuser requirements.txt .


# install dependency 
RUN pip install --no-cache-dir -r requirements.txt
RUN pip install --no-cache-dir fastapi uvicorn python-multipart

# copy application code
COPY --chown=appuser . $HOME/app

# port 7860 to the outside HF Hub bridge
EXPOSE 7860

# Launch uvicorn on all internal adaptors (0.0.0.0) so HF can connect!
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]