FROM python:3.9-slim WORKDIR /app # Install system dependencies RUN apt-get update && apt-get install -y \ build-essential \ ffmpeg \ libsm6 \ libxext6 \ && rm -rf /var/lib/apt/lists/* # Copy requirements first for better caching COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy app code COPY . . # Create necessary directories RUN mkdir -p static templates models # Create static/index.html if it doesn't exist RUN if [ ! -f static/index.html ]; then \ mkdir -p static && \ echo '
Please use the Gradio interface at /gradio or access the API directly.
' > static/index.html; \ fi # Set environment variables ENV PYTHONUNBUFFERED=1 ENV PORT=7860 ENV HOST=0.0.0.0 ENV MPLCONFIGDIR=/tmp/matplotlib # Expose the port EXPOSE 7860 # Run the application CMD ["python", "app.py"]