Spaces:
No application file
No application file
File size: 859 Bytes
9434231 8ef2cca 95c58ff 8ef2cca 28a1786 9434231 8ef2cca 95c58ff 28a1786 8ef2cca 28a1786 8ef2cca 28a1786 8ef2cca 84f84c3 8ef2cca 95c58ff 8ef2cca | 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 | FROM python:3.9-slim
# Create required user
RUN useradd -m -u 1000 user
USER user
# Set environment
ENV PATH="/home/user/.local/bin:$PATH" \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1
WORKDIR /app
# Install system dependencies (as root, then switch back)
USER root
RUN apt-get update && apt-get install -y \
ffmpeg \
libsndfile1 \
&& rm -rf /var/lib/apt/lists/*
USER user
# Copy requirements first (better caching)
COPY --chown=user requirements.txt .
RUN pip install --no-cache-dir --upgrade -r requirements.txt
# Copy application
COPY --chown=user app.py .
# Hugging Face requires port 7860
ENV PORT=7860
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD curl apt-get -f http://localhost:${PORT}/health || exit 1
# Run the application
CMD uvicorn app:app --host 0.0.0.0 --port ${PORT} |