File size: 861 Bytes
9a22bb5 | 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 | FROM python:3.11-slim
# Install system dependencies
RUN apt-get update && apt-get install -y \
libgl1 \
libglib2.0-0 \
libsm6 \
libxext6 \
libxrender1 \
libgomp1 \
&& rm -rf /var/lib/apt/lists/*
# Set up a non-root user for HF Spaces
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH
WORKDIR $HOME/app
# Install Python deps
COPY --chown=user requirements.txt .
# Debug: show what's in requirements.txt
RUN cat requirements.txt
RUN pip install --no-cache-dir --user -r requirements.txt
# Copy app code
COPY --chown=user . .
# Download model files at build time
RUN python download_models.py
# Ensure static directories exist and are writable
RUN mkdir -p static/uploads static/results models
EXPOSE 7860
CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--timeout", "120", "app:app"]
|