FROM python:3.10-slim
ENV PYTHONUNBUFFERED=1

# dipendenze native utili a numpy/scikit (safe choice)
RUN apt-get update && apt-get install -y --no-install-recommends \
    build-essential gcc g++ \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app

COPY requirements.txt /app/requirements.txt
RUN pip install --no-cache-dir -r /app/requirements.txt

# Correzione nome pacchetto e upgrade pip
RUN pip install --no-cache-dir --upgrade pip 
RUN pip install streamlit==1.29.0 streamlit-drawable-canvas==0.9.3 PyYAML Pillow pandas
RUN pip install --no-cache-dir folium streamlit-folium
RUN pip install --no-cache-dir psutil 

COPY app/ /app/app/
COPY entrypoint.sh /app/entrypoint.sh
RUN chmod +x /app/entrypoint.sh

# utente non-root
RUN useradd -m appuser
USER appuser

# cartelle dati/modelli (volumi)
RUN mkdir -p /home/appuser/data /home/appuser/models
ENV DATA_DIR=/home/appuser/data
ENV MODELS_DIR=/home/appuser/models

ENTRYPOINT ["/app/entrypoint.sh"]
