FROM python:3.9-slim # Create a non-root user RUN useradd -m appuser # Set environment variables for Hugging Face cache ENV TRANSFORMERS_CACHE=/app/cache ENV HF_HOME=/app/cache # Set working directory WORKDIR /app # Copy requirements and install them COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Create cache directory and set permissions RUN mkdir -p /app/cache && chown -R appuser /app/cache # Pre-download the model during build time RUN python3 -c "from transformers import AutoTokenizer, AutoModelForSeq2SeqLM; \ AutoTokenizer.from_pretrained('ai4bharat/IndicBART', use_fast=False); \ AutoModelForSeq2SeqLM.from_pretrained('ai4bharat/IndicBART')" # Copy all project files and set ownership COPY . . RUN chown -R appuser /app # Switch to non-root user USER appuser # Expose port for Streamlit EXPOSE 7860 # Run the Streamlit app CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"]