File size: 1,196 Bytes
51aa33d 0063ddd 51aa33d 0063ddd 51aa33d 0063ddd 51aa33d 0063ddd 51aa33d 0063ddd 6e0af0a 0063ddd 51aa33d 6e0af0a 0063ddd 51aa33d 6e0af0a 0063ddd 51aa33d 6e0af0a 0063ddd 6e0af0a 0063ddd 51aa33d |
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 |
# Use a slim Python base image
FROM python:3.9-slim
# Install system dependencies for audio and model support
RUN apt-get update && \
apt-get install -y --no-install-recommends \
build-essential \
gcc \
git \
ffmpeg \
libsndfile1 \
libgomp1 \
curl && \
rm -rf /var/lib/apt/lists/*
# Environment variables for better performance & Hugging Face cache
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
HF_HOME=/tmp/huggingface \
TRANSFORMERS_CACHE=/tmp/huggingface/transformers \
HF_HUB_CACHE=/tmp/huggingface/hub \
HF_DATASETS_CACHE=/tmp/huggingface/datasets \
XDG_CACHE_HOME=/tmp/huggingface
WORKDIR /app
# Copy and install dependencies
COPY requirements.txt /app/requirements.txt
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r /app/requirements.txt
# Create non-root user
RUN useradd -m -u 1000 user
USER user
ENV PATH="/home/user/.local/bin:$PATH"
# Copy code
COPY --chown=user:root . /app
# Expose Hugging Face port
EXPOSE 7860
# Run the app
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1", "--timeout-keep-alive", "120"]
|