# FROM MAIN DIR: docker build -t conlu/mujoco200mb -f docker/Dockerfile .
# Need to replace UID

FROM nvidia/cuda:10.1-base

RUN apt-get update && apt-get install -y \
    vim wget unzip \
    libosmesa6-dev libgl1-mesa-glx libgl1-mesa-dev patchelf libglfw3 build-essential

# Misc Ubuntu Packages
RUN apt-get update && apt-get install -y --allow-unauthenticated --no-install-recommends \
         vim build-essential cmake git wget curl ca-certificates \
         libjpeg-dev libpng-dev libgl1-mesa-glx zlib1g-dev \
         libopenmpi-dev python3-dev zlib1g-dev \
         libsm6 libxrender1 libfontconfig1

# Even More Misc Ubuntu Packages
RUN apt-get -y install libgtk2.0-0
RUN apt-get update --fix-missing && apt-get -y install \
    xvfb \
    xorg-dev \
    libsdl2-dev \
    swig

RUN useradd -u 13681 --create-home user
USER user
WORKDIR /home/user

RUN wget -q https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh && \
    bash Miniconda3-latest-Linux-x86_64.sh -b -p miniconda3 && \
    rm Miniconda3-latest-Linux-x86_64.sh

ENV PATH /home/user/miniconda3/bin:$PATH

# MuJoCo
ENV MUJOCO_PY_MJKEY_PATH /home/user/.mujoco/mjkey.txt
ENV MUJOCO_PY_MUJOCO_PATH /home/user/.mujoco/mujoco200
RUN mkdir -p .mujoco \
    && wget https://www.roboti.us/download/mujoco200_linux.zip -O mujoco.zip \
    && unzip mujoco.zip -d .mujoco \
    && rm mujoco.zip
COPY mjkey.txt .mujoco/mjkey.txt
RUN mv .mujoco/mujoco200_linux .mujoco/mujoco200
ENV LD_LIBRARY_PATH /home/user/.mujoco/mujoco200/bin:${LD_LIBRARY_PATH}
RUN pip install mujoco-py

# Python packages
RUN pip install torch torchvision

RUN pip install atari-py
RUN pip install box2d-py==2.3.8
RUN pip install cffi==1.13.2
RUN pip install cloudpickle==1.2.2
RUN pip install Cython==0.29.14
RUN pip install fasteners==0.15
RUN pip install future==0.18.2
RUN pip install glfw==1.8.5
RUN pip install gym==0.15.4
RUN pip install imageio==2.6.1
RUN pip install lockfile==0.12.2
RUN pip install monotonic==1.5
RUN pip install numpy==1.20.2
RUN pip install opencv-python==4.1.2.30
RUN pip install pandas==0.25.3
RUN pip install Pillow==6.2.1
RUN pip install pycparser==2.19
RUN pip install pyglet==1.3.2
RUN pip install python-dateutil==2.8.1
RUN pip install pytz==2019.3
RUN pip install PyYAML==5.1.2
RUN pip install scipy==1.3.3
RUN pip install six==1.13.0

RUN python -c "import mujoco_py"

# Switcheroni here because DM control is like that
ENV MUJOCO_PY_MUJOCO_PATH /home/user/.mujoco/mujoco200_linux
RUN mv .mujoco/mujoco200 .mujoco/mujoco200_linux
ENV LD_LIBRARY_PATH /home/user/.mujoco/mujoco200_linux/bin:${LD_LIBRARY_PATH}

RUN pip install git+https://github.com/rail-berkeley/d4rl@master#egg=d4rl
RUN pip install tensorflow
RUN pip install --upgrade git+https://github.com/y0ast/DUE.git
RUN pip install gpytorch
RUN pip install numpy==1.20.2

# ADD . /home/user/
WORKDIR /Meta-Offline-RL
