diff --git a/Dockerfile b/Dockerfile index 0d53cdf..822649f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,15 @@ -FROM ubuntu:18.04 +#FROM ubuntu:18.04 #FROM nvidia/opengl:1.2-glvnd-runtime-ubuntu18.04 -#FROM nvidia/vulkan:1.1.121-cuda-10.1--ubuntu18.04 - -# Make all NVIDIA GPUS visible, but I want to manually install drivers -ARG NVIDIA_VISIBLE_DEVICES=all -# Supress interactive menu while installing keyboard-configuration -ARG DEBIAN_FRONTEND=noninteractive +FROM nvidia/vulkan:1.1.121-cuda-10.1--ubuntu18.04 RUN sed -i 's#http://archive.ubuntu.com/ubuntu/#mirror://mirrors.ubuntu.com/mirrors.txt#' /etc/apt/sources.list; +ARG CARLA_VERSION_FULL=0.9.10.1 +ARG CARLA_VERSION=0.9.10 +ENV NVIDIA_VISIBLE_DEVICES=all +ENV NVIDIA_DRIVER_CAPABILITIES=compute,graphics,display +ENV DEBIAN_FRONTEND noninteractive + # add new sudo user ENV USERNAME kbkn ENV HOME /home/$USERNAME @@ -22,9 +23,10 @@ # Replace 1000 with your user/group id usermod --uid 1000 $USERNAME && \ groupmod --gid 1000 $USERNAME && \ - chown -Rf $USERNAME.$USERNAME /home/$USERNAME && \ mkdir -p /home/$USERNAME/.cache && \ - chmod -R 777 /home/$USERNAME/.cache + mkdir -p /home/$USERNAME/.config && \ + mkdir -p /home/$USERNAME/.cache && \ + chown -Rf $USERNAME.$USERNAME /home/$USERNAME RUN apt-get update && apt-get install -y --no-install-recommends \ sudo \ @@ -45,6 +47,7 @@ && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* + RUN packages='libsdl2-2.0 xserver-xorg libvulkan1' \ && apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y $packages --no-install-recommends \ && VULKAN_API_VERSION=`dpkg -s libvulkan1 | grep -oP 'Version: [0-9|\.]+' | grep -oP '[0-9|\.]+'` && \ @@ -62,6 +65,7 @@ # Error constructing proxy for org.gnome.Terminal:/org/gnome/Terminal/Factory0: Failed to execute child process dbus-launch (No such file or directory) # fix by setting LANG https://askubuntu.com/questions/608330/problem-with-gnome-terminal-on-gnome-3-12-2 # to install locales https://stackoverflow.com/questions/39760663/docker-ubuntu-bin-sh-1-locale-gen-not-found + RUN apt-get clean && \ apt-get update && \ apt-get install -y locales && \ @@ -100,34 +104,6 @@ xinit && \ rm -rf /var/lib/apt/lists/* -# (1-3) Install NVIDIA drivers, including X graphic drivers -# Same command as nvidia/driver, except --x-{prefix,module-path,library-path,sysconfig-path} are omitted in order to make use default path and enable X drivers. -# Driver version must be equal to host's driver -# Install the userspace components and copy the kernel module sources. -#ENV DRIVER_VERSION=410.129-diagnostic -#ENV DRIVER_VERSION_PATH=410.129 -#RUN cd /tmp && \ -# curl -fSsl -O https://us.download.nvidia.com/tesla/$DRIVER_VERSION_PATH/NVIDIA-Linux-x86_64-$DRIVER_VERSION.run && \ -# sh NVIDIA-Linux-x86_64-$DRIVER_VERSION.run -x && \ -# cd NVIDIA-Linux-x86_64-$DRIVER_VERSION && \ -# ./nvidia-installer --silent \ -# --no-kernel-module \ -# --install-compat32-libs \ -# --no-nouveau-check \ -# --no-nvidia-modprobe \ -# --no-rpms \ -# --no-backup \ -# --no-check-for-alternate-installs \ -# --no-libglx-indirect \ -# --no-glvnd-egl-client \ -# --no-glvnd-glx-client \ -# --no-install-libglvnd && \ -# mkdir -p /usr/src/nvidia-$DRIVER_VERSION && \ -# mv LICENSE mkprecompiled kernel /usr/src/nvidia-$DRIVER_VERSION && \ -# sed '9,${/^\(kernel\|LICENSE\)/!d}' .manifest > /usr/src/nvidia-$DRIVER_VERSION/.manifest - # this option cannot be used on newer driver - # --no-glvnd-egl-client \ - # --no-glvnd-glx-client \ COPY cuda-repo-ubuntu1804-11-2-local_11.2.2-460.32.03-1_amd64.deb /tmp/cuda-repo-ubuntu1804-11-2-local_11.2.2-460.32.03-1_amd64.deb RUN cd /tmp && \ wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-ubuntu1804.pin && \ @@ -188,6 +164,7 @@ unzip -q v1.2.0.zip && \ rm -rf v1.2.0.zip && \ git clone https://github.com/novnc/websockify /noVNC-1.2.0/utils/websockify + # Xorg segfault error # dbus-core: error connecting to system bus: org.freedesktop.DBus.Error.FileNotFound (Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory) # related? https://github.com/Microsoft/WSL/issues/2016 @@ -196,22 +173,36 @@ libdbus-c++-1-0v5 && \ rm -rf /var/lib/apt/lists/* -# (3) Run Xorg server + x11vnc + X applications -# see run.sh for details -RUN echo "alias m='cd /home/$USERNAME ; su $USERNAME'" >> /home/kbkn/.bashrc && \ - apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 1AF1527DE64CB8D9 && \ - add-apt-repository "deb [arch=amd64] http://dist.carla.org/carla $(lsb_release -sc) main" && \ - mkdir -p /opt/carla-simulator && \ - cd /opt/carla-simulator && \ - apt-get update && apt-get install -y --no-install-recommends \ - carla-simulator=0.9.10-1 \ - libxerces-c-dev iproute2 && \ - rm -rf /var/lib/apt/lists/* && \ - echo "export PYTHONPATH=$PYTHONPATH:/opt/carla-simulator/PythonAPI/carla/dist/carla-0.9.10-py2.7-linux-x86_64.egg:/opt/carla-simulation/PythonAPI/carla" >> ~/.bashrc +RUN echo "alias m='cd /home/$USERNAME ; su $USERNAME'" >> /home/$USERNAME/.bashrc + +# ROS Melodic +RUN sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list' +RUN apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654 +RUN apt-get update && apt-get install -y --no-install-recommends \ + ros-melodic-desktop-full \ + python-rosdep \ + python-rosinstall \ + python-rosinstall-generator \ + python-wstool \ + build-essential \ + && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# addtional ROS package +RUN apt-get update && apt-get install -y --no-install-recommends \ + ros-melodic-derived-object-msgs \ + ros-melodic-ackermann-msgs \ + ros-melodic-ainstein-radar-msgs \ + && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* RUN pip install --upgrade setuptools wheel && \ - pip install simple-pid \ + pip install \ + simple-pid \ numpy \ pygame \ + transforms3d \ future \ matplotlib \ open3d \ @@ -226,16 +217,40 @@ markdown-include \ mkdocs-redirects \ networkx \ - transforms3d \ - decorator==5.0.0 -COPY AdditionalMaps_0.9.10.1.tar.gz /home/$USERNAME/ -RUN tar xfvz /home/$USERNAME/AdditionalMaps_0.9.10.1.tar.gz -C /opt/carla-simulator/ && \ - rm /home/$USERNAME/AdditionalMaps_0.9.10.1.tar.gz -RUN mkdir -p /home/$USERNAME/.config && \ - chmod -R 777 /home/$USERNAME/.config && \ - mkdir -p /home/$USERNAME/.cache && \ - chmod -R 777 /home/$USERNAME/.cache - + decorator==5.0.0 && \ + rosdep init + +USER $USERNAME +WORKDIR /home/$USERNAME +RUN rosdep update +COPY CARLA_${CARLA_VERSION_FULL}.tar.gz /home/$USERNAME/ +RUN mkdir CARLA_${CARLA_VERSION_FULL} && \ + tar xfvz CARLA_${CARLA_VERSION_FULL}.tar.gz -C CARLA_${CARLA_VERSION_FULL} && \ + rm /home/$USERNAME/CARLA_${CARLA_VERSION_FULL}.tar.gz +COPY AdditionalMaps_${CARLA_VERSION_FULL}.tar.gz /home/$USERNAME/ +RUN tar xfvz AdditionalMaps_${CARLA_VERSION_FULL}.tar.gz -C /home/$USERNAME/CARLA_${CARLA_VERSION_FULL}/ && \ + rm /home/$USERNAME/AdditionalMaps_${CARLA_VERSION_FULL}.tar.gz + +RUN echo "export PYTHONPATH=$PYTHONPATH:~/CARLA_${CARLA_VERSION_FULL}/PythonAPI/carla/dist/carla-${CARLA_VERSION}-py2.7-linux-x86_64.egg:~/CARLA_${CARLA_VERSION_FULL}/PythonAPI/carla" >> ~/.bashrc + +SHELL ["/bin/bash", "-c"] +RUN mkdir -p ~/catkin_ws/src && \ + source /opt/ros/melodic/setup.bash && \ + catkin_init_workspace ~/catkin_ws/src && \ + cd ~/catkin_ws/src && \ + git clone --recursive https://github.com/carla-simulator/ros-bridge.git -b ${CARLA_VERSION_FULL} && \ + cd ~/catkin_ws && \ + catkin_make -DCMAKE_BUILD_TYPE=Release && \ + source ~/catkin_ws/devel/setup.bash + +RUN echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc && \ + echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc + +USER root +WORKDIR /root +RUN echo "alias m='cd /home/$USERNAME ; su $USERNAME'" >> /root/.bashrc + + COPY run.sh /run.sh EXPOSE 5900 EXPOSE 8081