stt-model / Dockerfile
AbdoIR's picture
Update Dockerfile
0063ddd verified
# 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"]