# Use official slim Python image FROM python:3.10-slim # Set working directory WORKDIR /app # Install system dependencies needed for Surprise and compiling RUN apt-get update && apt-get install -y \ build-essential \ curl \ git \ && rm -rf /var/lib/apt/lists/* # Upgrade pip RUN pip install --upgrade pip # Install specific versions of numpy and cython first to avoid Surprise issues RUN pip install numpy==1.25.0 cython==0.30.36 # Copy requirements and install COPY requirements.txt ./ RUN pip install -r requirements.txt # Copy source code COPY src/ ./src/ # Optional: copy data folder if it exists COPY data/ ./data/ 2>/dev/null || echo "No data folder found, skipping." # Optional: copy model folder if it exists COPY model/ ./model/ 2>/dev/null || echo "No model folder found, skipping." # Expose Streamlit port EXPOSE 8501 # Healthcheck for Streamlit HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health || exit 1 # Ensure Surprise data folder has correct permissions RUN mkdir -p /app/surprise_data && chmod 777 /app/surprise_data ENV SURPRISE_DATA_FOLDER=/app/surprise_data # Entry point for Streamlit ENTRYPOINT ["streamlit", "run", "src/app.py", "--server.port=8501", "--server.address=0.0.0.0"]