FROM nvidia/cuda:12.8.1-cudnn-devel-ubuntu22.04@sha256:ad6d59a3bbf3e82c1c849c9ac09cfc2a3e0bbb8655042fd899be6681b3fe2a85

SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ENV DEBIAN_FRONTEND=noninteractive \
    PYTHONDONTWRITEBYTECODE=1 \
    PYTHONUNBUFFERED=1 \
    PATH=/opt/conda/bin:$PATH

ARG MINICONDA_INSTALLER=Miniconda3-py39_24.11.1-0-Linux-x86_64.sh
ARG MINICONDA_SHA256=3ea8373098d72140e08aac9217822b047ec094eb457e7f73945af7c6f68bf6f5

RUN apt-get update \
    && apt-get install --yes --no-install-recommends \
        build-essential \
        ca-certificates \
        curl \
        git \
        libglib2.0-0 \
        libgl1 \
    && curl --fail --location --retry 5 \
        --output /tmp/miniconda.sh \
        "https://repo.anaconda.com/miniconda/${MINICONDA_INSTALLER}" \
    && echo "${MINICONDA_SHA256}  /tmp/miniconda.sh" | sha256sum --check --strict \
    && bash /tmp/miniconda.sh -b -p /opt/conda \
    && rm -f /tmp/miniconda.sh \
    && rm -rf /var/lib/apt/lists/*

RUN conda create --yes --name goose python=3.9 pip \
    && conda install --yes --name goose --channel pytorch --channel nvidia \
        pytorch=1.13.1 torchvision=0.14.1 pytorch-cuda=11.7

RUN conda run --name goose python -m pip install --no-cache-dir \
        cmake==3.31.6 \
        numpy==1.23.0 \
        onnxsim==0.4.36 \
        opencv-python==4.8.1.78 \
        protobuf==3.20.3 \
        pyparsing==2.4.5

RUN conda run --name goose python -m pip install --no-cache-dir \
        super-gradients==3.2.0 \
        torchmetrics==0.8.0

RUN conda clean --all --yes

WORKDIR /opt/mission-core/lab-v1
COPY run_goose_vegetation_benchmark.py /opt/mission-core/lab-v1/runner.py

ENTRYPOINT ["conda", "run", "--no-capture-output", "--name", "goose", "python", "/opt/mission-core/lab-v1/runner.py"]
