Spaces:
Runtime error
Runtime error
File size: 1,341 Bytes
9928fc1 881b45d 430d641 280956d 430d641 229449b a0e118e 229449b a0e118e 229449b 9928fc1 229449b 280956d 229449b e68a0f5 060e70d e68a0f5 280956d 229449b 9928fc1 881b45d 430d641 881b45d 430d641 0a1a1bb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
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"] |