speech-model / Dockerfile
notUbaid's picture
Upload folder using huggingface_hub
49525ce verified
Raw
History Blame Contribute Delete
1.8 kB
# ==============================================================================
# Dockerfile - Production Container for Render Deployment (Anvaya Speech AI)
# ==============================================================================
FROM python:3.11-slim-bookworm
# Set environment variables
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
DEBIAN_FRONTEND=noninteractive \
PORT=8501 \
STREAMLIT_SERVER_HEADLESS=true \
STREAMLIT_SERVER_ENABLE_CORS=false \
STREAMLIT_SERVER_ENABLE_XSRF_PROTECTION=false \
STREAMLIT_SERVER_ENABLE_WEBSOCKET_COMPRESSION=false \
STREAMLIT_SERVER_MAX_UPLOAD_SIZE=50
# Install required system audio and compilation libraries
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
libsndfile1 \
ffmpeg \
curl \
git \
&& rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /app
# Install CPU-optimized PyTorch first (reduces image size from ~4GB to ~600MB)
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir torch torchaudio --index-url https://download.pytorch.org/whl/cpu
# Copy requirements and install dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy application codebase
COPY . /app
# Pre-cache base models during build so the application starts instantly in production
RUN python ml/precache_models.py
# Expose standard port
EXPOSE 8501
# Healthcheck
HEALTHCHECK CMD curl --fail http://localhost:${PORT}/_stcore/health || exit 1
# Start Streamlit binding to Render's dynamic PORT
CMD ["sh", "-c", "streamlit run webapp.py --server.port=${PORT:-8501} --server.address=0.0.0.0 --server.headless=true --browser.gatherUsageStats=false --server.enableWebsocketCompression=false"]