File size: 1,089 Bytes
3506f8c
 
2d9a129
3506f8c
 
288e32e
3506f8c
 
 
 
 
 
 
 
2d9a129
288e32e
3506f8c
 
 
 
 
2d9a129
3506f8c
 
2d9a129
3506f8c
 
 
 
288e32e
3506f8c
 
 
288e32e
 
2d9a129
 
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
# Use HF Spaces optimized base (eliminates pipfreeze stage)
FROM python:3.12-slim

# Install ONLY essential system deps - no extra libs causing cache conflicts
RUN apt-get update -qq && apt-get install -y --no-install-recommends \
    ffmpeg \
    libgl1 \
    && apt-get clean && rm -rf /var/lib/apt/lists/*

# Set unbuffered Python + working dir
ENV PYTHONUNBUFFERED=1
WORKDIR /code

# Copy ONLY requirements (pin exact versions, no wildcards)
COPY requirements.txt .

# Force clean pip install WITHOUT cache mounts (HF Spaces ignores them)
RUN pip install --no-cache-dir --disable-pip-version-check \
    pip==24.2 \
    && pip install --no-cache-dir -r requirements.txt \
    && pip cache purge

# Copy app AFTER pip (isolates code changes)
COPY app.py .

# HF Spaces Gradio compatibility symlinks
RUN mkdir -p /home/user/app && \
    ln -sf /code /home/user/app && \
    ln -sf /code/app.py /home/user/app/app.py

# Non-root user (HF Spaces requirement)
RUN adduser --disabled-password --gecos '' user && \
    chown -R user:1000 /code
USER user

EXPOSE 7860
CMD ["python", "app.py"]