From 8b0b641c2a379b89e950396b9ecfee26ab558ac4 Mon Sep 17 00:00:00 2001 From: mikihiroikura Date: Fri, 4 Oct 2024 18:50:44 +0200 Subject: [PATCH] use non-root user, add submodule catkin_simple --- .gitmodules | 3 +++ Dockerfile | 31 +++++++++++++++++++++---------- README.md | 4 ++-- catkin_simple | 1 + docker-compose.yml | 2 +- 5 files changed, 28 insertions(+), 13 deletions(-) create mode 160000 catkin_simple diff --git a/.gitmodules b/.gitmodules index 7d1b7e0..5c40c79 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,6 @@ [submodule "rpg_dvs_ros"] path = rpg_dvs_ros url = git@github.com:uzh-rpg/rpg_dvs_ros.git +[submodule "catkin_simple"] + path = catkin_simple + url = https://github.com/catkin/catkin_simple.git diff --git a/Dockerfile b/Dockerfile index 941b6c0..6da1c29 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,18 +1,24 @@ FROM osrf/ros:melodic-desktop-full RUN apt update && apt install -y git wget -ENV DISPLAY host.docker.internal:0.0 +ENV DISPLAY=host.docker.internal:0.0 ## python-catkin-tools +#### Add User ID and Group ID +ARG UNAME=rate +ARG UID=1000 +ARG GID=1000 +RUN groupadd -g $GID -o $UNAME +RUN useradd -m -u $UID -g $GID -o -s /bin/bash $UNAME + +ARG CODE_DIR=/home/${UNAME} + #### ROS setup #### -RUN mkdir -p ~/catkin_ws/src && \ - echo "source /opt/ros/melodic/setup.bash" >> /root/.bashrc +RUN mkdir -p ${CODE_DIR}/catkin_ws/src && \ + echo "source /opt/ros/melodic/setup.bash" >> ${CODE_DIR}/.bashrc #### Install dependencies #### RUN apt-get update && apt-get install -y python-catkin-tools -# catkin_simple -RUN cd ~/catkin_ws/src && \ - git clone https://github.com/catkin/catkin_simple.git # build libcaer library -RUN mkdir ~/src && cd ~/src && \ +RUN mkdir ${CODE_DIR}/src && cd ${CODE_DIR}/src && \ git clone https://gitlab.com/inivation/dv/libcaer.git && cd libcaer && \ apt-get install -y build-essential cmake pkg-config libusb-1.0-0-dev && \ cmake -DCMAKE_INSTALL_PREFIX=/usr . && \ @@ -20,10 +26,15 @@ RUN mkdir ~/src && cd ~/src && \ # build ceres RUN apt-get install -y libgoogle-glog-dev libgflags-dev \ libatlas-base-dev libeigen3-dev && \ - cd ~/src && wget http://ceres-solver.org/ceres-solver-2.1.0.tar.gz && \ + cd ${CODE_DIR}/src && wget http://ceres-solver.org/ceres-solver-2.1.0.tar.gz && \ tar zxf ceres-solver-2.1.0.tar.gz && \ - mkdir -p ~/src/ceres-solver-2.1.0/build && cd ~/src/ceres-solver-2.1.0/build && \ + mkdir -p ${CODE_DIR}/src/ceres-solver-2.1.0/build && cd ${CODE_DIR}/src/ceres-solver-2.1.0/build && \ cmake .. && make && make install #### Copy source code #### -COPY ./ /root/catkin_ws/src \ No newline at end of file +COPY ./ ${CODE_DIR}/catkin_ws/src + +RUN chown -R $UNAME:$UNAME ${CODE_DIR}/catkin_ws + +USER $UNAME +WORKDIR ${CODE_DIR} \ No newline at end of file diff --git a/README.md b/README.md index 80ace26..e8e9b71 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ git submodule update --init --recursive ``` ### Build docker image ``` -docker build -t rate:latest . +docker build --build-arg UID=$(id -u) --build-arg GID=$(id -g) -t rate:latest . ``` ### Run docker container @@ -57,7 +57,7 @@ xhost local:docker ## How to run RATE, continuous feature detection and tracking with event rosbag data 1st terminal (in docker container) ``` -roslaunch haste_ros haste_fd_timeslice_sae.launch event_topic:=/dvs/events camera_size:=240x180 camera_calib:=/root/catkin_ws/src/haste_ros/haste/dataset/calib.txt +roslaunch haste_ros haste_fd_timeslice_sae.launch event_topic:=/dvs/events camera_size:=240x180 camera_calib:=/home/rate/catkin_ws/src/haste_ros/haste/dataset/calib.txt ``` 2nd terminal (in host if you have ros environment locally / otherwise in docker container) ``` diff --git a/catkin_simple b/catkin_simple new file mode 160000 index 0000000..0e62848 --- /dev/null +++ b/catkin_simple @@ -0,0 +1 @@ +Subproject commit 0e62848b12da76c8cc58a1add42b4f894d1ac21e diff --git a/docker-compose.yml b/docker-compose.yml index c625712..54450d2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,5 +12,5 @@ services: - DISPLAY=${DISPLAY} volumes: - /tmp/.X11-unix:/tmp/.X11-unix - - /home/m-ikura/Github/SilkyEvCam/rosbag/:/app/rosbag + - /home/mikura-iit.local/data/rosbag/:/app/rosbag # Mount rosbag files into docker container command: sleep infinity \ No newline at end of file