FROM python:3.9-slim WORKDIR /app # Set environment variables ENV HOME=/tmp ENV STREAMLIT_SERVER_HEADLESS=true ENV STREAMLIT_BROWSER_GATHER_USAGE_STATS=false ENV HUGGINGFACE_HUB_CACHE=/tmp/huggingface_cache ENV TRANSFORMERS_CACHE=/tmp/huggingface_cache RUN apt-get update && apt-get install -y \ build-essential \ curl \ software-properties-common \ git \ && rm -rf /var/lib/apt/lists/* # Create cache directory RUN mkdir -p /tmp/huggingface_cache && chmod 777 /tmp/huggingface_cache COPY requirements.txt ./ RUN pip3 install -r requirements.txt # Pre-download the model during build time RUN python -c "from sentence_transformers import SentenceTransformer; model = SentenceTransformer('BAAI/bge-small-en'); print('Model downloaded successfully')" COPY src/ ./src/ # Create .streamlit directory and config file RUN mkdir -p /tmp/.streamlit RUN echo '[server]\nheadless = true\nport = 8501\nenableCORS = false\nenableXsrfProtection = false\n\n[browser]\ngatherUsageStats = false' > /tmp/.streamlit/config.toml EXPOSE 8501 HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]