Spaces:
Runtime error
Runtime error
| FROM python:3.11-slim | |
| WORKDIR /code | |
| # Create cache directory and set permissions | |
| RUN mkdir -p /cache && \ | |
| chmod 777 /cache && \ | |
| mkdir -p /.cache && \ | |
| chmod 777 /.cache | |
| # Set cache environment variables | |
| ENV TRANSFORMERS_CACHE=/cache \ | |
| HF_HOME=/cache \ | |
| XDG_CACHE_HOME=/cache \ | |
| PYTHONPATH=/code | |
| # Install system dependencies | |
| RUN apt-get update && apt-get install -y \ | |
| gcc \ | |
| g++ \ | |
| make \ | |
| git \ | |
| ffmpeg \ | |
| libsndfile1 \ | |
| portaudio19-dev \ | |
| python3-dev \ | |
| build-essential \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Copy requirements first to leverage Docker cache | |
| COPY ./requirements.txt /code/requirements.txt | |
| # Install Python packages in multiple steps to handle dependencies better | |
| RUN pip install --no-cache-dir --upgrade pip && \ | |
| pip install --no-cache-dir 'numpy==1.23.5' && \ | |
| pip install --no-cache-dir 'faiss-cpu==1.7.3' && \ | |
| pip install --no-cache-dir einops>=0.6.1 && \ | |
| pip install --no-cache-dir -r /code/requirements.txt | |
| # Copy the rest of the application | |
| COPY ./app.py /code/app.py | |
| COPY ./templates /code/templates | |
| COPY ./models /code/models | |
| # Set proper permissions for the application | |
| RUN chown -R 1000:1000 /code && \ | |
| chmod -R 755 /code | |
| EXPOSE 7860 | |
| # Create and switch to non-root user | |
| RUN useradd -m -u 1000 user | |
| USER user | |
| CMD ["python", "app.py"] |