From 9318d585deb58881dd66552081b315cd15e59d50 Mon Sep 17 00:00:00 2001 From: Jose Luis Rivero Date: Mon, 2 Sep 2024 17:59:56 +0200 Subject: [PATCH] Simplify the docker build+run in relay tutorial Removed build.sh and run.sh scripts that were really not needed to just run the relay example. Modify the instructions accordingly. Signed-off-by: Jose Luis Rivero --- docker/{gz-transport => }/Dockerfile | 0 docker/build.bash | 44 -------------- docker/run.bash | 91 ---------------------------- tutorials/08_relay.md | 14 +---- 4 files changed, 3 insertions(+), 146 deletions(-) rename docker/{gz-transport => }/Dockerfile (100%) delete mode 100755 docker/build.bash delete mode 100755 docker/run.bash diff --git a/docker/gz-transport/Dockerfile b/docker/Dockerfile similarity index 100% rename from docker/gz-transport/Dockerfile rename to docker/Dockerfile diff --git a/docker/build.bash b/docker/build.bash deleted file mode 100755 index 30c4e5a91..000000000 --- a/docker/build.bash +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env bash - -# -# Copyright (C) 2019 Open Source Robotics Foundation -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# - -# Builds a Docker image. - -if [ $# -eq 0 ] -then - echo "Usage: $0 directory-name" - exit 1 -fi - -# get path to current directory -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" - -if [ ! -d $DIR/$1 ] -then - echo "image-name must be a directory in the same folder as this script" - exit 2 -fi - -user_id=$(id -u) -image_name=$(basename $1) -image_plus_tag=$image_name:$(date +%Y_%b_%d_%H%M) - -docker build --rm -t $image_plus_tag --build-arg user_id=$user_id $DIR/$image_name -docker tag $image_plus_tag $image_name:latest - -echo "Built $image_plus_tag and tagged as $image_name:latest" diff --git a/docker/run.bash b/docker/run.bash deleted file mode 100755 index deb6fd50e..000000000 --- a/docker/run.bash +++ /dev/null @@ -1,91 +0,0 @@ -#!/usr/bin/env bash - -# -# Copyright (C) 2019 Open Source Robotics Foundation -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# - -# Runs a docker container with the image created by build.bash -# Requires: -# docker -# nvidia-docker -# an X server -# Recommended: -# A joystick mounted to /dev/input/js0 or /dev/input/js1 - -if [ $# -lt 1 ] -then - echo "Usage: $0 [ ...]" - exit 1 -fi - -IMG=$(basename $1) - -ARGS=("$@") -WORKSPACES=("${ARGS[@]:1}") - -# Make sure processes in the container can connect to the x server -# Necessary so gazebo can create a context for OpenGL rendering (even headless) -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 - -DOCKER_OPTS= - -# Share your vim settings. -VIMRC=~/.vimrc -if [ -f $VIMRC ] -then - DOCKER_OPTS="$DOCKER_OPTS -v $VIMRC:/home/developer/.vimrc:ro" -fi - -for WS_DIR in ${WORKSPACES[@]} -do - WS_DIRNAME=$(basename $WS_DIR) - if [ ! -d $WS_DIR/src ] - then - echo "Other! $WS_DIR" - DOCKER_OPTS="$DOCKER_OPTS -v $WS_DIR:/home/developer/other/$WS_DIRNAME" - else - echo "Workspace! $WS_DIR" - DOCKER_OPTS="$DOCKER_OPTS -v $WS_DIR:/home/developer/workspaces/$WS_DIRNAME" - fi -done - -# Mount extra volumes if needed. -# E.g.: -# -v "/opt/sublime_text:/opt/sublime_text" \ - -docker run -it \ - -e DISPLAY \ - -e QT_X11_NO_MITSHM=1 \ - -e XAUTHORITY=$XAUTH \ - -v "$XAUTH:$XAUTH" \ - -v "/tmp/.X11-unix:/tmp/.X11-unix" \ - -v "/etc/localtime:/etc/localtime:ro" \ - -v "/dev/input:/dev/input" \ - --rm \ - --security-opt seccomp=unconfined \ - $DOCKER_OPTS \ - $IMG diff --git a/tutorials/08_relay.md b/tutorials/08_relay.md index 24fe7e215..50649841c 100644 --- a/tutorials/08_relay.md +++ b/tutorials/08_relay.md @@ -29,25 +29,17 @@ Download the [build.bash](https://github.com/gazebosim/gz-transport/raw/gz-trans [Dockerfile](https://github.com/gazebosim/gz-transport/raw/gz-transport14/docker/gz-transport/Dockerfile) files. ```{.sh} -wget https://github.com/gazebosim/gz-transport/raw/gz-transport14/docker/build.bash -wget https://github.com/gazebosim/gz-transport/raw/gz-transport14/docker/run.bash -mkdir gz-transport && wget https://github.com/gazebosim/gz-transport/raw/gz-transport14/docker/gz-transport/Dockerfile -O gz-transport/Dockerfile -chmod +x build.bash run.bash +wget https://github.com/gazebosim/gz-transport/raw/gz-transport14/docker/gz-transport/Dockerfile -O Dockerfile ``` Now, it's time to build the Docker image: ``` -./build.bash gz-transport +docker build -t gz-transport-relay - < Dockerfile ``` Run your Docker container: ``` -./run.bash gz-transport -``` - -Inside the docker instance, go to the `example` directory: -``` -cd gz-transport/example/build +docker run -it --rm gz-transport-relay /bin/bash ``` Back on your host, make sure that you have Gazebo Tools and net-tools