FROM python:3.9-slim WORKDIR /app # Install system tools RUN apt-get update && apt-get install -y --no-install-recommends \ gcc python3-dev curl && \ rm -rf /var/lib/apt/lists/* # Create folders for models and configs RUN mkdir -p /app/models /app/huggingface /tmp/.streamlit && \ chmod 777 /app/models /app/huggingface /tmp/.streamlit # Set environment variables ENV TRANSFORMERS_CACHE=/app/models ENV HF_HOME=/app/huggingface ENV STREAMLIT_CONFIG_DIR=/tmp/.streamlit # Streamlit config (fix for Hugging Face 403 upload error) RUN echo "[server]\n\ enableCORS = false\n\ enableXsrfProtection = false\n\ fileWatcherType = 'none'\n\ [browser]\n\ gatherUsageStats = false\n" > /tmp/.streamlit/config.toml # Install Python dependencies COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy application code COPY app.py . # Health check and expose port EXPOSE 8501 HEALTHCHECK --interval=30s --timeout=5s CMD curl -f http://localhost:8501/_stcore/health # Run the app CMD ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0"]