diff --git a/README.md b/README.md index cb32c5f7955b9b1019e95611ad43635a167ceafa..7e7f2cdd3dae7195ae68675655c4c8ab7f015272 100644 --- a/README.md +++ b/README.md @@ -1 +1,13 @@ -Docker images for ros course \ No newline at end of file +Docker images for ros course + +# Setup + +Build the `registry.gitlab.clubelek.fr/formations/ros/docker-images/ros:user` images : + +`make docker-user` + +# Usage + +Linux : `./run.sh registry.gitlab.clubelek.fr/formations/ros/docker-images/ros:user` + +Windows : launch the vnc image `registry.gitlab.clubelek.fr/formations/ros/docker-images/ros:user-vnc` diff --git a/makefile b/makefile new file mode 100644 index 0000000000000000000000000000000000000000..f8ad281b390cccfb683cf0defb5c3089fb76da88 --- /dev/null +++ b/makefile @@ -0,0 +1,19 @@ +# TODO: universal image name from folder_name+dockerfile_name +registry_url=registry.gitlab.clubelek.fr/formations/ros/docker-images/ + +all: ros-base ros-desktop ros-graphic-acceleration ros-ide + +.PHONY: ros-base ros-desktop ros-graphic-acceleration ros-user + +ros-base: + docker build -t ${registry_url}ros:base -f ./ros-base/Dockerfile ./ros-base + +ros-desktop: ros-base + docker build -t ${registry_url}ros:desktop -f ./ros-desktop/Dockerfile ./ros-desktop + +ros-graphic-acceleration: ros-desktop + docker build -t ${registry_url}ros:graphic-acceleration -f ./ros-graphic-acceleration/Dockerfile ./ros-graphic-acceleration + +ros-ide: ros-graphic-acceleration + docker build -t ${registry_url}ros:ide -f ./ros-ide/Dockerfile ./ros-ide + diff --git a/ros-base/Dockerfile b/ros-base/Dockerfile index 007de72320b0cd5b8f056fe579c9bac656cebf5e..78fe578a72ff7e9a7387ca544e07d8ead612d717 100644 --- a/ros-base/Dockerfile +++ b/ros-base/Dockerfile @@ -25,7 +25,7 @@ RUN apt-get update && apt-get install -q -y \ # Install bare bones ROS Installation RUN apt-get update && apt-get install -q -y \ - ros-$ROS_VERSION_NAME-ros-base \ + ros-$ROS_VERSION_NAME-ros-base python3-colcon-common-extensions \ && rm -rf /var/lib/apt/lists/* # Add source command to root user bashrc diff --git a/ros-desktop/Dockerfile b/ros-desktop/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..7493a7666d4dc98c89ac25025f6e905fb7e5cede --- /dev/null +++ b/ros-desktop/Dockerfile @@ -0,0 +1,6 @@ +FROM registry.gitlab.clubelek.fr/formations/ros/docker-images/ros:base + +# Install desktop ROS Installation +RUN apt-get update && apt-get install -q -y \ + ros-$ROS_VERSION_NAME-desktop \ + && rm -rf /var/lib/apt/lists/* diff --git a/ros-graphic-acceleration/10_nvidia.json b/ros-graphic-acceleration/10_nvidia.json new file mode 100644 index 0000000000000000000000000000000000000000..10044b5f1a26b6dc2c2d98b45d37968fb8f2d084 --- /dev/null +++ b/ros-graphic-acceleration/10_nvidia.json @@ -0,0 +1,7 @@ +{ + "file_format_version" : "1.0.0", + "ICD" : { + "library_path" : "libEGL_nvidia.so.0" + } +} + diff --git a/ros-graphic-acceleration/Dockerfile b/ros-graphic-acceleration/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..20d81b901fea28e49a51e01f767ad62a1167f42e --- /dev/null +++ b/ros-graphic-acceleration/Dockerfile @@ -0,0 +1,43 @@ +FROM registry.gitlab.clubelek.fr/formations/ros/docker-images/ros:desktop + +# nvidia-container-runtime +ENV NVIDIA_VISIBLE_DEVICES \ + ${NVIDIA_VISIBLE_DEVICES:-all} +ENV NVIDIA_DRIVER_CAPABILITIES \ + ${NVIDIA_DRIVER_CAPABILITIES:+$NVIDIA_DRIVER_CAPABILITIES,}graphics,utility + +# Required for non-glvnd setups. +ENV LD_LIBRARY_PATH /usr/lib/x86_64-linux-gnu:/usr/lib/i386-linux-gnu${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}} + +RUN apt-get update && apt-get install -y --no-install-recommends \ + git \ + ca-certificates \ + make \ + automake \ + autoconf \ + libtool \ + pkg-config \ + python \ + libxext-dev \ + libx11-dev \ + x11proto-gl-dev + +WORKDIR /opt/libglvnd +RUN git clone --branch=0.1.1 https://github.com/NVIDIA/libglvnd.git . && \ + ./autogen.sh && \ + ./configure --prefix=/usr/local --libdir=/usr/local/lib/x86_64-linux-gnu && \ + make -j"$(nproc)" install-strip && \ + find /usr/local/lib/x86_64-linux-gnu -type f -name 'lib*.la' -delete + +COPY 10_nvidia.json /usr/local/share/glvnd/egl_vendor.d/10_nvidia.json + +RUN echo '/usr/local/lib/x86_64-linux-gnu' >> /etc/ld.so.conf.d/glvnd.conf && \ + echo '/usr/local/lib/i386-linux-gnu' >> /etc/ld.so.conf.d/glvnd.conf && \ + ldconfig + +ENV LD_LIBRARY_PATH /usr/local/lib/x86_64-linux-gnu:${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}} + +RUN apt-get -y update && apt-get install -y zsh screen tree sudo ssh synaptic nano inetutils-ping git + +# Additional development tools +RUN apt-get install -y x11-apps python-pip build-essential diff --git a/ros-ide/Dockerfile b/ros-ide/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..401c62fdf5780f53e95dd456ee71d7b107e51284 --- /dev/null +++ b/ros-ide/Dockerfile @@ -0,0 +1,11 @@ +FROM registry.gitlab.clubelek.fr/formations/ros/docker-images/ros:graphic-acceleration + +WORKDIR /opt + +RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -q -y \ + eclipse \ + jupyter \ + && wget https://download.jetbrains.com/python/pycharm-professional-2019.2.4.tar.gz \ + && tar -xvf pycharm-professional-2019.2.4.tar.gz \ + && echo 'export PATH=/opt/pycharm-professional-2019.2.4/bin:${PATH}' >> /root/.bashrc \ + && rm -rf /var/lib/apt/lists/* diff --git a/run.sh b/run.sh new file mode 100755 index 0000000000000000000000000000000000000000..ff37c44faeafde0ff27d4592620dfa6afec737d0 --- /dev/null +++ b/run.sh @@ -0,0 +1,68 @@ +#!/usr/bin/env bash + +# Check args +if [ "$#" -ne 3 ]; then + echo "usage: ./run.sh IMAGE_NAME CONTAINER_NAME WORKSPACE" + exit 1 +fi + +if [ ${3:0:1} == '/' ]; then + workspace_path=$3 +else + workspace_path=`pwd`/$3 +fi + +# Get this script's path +pushd `dirname $0` > /dev/null +SCRIPTPATH=`pwd` +popd > /dev/null + +set -e + + +XAUTH=/tmp/.docker.xauth +if [ ! -f $XAUTH ] +then + xauth_list=$(xauth nlist :0 | sed -e 's/^..../ffff/') + if [ ! -z "$xauth_list" ] + then + echo $xauth_list | xauth -f $XAUTH nmerge - + else + touch $XAUTH + fi + chmod a+r $XAUTH +fi + +# Run the container with shared X11 +if [ -z DOCKER_NVIDIA ]; then + sudo docker run\ + --privileged\ + --rm\ + --net=host\ + -e SHELL\ + --env="DISPLAY=$DISPLAY"\ + --env="QT_X11_NO_MITSHM=1"\ + -env="XAUTHORITY=$XAUTH"\ + --volume="$XAUTH:$XAUTH"\ + --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \ + --volume="${workspace_path}:${HOME}/workspace" \ + -e DOCKER=1\ + --name $2 \ + --runtime=nvidia \ + -it $1 bash +else + sudo docker run\ + --privileged\ + --rm\ + --net=host\ + -e SHELL\ + --env="DISPLAY=$DISPLAY"\ + --env="QT_X11_NO_MITSHM=1"\ + -env="XAUTHORITY=$XAUTH"\ + --volume="$XAUTH:$XAUTH"\ + --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \ + --volume="${workspace_path}:${HOME}/workspace" \ + -e DOCKER=1\ + --name $2 \ + -it $1 bash +fi