FROM python:3.9-slim WORKDIR /code # Install system dependencies RUN apt-get update && apt-get install -y \ build-essential \ python3-dev \ libsndfile1 \ ffmpeg \ espeak-ng \ git \ && rm -rf /var/lib/apt/lists/* # Set environment variables ENV PYTHONUNBUFFERED=1 ENV NUMBA_CACHE_DIR=/tmp/numba_cache ENV XDG_CACHE_HOME=/tmp/cache ENV HOME=/tmp/home ENV MPLCONFIGDIR=/tmp/matplotlib ENV TTS_HOME=/tmp/tts_home ENV COQUI_TOS_AGREED=1 # Create necessary directories with appropriate permissions RUN mkdir -p /tmp/cache \ /tmp/numba_cache \ /tmp/home/.local/share/tts \ /tmp/matplotlib \ /tmp/tts_home \ /code/tts_cache && \ chmod -R 777 /tmp/cache \ /tmp/numba_cache \ /tmp/home \ /tmp/matplotlib \ /tmp/tts_home \ /code/tts_cache # Copy requirements first COPY ./requirements.txt /code/requirements.txt # Install dependencies in specific order RUN pip install --no-cache-dir --upgrade pip && \ pip install --no-cache-dir numpy==1.22.0 && \ pip install --no-cache-dir torch==2.5.1 torchaudio==2.5.1 && \ pip install --no-cache-dir numba==0.60.0 && \ pip install --no-cache-dir librosa==0.10.0 && \ pip install --no-cache-dir -r /code/requirements.txt # Copy the rest of the application COPY . /code/ # Set proper permissions RUN chmod -R 777 /code # Expose the port EXPOSE 7860 # Command to run the application CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]