# Use Python 3.9 slim as the base image FROM python:3.9-slim # Set working directory WORKDIR /app # Install system dependencies RUN apt-get update && apt-get install -y \ build-essential \ curl \ software-properties-common \ git \ libgl1-mesa-glx \ libglib2.0-0 \ espeak \ && rm -rf /var/lib/apt/lists/* # Create a directory for MediaPipe models and set permissions RUN mkdir -p /app/mediapipe_models && chmod -R 777 /app/mediapipe_models # Set environment variable to redirect MediaPipe model downloads ENV MEDIAPIPE_CACHE_DIR=/app/mediapipe_models # Copy requirements and source code COPY requirements.txt ./ COPY src/ ./src/ # Install Python dependencies RUN pip3 install --no-cache-dir -r requirements.txt # Create a non-root user and set ownership RUN useradd -m appuser && chown -R appuser:appuser /app USER appuser # Expose Streamlit port EXPOSE 8501 # Healthcheck for Hugging Face Spaces HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health # Run Streamlit ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]