# syntax=docker/dockerfile:1-labs

FROM registry.gitlab.com/spinnaker2/s2-sim2lab-app:dev

RUN python3 -m pip install --upgrade pip \
    && python3 -m pip install \
        numpy \
        scipy \
        pytest \
        pytest-cov \
        pytest-mock \
        setuptools==73.0.1 \
        ruff==0.12.0 \
        tensorflow
RUN python -m pip install \
        torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu


# - - - - - - - - - - - -  build project - - - - - - - - - - - #
WORKDIR ${WORK_DIR}/py-spinnaker2
# the folders currently contain invalid symlinks at copy time, i.e. the files they point to are created during build time. COPY cannot be used here: bind the context and plain copy!
# COPY --parents src tests examples pyproject.toml .git ./
RUN --mount=type=bind,target=/context cp -ra /context/src /context/tests /context/examples /context/pyproject.toml /context/setup.py /context/.git ${WORK_DIR}/py-spinnaker2

RUN --mount=type=secret,id=GIT_TOKEN git config --global --replace-all url.https://gitlab-ci-token:$(cat /run/secrets/GIT_TOKEN)@gitlab.com/.insteadOf git@gitlab.com: \
    && git config --global --add url.https://gitlab-ci-token:$(cat /run/secrets/GIT_TOKEN)@gitlab.com/.insteadOf ssh://git@gitlab.com/ \
    && git config --global --add url.https://gitlab-ci-token:$(cat /run/secrets/GIT_TOKEN)@gitlab.com/.insteadOf https://gitlab.com/ \
    && git submodule sync --recursive \
    && git submodule update --init --recursive

RUN pwd && ls -lha && pip install -e .[dev]