FROM ubuntu:24.04

# DEBIAN_FRONTEND=noninteractive is used to prevent installation of
# package tzdata to ask for timezone
ENV DEBIAN_FRONTEND=noninteractive

# Required for Gudhi compilation
RUN apt update && apt install -y make \
    g++ \
    cmake \
    perl \
    libboost-all-dev \
    libeigen3-dev \
    libgmp3-dev \
    libmpfr-dev \
    libtbb-dev \
    libcgal-dev \
    python3 \
    python3-venv \
    xz-utils \
    curl

ADD install_cgal.sh /
RUN sh install_cgal.sh

# PEP668: work in a virtual environment
ENV VIRTUAL_ENV=/opt/venv
RUN python3 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

RUN python -m pip install \
    setuptools \
    Cython \
    pybind11 \
    numpy \
    matplotlib \
    scipy \
    POT \
    scikit-learn

# apt clean up
RUN apt-get autoremove && rm -rf /var/lib/apt/lists/*

ARG GUDHI_VERSION="3.11.0"

RUN curl -LO "https://github.com/GUDHI/gudhi-devel/releases/download/tags%2Fgudhi-release-${GUDHI_VERSION}/gudhi.${GUDHI_VERSION}.tar.gz" \
&& tar xf gudhi.${GUDHI_VERSION}.tar.gz \
&& cd gudhi.${GUDHI_VERSION} \
&& mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=Release -DWITH_GUDHI_PYTHON=OFF ..  \
&& make all test install \
&& cmake -DWITH_GUDHI_PYTHON=ON . \
&& cd python \
&& python setup.py install