Spaces:
Sleeping
Sleeping
| FROM python:3.9-slim | |
| # 1. Install system dependencies | |
| RUN apt-get update && apt-get install -y \ | |
| espeak-ng \ | |
| libsndfile1 \ | |
| git | |
| # 2. Configure environment | |
| ENV HF_HOME=/app/cache \ | |
| XDG_CACHE_HOME=/app/cache \ | |
| PYTHONPATH="${PYTHONPATH}:/app" | |
| # 3. Create directories and set global permissions | |
| RUN mkdir -p /app/cache/hub/models--hexgrad--Kokoro-82M && \ | |
| mkdir -p /app/cache/hub/.locks/models--hexgrad--Kokoro-82M && \ | |
| mkdir -p /.local && \ | |
| chmod -R 777 /app && \ | |
| chmod -R 777 /.local && \ | |
| chmod -R 777 /usr/local/lib/python3.9/site-packages | |
| WORKDIR /app | |
| # 4. Install Python dependencies | |
| COPY requirements.txt . | |
| # First install setup tools | |
| RUN pip install --upgrade pip setuptools wheel | |
| # Then install other requirements | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Install spaCy model | |
| RUN python -m spacy download en_core_web_sm | |
| # Pre-download the model with explicit permissions | |
| RUN python -c "from huggingface_hub import hf_hub_download; hf_hub_download('hexgrad/Kokoro-82M', 'config.json')" || true && \ | |
| chmod -R 777 /app/cache | |
| # 5. Copy application code | |
| COPY . . | |
| # 6. Run FastAPI | |
| CMD uvicorn app:app --host 0.0.0.0 --port 7860 |