FROM nvidia/cuda:11.8.0-devel-ubuntu22.04

ARG UID=1000
ARG GID=1000
ARG USERNAME=container-user
RUN groupadd --gid ${GID} ${USERNAME} \
    && useradd --uid ${UID} --gid ${GID} -m ${USERNAME} \
    && apt-get update \
    && apt-get install -y sudo \
    && apt install -y python3-pip ffmpeg libsm6 libxext6 \
    && apt install git -y \
    && echo ${USERNAME} ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/${USERNAME} \
    && chmod 0440 /etc/sudoers.d/${USERNAME}

USER ${UID}
ADD --chown=${UID}:${GID} . /cope2n-ai

WORKDIR /cope2n-ai
RUN pip3 install -r requirements.txt --no-cache-dir
RUN python3 -m pip install -e detectron2
RUN cd /cope2n-ai/sdsvtd && pip install -v -e .
RUN cd /cope2n-ai/sdsvtr && pip install -v -e .
RUN pip install -U openmim && mim install mmcv-full==1.7.0
RUN cd /cope2n-ai
RUN export PYTHONPATH="."

CMD ["sh", "run.sh"]