From a0bce838f26bd88bf5485520c3ecda56ab5aeec4 Mon Sep 17 00:00:00 2001 From: yenon Date: Thu, 1 Sep 2022 11:39:26 +0200 Subject: [PATCH] initial commit --- build_ros/Dockerfile | 12 ++++++++++++ docker-compose.yaml | 24 ++++++++++++++++++++++++ start.sh | 29 +++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+) create mode 100755 build_ros/Dockerfile create mode 100755 docker-compose.yaml create mode 100755 start.sh diff --git a/build_ros/Dockerfile b/build_ros/Dockerfile new file mode 100755 index 0000000..ca25dc8 --- /dev/null +++ b/build_ros/Dockerfile @@ -0,0 +1,12 @@ +ARG ROS=humble +FROM osrf/ros:${ROS}-desktop +RUN apt-get update -y +RUN apt-get install -y ros-galactic-ros-ign-gazebo +RUN DEBIAN_FRONTEND=noninteractive apt-get install -y xserver-xorg-video-all libgl1-mesa-glx libgl1-mesa-dri libglvnd0 libgl1 libglx0 libegl1 libxext6 libx11-6 +RUN apt-get install -y libvulkan1 mesa-vulkan-drivers vulkan-utils mesa-utils +ARG UID=1000 +ARG GID=1000 +run groupadd -f -g $GID ros +RUN useradd -u $UID -g $GID -m ros +RUN usermod -aG video ros +RUN usermod -aG render ros diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100755 index 0000000..7b43bfd --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,24 @@ +version: "3.2" + +services: + ros: + image: ros/custom + build: + context: ./build_ros + args: + ROS: galactic #Desired ROS version + user: 1000:1000 #Fill in your id's here. (UID:GUI) + volumes: + - /tmp/.X11-unix:/tmp/.X11-unix:rw + - ./ros:/home/ros + devices: + - /dev/dri:/dev/dri + environment: + - DISPLAY=$DISPLAY + - XAUTHORITY=$XAUTHORITY + entrypoint: /bin/bash + stdin_open: true + tty: true + #group_add: + # - video + # - render diff --git a/start.sh b/start.sh new file mode 100755 index 0000000..32c98bf --- /dev/null +++ b/start.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +sudo docker-compose build +sudo docker-compose up -d + +up_result=$(sudo docker-compose ps -q) + +hosts=() + +while read line; do + hosts+=(`sudo docker inspect --format='{{ .Config.Hostname }}' $line`) + #xhost +local:`sudo docker inspect --format='{{ .Config.Hostname }}' $line` +done <<< "$up_result" + +echo "Adding to xhost:" +for host in ${hosts[@]}; do + echo " + $host" + xhost "+local:$host" +done + +echo "Attaching." +echo "You are ready for shell access." +sudo docker-compose up + +echo "Removing from xhost:" +for host in ${hosts[@]}; do + echo " - $host" + xhost "-local:$host" +done