# Use slim Python base image FROM python:3.10-slim # Set working directory WORKDIR /app # Install dependencies (ffmpeg, fonts, build tools, etc.) RUN apt-get update && apt-get install -y \ ffmpeg \ libsndfile1 \ build-essential \ g++ \ fonts-ebgaramond \ fonts-dejavu \ && rm -rf /var/lib/apt/lists/* # Copy requirements first (for caching) COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy project files COPY api_server /app/api_server COPY utils /app/utils COPY video /app/video COPY server.py /app/server.py # Create writable directories RUN mkdir -p /data/media /data/matplotlib /data/hf_cache /data/hf_home /data/numba_cache /data/nltk_data \ && chmod -R 777 /data # Environment settings ENV STORAGE_PATH=/data/media ENV MPLCONFIGDIR=/data/matplotlib ENV HF_HOME=/data/hf_home ENV TRANSFORMERS_CACHE=/data/hf_cache ENV NUMBA_CACHE_DIR=/data/numba_cache ENV NLTK_DATA=/data/nltk_data # Expose HF Space default port EXPOSE 7860 # Start FastAPI with uvicorn (HF expects web server on 0.0.0.0:7860) CMD ["uvicorn", "server:app", "--host", "0.0.0.0", "--port", "7860"]