From 1cd1f9e0ff7ba0c195ab2a24cbd0ba896c297e68 Mon Sep 17 00:00:00 2001 From: koalp <koalp@alpaga.dev> Date: Sat, 9 Nov 2019 23:53:20 +0100 Subject: [PATCH] feat: add Dockerfiles for ros images --- README.md | 14 ++++- makefile | 19 +++++++ ros-base/Dockerfile | 2 +- ros-desktop/Dockerfile | 6 +++ ros-graphic-acceleration/10_nvidia.json | 7 +++ ros-graphic-acceleration/Dockerfile | 43 ++++++++++++++++ ros-ide/Dockerfile | 11 ++++ run.sh | 68 +++++++++++++++++++++++++ 8 files changed, 168 insertions(+), 2 deletions(-) create mode 100644 makefile create mode 100644 ros-desktop/Dockerfile create mode 100644 ros-graphic-acceleration/10_nvidia.json create mode 100644 ros-graphic-acceleration/Dockerfile create mode 100644 ros-ide/Dockerfile create mode 100755 run.sh diff --git a/README.md b/README.md index cb32c5f..7e7f2cd 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 0000000..f8ad281 --- /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 007de72..78fe578 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 0000000..7493a76 --- /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 0000000..10044b5 --- /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 0000000..20d81b9 --- /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 0000000..401c62f --- /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 0000000..ff37c44 --- /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 -- GitLab