Spaces:
Configuration error
Configuration error
File size: 1,796 Bytes
49525ce | 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 46 47 48 49 50 51 | # ==============================================================================
# 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"]
|