Spaces:
Runtime error
Runtime error
# Use a minimal base Python image | |
FROM python:3.10-slim | |
# Install OS dependencies required for PyAV and basic media processing | |
RUN apt-get update && apt-get install -y \ | |
ffmpeg \ | |
libgl1 \ | |
&& rm -rf /var/lib/apt/lists/* \ | |
&& apt-get clean | |
# Create non-root user (but don't switch yet) | |
RUN useradd -m -u 1000 user | |
# Set up environment | |
ENV PATH="/home/user/.local/bin:$PATH" | |
WORKDIR /app | |
# Copy only requirements first to leverage Docker cache | |
COPY requirements.txt . | |
# Install Python dependencies | |
RUN pip install --no-cache-dir --upgrade pip setuptools wheel \ | |
&& pip install --no-cache-dir -r requirements.txt | |
# (Optional) Pre-cache model to avoid downloading at runtime on Spaces | |
# RUN python -c "from huggingface_hub import snapshot_download; snapshot_download('llava-hf/LLaVA-NeXT-Video-7B-hf')" | |
# Copy app code | |
COPY main.py . | |
COPY my_lib ./my_lib | |
# Switch to non-root user for runtime | |
USER user | |
# Expose port required by Hugging Face Spaces | |
EXPOSE 7860 | |
# Run FastAPI app with Uvicorn | |
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"] | |