FROM python:3.11-slim # Use /app as working directory WORKDIR /app # Set HOME to /app so Streamlit doesn't try writing to / ENV HOME=/app # Environment variables for Streamlit and cache ENV STREAMLIT_HOME=$HOME/.streamlit ENV HF_HOME=$HOME/.cache/huggingface ENV TRANSFORMERS_CACHE=$HOME/.cache/transformers ENV TORCH_HOME=$HOME/.cache/torch ENV STREAMLIT_CONFIG_DIR=$HOME/.streamlit # Install dependencies RUN apt-get update && apt-get install -y \ build-essential \ curl \ git \ && rm -rf /var/lib/apt/lists/* # Install Python dependencies COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy your source code COPY src/ ./src/ # Create writable directories for Streamlit and Chroma RUN mkdir -p $HOME/.streamlit \ $HOME/.cache/huggingface \ $HOME/.cache/transformers \ $HOME/.cache/torch \ $HOME/src/data \ $HOME/src/chroma \ && chmod -R 777 $HOME # Streamlit port EXPOSE 8501 # Run the Streamlit app ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0", "--server.enableXsrfProtection=false"]