# IONe Dockerfile that contains the Python dependencies for interoperability tests

FROM buildpack-deps:bullseye

RUN apt-get update && \
    apt-get dist-upgrade -y && \
    apt-get install python3-venv python3-pip -y && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*

ARG ION_FILE=ione-1.0.1.tar.gz

RUN mkdir /ion_build && cd /ion_build && \
    wget -O "$ION_FILE" "https://sourceforge.net/projects/ione/files/$ION_FILE/download?use_mirror=netcologne&ts=$(date +%s)" && \
    tar -xvf "$ION_FILE" && \
    rm "$ION_FILE"

RUN cd /ion_build/ione-code* && \
    aclocal && \
    CPPFLAGS=-Wno-maybe-uninitialized ./configure && \
    make -j4 && \
    make install && \
    ldconfig && \
    cd / && \
    rm -r /ion_build

COPY ./pyd3tn/requirements.txt /req-pyd3tn.txt
COPY ./python-ud3tn-utils/requirements.txt /req-utils.txt
COPY ./test/integration/requirements.txt /req-test.txt
COPY ./tools/analysis/requirements.txt /req-analysis.txt

RUN python3 -m venv /ud3tn_venv && \
    /ud3tn_venv/bin/python -m pip install --no-cache-dir -U setuptools pip wheel && \
    /ud3tn_venv/bin/python -m pip install --no-cache-dir -U -r /req-pyd3tn.txt && \
    /ud3tn_venv/bin/python -m pip install --no-cache-dir -U -r /req-utils.txt && \
    /ud3tn_venv/bin/python -m pip install --no-cache-dir -U -r /req-test.txt && \
    /ud3tn_venv/bin/python -m pip install --no-cache-dir -U -r /req-analysis.txt
