# Dockerfile for simtools development.
#
# Based on the CORSIKA and sim_telarray image.
# All dependencies for simtools are installed,
# but not simtools itself. It is expected that
# simtools is installed in an external directory
# mounted in the container.
#
# hadolint global ignore=DL3007,DL3013,DL3041,SC1091
# - DL3007, DL3041: ignore warnings about using latest
# - DL3013: ignore warnings about installing non-specific versions with microdnf)
# - SC1091: ignore warning about not being able to source the bashrc
ARG BUILD_OPT="prod6-baseline"
ARG HADRONIC_MODEL="qgs2"
ARG SIMTEL_VERSION="240927"
ARG CORSIKA_VERSION="77550"
ARG BERNLOHR_VERSION="1.68"
FROM ghcr.io/gammasim/simtools-corsika-sim-telarray-${SIMTEL_VERSION}-corsika-${CORSIKA_VERSION}-bernlohr-${BERNLOHR_VERSION}-${BUILD_OPT}-${HADRONIC_MODEL}:latest
WORKDIR /workdir
ARG PYTHON_VERSION="3.12"

RUN microdnf update -y && microdnf install -y \
    findutils gcc-c++ git \
    python${PYTHON_VERSION}-pip python${PYTHON_VERSION}-devel wget && \
    microdnf clean all

RUN wget --quiet https://raw.githubusercontent.com/gammasim/simtools/main/pyproject.toml && \
    python${PYTHON_VERSION} -m venv env && \
    source env/bin/activate && \
    pip install --no-cache-dir -U pip && \
    pip install --no-cache-dir toml-to-requirements && \
    toml-to-req --toml-file pyproject.toml --optional-lists dev,doc,tests && \
    pip uninstall -y toml-to-requirements && \
    pip install --no-cache-dir -r requirements.txt

ENV SIMTEL_PATH="/workdir/sim_telarray/"
ENV PATH="/workdir/simtools/env/bin/:$PATH"
SHELL ["/bin/bash", "-c"]

WORKDIR /workdir/external
