Skip to content

Commit

Permalink
🔨 Updated Dockerfile and ease-of-use script to run virtual_camera.
Browse files Browse the repository at this point in the history
Signed-off-by: Bey Hao Yun <[email protected]>
  • Loading branch information
cardboardcode committed Aug 13, 2024
1 parent 9315ae6 commit 02c5133
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
16 changes: 13 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
FROM ros:humble-perception-jammy

MAINTAINER Bey Hao Yun <[email protected]>

# Add user
RUN adduser --quiet --disabled-password user

ENV DEBIAN_FRONTEND=noninteractive
# Install OpenCV
RUN apt-get update && \
apt-get install -y xauth xxd x11-xserver-utils && \
rm -rf /var/lib/apt/lists/*

WORKDIR /home/user/virtual_camera_ws
RUN mkdir src
COPY . src/virtual_camera

# colcon compilation
RUN . /opt/ros/$ROS_DISTRO/setup.sh \
&& colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release

RUN sed -i '$isource "/home/user/virtual_camera_ws/install/setup.bash"' /ros_entrypoint.sh

RUN chown -R user:user /home/user/
USER user

WORKDIR /home/user
ENTRYPOINT ["/ros_entrypoint.sh"]
21 changes: 11 additions & 10 deletions scripts/1_create_docker_container.bash
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@

xhost +local:docker

docker run -ti \
--ipc host \
--net host \
--name vcam_test_container \
-e DISPLAY=$DISPLAY \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v /dev/shm:/dev/shm \
-v $(pwd):/home/user/virtual_camera \
-u 0 \
vcam_image:latest /bin/bash
docker run -it --rm \
--ipc host \
--net host \
--name vcam_test_container \
-e DISPLAY=$DISPLAY \
-v /dev/shm:/dev/shm \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-u user \
vcam_image:humble bash -c \
"ros2 launch virtual_camera showimageraw.launch.py \
use_image_viewer:=true"

xhost -local:docker

0 comments on commit 02c5133

Please sign in to comment.