File size: 994 Bytes
bc9f3e6 | 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 | FROM python:3.11-slim
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
curl \
git \
ffmpeg \
libsm6 \
libxext6 \
poppler-utils \
&& rm -rf /var/lib/apt/lists/*
# Create user for Hugging Face Spaces (UID 1000)
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH \
PYTHONUNBUFFERED=1 \
MPLBACKEND=Agg \
HF_HUB_DISABLE_TELEMETRY=1 \
DO_NOT_TRACK=1
WORKDIR $HOME/app
# Install Python requirements
COPY --chown=user:user requirements.txt $HOME/app/requirements.txt
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
# Copy application source code
COPY --chown=user:user . $HOME/app
# Ensure user_data directory is writable
RUN mkdir -p $HOME/app/user_data && chmod -R 777 $HOME/app/user_data
EXPOSE 7860
CMD ["uvicorn", "backend.web_api:app", "--host", "0.0.0.0", "--port", "7860"]
|