Spaces:
Sleeping
Sleeping
File size: 2,035 Bytes
5a1a25f bc3dd6d 5a1a25f bc3dd6d 5a1a25f 3fa3ef8 bc3dd6d 5a1a25f 3fa3ef8 bc3dd6d 5a1a25f bc3dd6d 5a1a25f bc3dd6d dc7581c 5a1a25f bc3dd6d a48f7a5 dc7581c a48f7a5 dc7581c 3fa3ef8 5a1a25f a48f7a5 5a1a25f bc3dd6d 5a1a25f 9db27c2 5a1a25f 9db27c2 5a1a25f | 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 52 53 54 55 56 57 58 59 60 61 62 63 64 | 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"] |