diff --git a/Dockerfile b/Dockerfile index 1f87bd6..c1eae70 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,25 @@ FROM ros:humble-perception-jammy -MAINTAINER Bey Hao Yun - # 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"] \ No newline at end of file diff --git a/scripts/1_create_docker_container.bash b/scripts/1_create_docker_container.bash index af664aa..8f61a1c 100644 --- a/scripts/1_create_docker_container.bash +++ b/scripts/1_create_docker_container.bash @@ -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