FROM python:3.8-slim

USER 0

# Install git (needed for Mlflow tracking)
RUN apt-get update && apt-get install -y git && apt-get install build-essential -y
COPY requirements.txt requirements.txt

RUN pip install --no-cache-dir -r requirements.txt --no-warn-script-location
# For sklearn-extra
RUN pip install Cython
RUN pip install https://github.com/scikit-learn-contrib/scikit-learn-extra/archive/refs/heads/main.zip
# This will fail if it's in requirements instead Dockerfile
RUN pip install dask-ml

# https://github.com/scikit-learn-contrib/hdbscan/issues/457#issuecomment-1006134405
RUN pip install numba==0.53.*
RUN pip install --upgrade numpy
RUN pip install hdbscan --no-cache-dir --no-binary hdbscan

ENV PYTHONUNBUFFERED=0

COPY service /app/

# Our service wants to create dirs and download artifacts to local disk
RUN chown 65534 /app/tasks/resources/

EXPOSE 12345

CMD ["/app/entrypoint.sh"]
