FROM carlasim/carla:0.9.13

# CMD ['/bin/sh','-c','/bin/bash']

# 添加环境变量
# export XDG_RUNTIME_DIR=/usr/lib/
# export RUNLEVEL=3

ENV XDG_RUNTIME_DIR=/usr/lib/
ENV RUNLEVEL=3
USER root
RUN rm /etc/apt/sources.list.d/cuda.list

RUN rm /etc/apt/sources.list.d/nvidia-ml.list

RUN apt-key del 7fa2af80


RUN sed -i 's/archive.ubuntu.com/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list

RUN apt-get update && apt-get install -y --no-install-recommends wget

RUN wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-keyring_1.0-1_all.deb

RUN dpkg -i cuda-keyring_1.0-1_all.deb

# 设置清华源

RUN apt-get update

RUN apt-get install xdg-user-dirs

RUN apt-get install nano sudo curl -y

RUN apt-get install libglu1-mesa-dev freeglut3-dev mesa-common-dev mesa-utils -y

RUN apt-get install libxtst6 libxv1 libegl1-mesa -y

RUN wget https://sourceforge.net/projects/virtualgl/files/3.0.1/virtualgl_3.0.1_amd64.deb

RUN dpkg -i virtualgl_3.0.1_amd64.deb

RUN apt-get update 

RUN apt-get -f install

# 安装conda
# yhyu13 : install additional packages
# 设置apt的源为tsinghua镜像源
RUN sed -i 's/archive.ubuntu.com/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list

RUN apt-get update && apt-get install -y curl wget

# 安装conda
RUN curl -O https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh \
    && bash Miniconda3-latest-Linux-x86_64.sh -b -p /opt/conda \
    && rm Miniconda3-latest-Linux-x86_64.sh

RUN /opt/conda/bin/conda update -n base -c defaults conda

RUN /opt/conda/bin/conda create -n py38 python=3.8.5 -y
ENV PATH /opt/conda/envs/py38/bin:$PATH

COPY requirements.txt requirements.txt

RUN pip install -r requirements.txt


# RUN wget http://download.nvidia.com/XFree86/Linux-x86_64/450.57/NVIDIA-Linux-x86_64-450.57.run

# RUN sudo /bin/bash NVIDIA-Linux-x86_64-450.57.run --accept-license --no-questions --ui=none

# RUN sudo apt-get install -y xserver-xorg mesa-utils libvulkan1

# RUN sudo nvidia-xconfig --preserve-busid -a --virtual=1280x1024

# RUN ENV SDL_VIDEODRIVER=x11

# RUN sudo X :0 &

RUN apt install vulkan-utils

USER carla

# WORKDIR /home/vangogh/software/FuzzScene

# COPY code/env/carla.yml  /home/vangogh/software/FuzzScene/code/env/carla.yml

# COPY code/env/dave.yml  /home/vangogh/software/FuzzScene/code/env/dave.yml

# RUN /opt/conda/bin/conda env create -f code/env/carla.yml 
# /opt/conda/bin/conda env create -f code/env/dave.yml


COPY . .
# CMD ["/home/carla/CarlaUE4.sh -opengl"]
# CMD ["./CarlaUE4.sh","-opengl"]