Spaces:
Running
Running
File size: 1,186 Bytes
7814ee2 |
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 |
FROM python:3.8
# Set a writable cache directory for Hugging Face models
ENV HF_HOME="/tmp/huggingface_cache"
ENV MPLCONFIGDIR="/tmp/matplotlib_cache"
ENV TRANSFORMERS_CACHE="/tmp/huggingface"
ENV NUMBA_CACHE_DIR="/tmp/numba_cache"
# Create and set correct permissions for cache directories
RUN mkdir -p $HF_HOME $MPLCONFIGDIR $TRANSFORMERS_CACHE $NUMBA_CACHE_DIR \
&& chmod -R 777 $HF_HOME $MPLCONFIGDIR $TRANSFORMERS_CACHE $NUMBA_CACHE_DIR
# Install system dependencies
RUN apt-get update && apt-get install -y \
ffmpeg \
&& rm -rf /var/lib/apt/lists/*
# Set up a non-root user to avoid permission issues
RUN useradd -m appuser
USER appuser
# Set the PATH to include local bin directory
ENV PATH="/home/appuser/.local/bin:$PATH"
# Install Python dependencies
COPY --chown=appuser:appuser requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Manually install uvicorn in case it failed above
RUN pip install uvicorn
# Verify that uvicorn was installed
RUN pip show uvicorn
# Copy the API code
COPY --chown=appuser:appuser . .
# Expose the port
EXPOSE 5000
# Run the application
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "5000"]
|