Spaces:
Sleeping
Sleeping
| # --- Use Python 3.10 as the base image for modern syntax compatibility --- | |
| FROM python:3.10-slim | |
| # Set the working directory inside the container | |
| WORKDIR /code | |
| # Set environment variables for cache directories | |
| ENV MPLCONFIGDIR=/tmp/matplotlib | |
| ENV HF_HOME=/tmp/huggingface | |
| ENV NUMBA_CACHE_DIR=/tmp/numba_cache | |
| ENV PYTHONUNBUFFERED=1 | |
| ENV FONTCONFIG_PATH=/tmp/fonts | |
| ENV FONTCONFIG_CACHE=/tmp/fonts-cache | |
| ENV LHOTSE_CACHE=/tmp/.lhotse | |
| ENV XDG_CACHE_HOME=/tmp | |
| ENV HOME=/tmp | |
| ENV LHOTSE_TOOLS=/tmp/.lhotse | |
| # --- Install system dependencies --- | |
| RUN apt-get update && \ | |
| apt-get install -y --no-install-recommends \ | |
| libsndfile1 \ | |
| ffmpeg \ | |
| build-essential \ | |
| git \ | |
| fontconfig \ | |
| && apt-get clean \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Copy the requirements file | |
| COPY ./requirements.txt /code/requirements.txt | |
| # --- Install Python dependencies --- | |
| # Upgrade pip first | |
| RUN pip install --no-cache-dir --upgrade pip setuptools wheel | |
| # Install PyTorch with its specific index-url FIRST | |
| RUN pip install --no-cache-dir \ | |
| torch==2.0.1 \ | |
| torchaudio==2.0.2 \ | |
| --index-url https://download.pytorch.org/whl/cpu | |
| # Install all other requirements from the file in a single step | |
| # Use --use-deprecated=legacy-resolver if dependency conflicts are complex | |
| RUN pip install --no-cache-dir -r /code/requirements.txt | |
| # Verify the installed versions (optional but good practice) | |
| RUN python -c "import torch; print(f'PyTorch: {torch.__version__}')" | |
| RUN python -c "import pytorch_lightning as pl; print(f'PyTorch Lightning: {pl.__version__}')" | |
| RUN python -c "import nemo; print(f'NeMo: {nemo.__version__}')" | |
| # Create cache directories with proper permissions | |
| RUN mkdir -p /tmp/matplotlib /tmp/huggingface /tmp/numba_cache /tmp/.lhotse /tmp/fonts /tmp/fonts-cache && \ | |
| chmod -R 777 /tmp | |
| # Fix fontconfig cache directory | |
| RUN fc-cache -fv | |
| # Copy the rest of your application code | |
| COPY . /code/ | |
| # Expose port | |
| EXPOSE 7860 | |
| # Run the application | |
| CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] |