Spaces:
Sleeping
Sleeping
| FROM python:3.11-slim | |
| # Set working directory | |
| WORKDIR /app | |
| # Install system dependencies | |
| # fonts-noto-extra provides NotoSansDevanagari as fallback if Kalimati download fails | |
| RUN apt-get update && apt-get install -y \ | |
| build-essential \ | |
| curl \ | |
| git \ | |
| fontconfig \ | |
| fonts-noto-extra \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Copy requirements first for better Docker layer caching | |
| COPY requirements.txt . | |
| # Install Python dependencies | |
| RUN pip install --no-cache-dir --upgrade pip && \ | |
| pip install --no-cache-dir -r requirements.txt | |
| # Copy all app files | |
| COPY . . | |
| # Download Kalimati font β using reliable GitHub raw URL | |
| RUN mkdir -p /app/fonts && \ | |
| curl -fL "https://github.com/mhnpd/nepali-font/raw/master/fonts/Kalimati.ttf" \ | |
| -o /app/fonts/Kalimati.ttf && \ | |
| echo "β Kalimati downloaded: $(wc -c < /app/fonts/Kalimati.ttf) bytes" || \ | |
| echo "β οΈ Kalimati download failed β NotoSansDevanagari will be used as fallback" | |
| # Register Kalimati font with system font cache | |
| RUN if [ -f /app/fonts/Kalimati.ttf ]; then \ | |
| mkdir -p /usr/local/share/fonts/nepali && \ | |
| cp /app/fonts/Kalimati.ttf /usr/local/share/fonts/nepali/ && \ | |
| fc-cache -fv && \ | |
| echo "β Kalimati font registered with system"; \ | |
| else \ | |
| echo "β οΈ Skipping font registration β file not found"; \ | |
| fi | |
| # Set environment variables | |
| ENV PYTHONPATH=/app:/app/src | |
| ENV HF_HOME=/tmp/huggingface | |
| ENV TRANSFORMERS_CACHE=/tmp/huggingface | |
| ENV STREAMLIT_BROWSER_GATHER_USAGE_STATS=false | |
| ENV STREAMLIT_SERVER_PORT=7860 | |
| ENV STREAMLIT_SERVER_ADDRESS=0.0.0.0 | |
| ENV STREAMLIT_SERVER_HEADLESS=true | |
| ENV MPLCONFIGDIR=/tmp/matplotlib | |
| # Create necessary temp directories | |
| RUN mkdir -p /tmp/huggingface /tmp/matplotlib | |
| # Expose the port HF Spaces expects | |
| EXPOSE 7860 | |
| # Run the Streamlit app from src/ folder | |
| CMD ["streamlit", "run", "src/streamlit_app.py", \ | |
| "--server.port=7860", \ | |
| "--server.address=0.0.0.0", \ | |
| "--server.headless=true", \ | |
| "--browser.gatherUsageStats=false"] |