From d71875b2538f3bcb2475b9b92c1cb87fddbe9c19 Mon Sep 17 00:00:00 2001 From: TIm Kluge <timklge@gmail.com> Date: Tue, 28 Apr 2020 17:26:00 +0200 Subject: [PATCH] Add DOCKERFILE --- Dockerfile | 29 +++++++++++++++++++++++++++++ README.md | 7 +++++++ docker-run.sh | 17 +++++++++++++++++ entrypoint.sh | 4 ++++ 4 files changed, 57 insertions(+) create mode 100644 Dockerfile create mode 100755 docker-run.sh create mode 100644 entrypoint.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..be81bdc --- /dev/null +++ b/Dockerfile @@ -0,0 +1,29 @@ +FROM osrf/ros:melodic-desktop-full-bionic + +ENV uid 1000 +ENV gid 1000 + +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +ENV USERNAME ros +RUN useradd -m $USERNAME && \ + echo "$USERNAME:$USERNAME" | chpasswd && \ + usermod --shell /bin/bash $USERNAME && \ + usermod -aG sudo $USERNAME && \ + echo "$USERNAME ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/$USERNAME && \ + chmod 0440 /etc/sudoers.d/$USERNAME && \ + # Replace 1000 with your user/group id + usermod --uid $uid $USERNAME && \ + groupmod --gid $gid $USERNAME + +WORKDIR /home/$USERNAME +COPY src /home/$USERNAME/src +RUN apt-get update && apt-get install -y \ + python-catkin-tools bash +RUN rosdep install --from-paths . -r -y +RUN catkin config \ + --extend /opt/ros/melodic && \ + catkin build + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/README.md b/README.md index afa25cb..c65f7f0 100644 --- a/README.md +++ b/README.md @@ -44,5 +44,12 @@ See the [README.md of the submodule](../../../../sample_applications/-/blob/mast - Execution of a simple motion costraint by a blocking object: `roslaunch sample_applications sample_constraint_simulation.launch` - Execution of a velocity constraint cartesian trajectory: `roslaunch sample_applications simulation.launch` +## Docker +To run via docker on any up-to-date linux system: +- `docker build . -t ceti-panda-gazebo-workspace` +- `./docker-run.sh roslaunch sample_applications sample_simple_simulation.launch` + +Note that this expects your `uid` and `gid` to be `1000`. This is generally the case if your user is the primary user on your system. Otherwise, please change +the values at the top of the `Dockerfile`. \ No newline at end of file diff --git a/docker-run.sh b/docker-run.sh new file mode 100755 index 0000000..8fbb638 --- /dev/null +++ b/docker-run.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +# http://wiki.ros.org/docker/Tutorials/GUI + +XSOCK=/tmp/.X11-unix +XAUTH=/tmp/.docker.xauth +touch $XAUTH +xauth nlist $DISPLAY | sed -e 's/^..../ffff/' | xauth -f $XAUTH nmerge - + +docker run -it \ + --volume=$XSOCK:$XSOCK:rw \ + --volume=$XAUTH:$XAUTH:rw \ + --env="XAUTHORITY=${XAUTH}" \ + --env="DISPLAY" \ + --user="ros" \ + ceti-panda-gazebo-workspace \ + "$@" \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..527ef79 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,4 @@ +#!/bin/bash +source /opt/ros/melodic/setup.bash +source $HOME/devel/setup.bash +exec "$@" \ No newline at end of file -- GitLab