File size: 1,439 Bytes
40d8928
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
FROM python:3.10-slim

# System-level deps. build-essential is only needed if a pip package needs
# to compile from source — safe to keep, drop later if you want a smaller image.
RUN apt-get update && apt-get install -y --no-install-recommends \
    build-essential \
    && rm -rf /var/lib/apt/lists/*

# HF Spaces Docker containers run as a non-root user (uid 1000) by convention.
# Skipping this causes permission errors when the app tries to write to
# ~/.cache/huggingface at runtime.
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH

WORKDIR /home/user/app

# Copy + install requirements first so Docker caches this layer separately
# from your source code — code changes won't force a full pip reinstall.
COPY --chown=user requirements.txt .
RUN pip install --no-cache-dir --upgrade pip && \
    pip install --no-cache-dir -r requirements.txt

# Now copy the rest of the app (src/, README.md, etc.)
COPY --chown=user . .

# Writable HF cache location + your model source config
ENV HF_HOME=/home/user/.cache/huggingface \
    MODEL_SOURCE=hub \
    HF_USERNAME=Pro-aryan00

# HF Spaces routes external traffic to port 7860 by default for Docker SDK
EXPOSE 7860

CMD ["streamlit", "run", "src/app.py", \
     "--server.port=7860", \
     "--server.address=0.0.0.0", \
     "--server.headless=true", \
     "--server.enableCORS=false", \
     "--server.enableXsrfProtection=false"]