FROM python:3.10-slim # Install system dependencies RUN apt-get update && apt-get install -y \ build-essential \ curl \ git \ gcc \ g++ \ && rm -rf /var/lib/apt/lists/* # Set working directory WORKDIR /app # Copy requirements first for better caching COPY requirements.txt . # Install Python dependencies RUN pip install --no-cache-dir -r requirements.txt # Copy application code COPY . . # Create models directory for persistent storage RUN mkdir -p /data/models # Set environment variables ENV MODEL_CACHE_DIR=/data/models ENV HOST=0.0.0.0 ENV PORT=8501 ENV STREAMLIT_SERVER_PORT=8501 ENV STREAMLIT_SERVER_HEADLESS=true ENV STREAMLIT_BROWSER_GATHER_USAGE_STATS=false # Expose port EXPOSE 8501 # Health check HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \ CMD curl --fail http://localhost:8501/_stcore/health # Download a small model during build (TinyLlama is lightweight) RUN python scripts/download_models.py --model tiny-llama --cache-dir /data/models # Command to run the Streamlit app CMD ["streamlit", "run", "src/streamlit_app.py"]