FROM python:3.9-slim # Set environment variables ENV PYTHONUNBUFFERED=1 \ PYTHONDONTWRITEBYTECODE=1 \ MPLCONFIGDIR=/tmp/matplotlib WORKDIR /app # Install system dependencies RUN apt-get update && \ apt-get install -y --no-install-recommends \ build-essential \ curl \ git \ ffmpeg \ libsndfile1 \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* # Create necessary directories RUN mkdir -p /app/tmp_model /tmp/matplotlib # Copy requirements first (for better caching) COPY requirements.txt . # Install Python dependencies with specific order for compatibility RUN pip install --no-cache-dir --upgrade pip && \ pip install --no-cache-dir torch==2.0.1 torchaudio==2.0.2 && \ pip install --no-cache-dir -r requirements.txt && \ pip install --no-cache-dir git+https://github.com/speechbrain/speechbrain.git@v0.5.14 # Copy source code COPY src/ ./src/ # Set up Streamlit configuration RUN mkdir -p .streamlit RUN echo "[server]" > ./.streamlit/config.toml && \ echo "port = 8501" >> ./.streamlit/config.toml && \ echo "address = \"0.0.0.0\"" >> ./.streamlit/config.toml && \ echo "headless = true" >> ./.streamlit/config.toml && \ echo "" >> ./.streamlit/config.toml && \ echo "[browser]" >> ./.streamlit/config.toml && \ echo "gatherUsageStats = false" >> ./.streamlit/config.toml && \ echo "" >> ./.streamlit/config.toml && \ echo "[runner]" >> ./.streamlit/config.toml && \ echo "fastReruns = true" >> ./.streamlit/config.toml # Expose port EXPOSE 8501 # Health check HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health # Run the app ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]