From d4063819a7e663b82d596f5e33ad3548e1fbd8f6 Mon Sep 17 00:00:00 2001 From: David Spielman Date: Fri, 6 Dec 2024 15:13:49 -0600 Subject: [PATCH] Added Dockerfile and docker compose files --- docker/Dockerfile | 48 +++++++++++++++++++++++++++++ docker/docker-compose.yml | 36 ++++++++++++++++++++++ docker/extrinsic_calibration_gui.sh | 3 ++ docker/intrinsic_calibration_gui.sh | 3 ++ 4 files changed, 90 insertions(+) create mode 100644 docker/Dockerfile create mode 100644 docker/docker-compose.yml create mode 100755 docker/extrinsic_calibration_gui.sh create mode 100755 docker/intrinsic_calibration_gui.sh diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 00000000..f04387a3 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,48 @@ +ARG TAG=jammy +FROM ubuntu:${TAG} + +ARG ROS_DISTRO + +SHELL ["/bin/bash", "-c"] + +ENV DEBIAN_FRONTEND noninteractive + +USER root + +# Install +RUN apt update \ + && apt upgrade -y \ + && apt install -y cmake curl git python3 + +# Add ROS2 sources to install ROS infrastructure tools +RUN curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg \ + && echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | tee /etc/apt/sources.list.d/ros2.list > /dev/null + +# Install and configure ROS infrastructure tools +RUN apt update \ + && apt install -y python3-vcstool python3-colcon-common-extensions python3-rosdep \ + && rosdep init \ + && rosdep update + +# Bind mount the source directory so as not to unnecessarily copy source code into the docker image +ARG WORKSPACE_DIR=/opt/industrial_calibration +RUN --mount=type=bind,target=${WORKSPACE_DIR}/src/industrial_calibration \ + apt update -y -qq \ + && vcs import ${WORKSPACE_DIR}/src < ${WORKSPACE_DIR}/src/industrial_calibration/dependencies.repos --shallow \ + && rosdep install \ + --from-paths ${WORKSPACE_DIR}/src \ + -iry + +# Build the repository +# Bind mount the source directory so as not to unnecessarily copy source code into the docker image +RUN --mount=type=bind,target=${WORKSPACE_DIR}/src/industrial_calibration \ + cd ${WORKSPACE_DIR} \ + && colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release \ + && rm -rf build log + +# Set the entrypoint to source the workspace +COPY docker/extrinsic_calibration_gui.sh /extrinsic_calibration_gui.sh +COPY docker/intrinsic_calibration_gui.sh /intrinsic_calibration_gui.sh + + +ENTRYPOINT ["/extrinsic_calibration_gui"] \ No newline at end of file diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml new file mode 100644 index 00000000..637ab3e7 --- /dev/null +++ b/docker/docker-compose.yml @@ -0,0 +1,36 @@ +services: + industrial_calibration: + build: + context: .. + dockerfile: docker/Dockerfile + args: + TAG: jammy + ROS_DISTRO: humble + environment: + DISPLAY: $DISPLAY + XAUTHORITY: $XAUTHORITY + NVIDIA_DRIVER_CAPABILITIES: all + ROS_LOG_DIR: /tmp + container_name: industrial_calibration + image: ghcr.io/ros-industrial/industrial_calibration:jammy + stdin_open: true + tty: true + network_mode: host + privileged: false + user: ${CURRENT_UID} # CURRENT_UID=$(id -u):$(id -g) + volumes: + - /tmp/.X11-unix:/tmp/.X11-unix + - /etc/hosts:/etc/hosts + - /etc/passwd:/etc/passwd:ro + - /etc/group:/etc/group:ro + + # entrypoint: /extrinsic_calibration_gui.sh + entrypoint: /intrinsic_calibration_gui.sh + + deploy: + resources: + reservations: + devices: + - driver: nvidia + count: 1 + capabilities: [gpu] \ No newline at end of file diff --git a/docker/extrinsic_calibration_gui.sh b/docker/extrinsic_calibration_gui.sh new file mode 100755 index 00000000..2e7431ba --- /dev/null +++ b/docker/extrinsic_calibration_gui.sh @@ -0,0 +1,3 @@ +#!/bin/bash +source /opt/industrial_calibration/install/setup.bash +./opt/industrial_calibration/install/industrial_calibration/bin/industrial_calibration_extrinsic_hand_eye_calibration_app \ No newline at end of file diff --git a/docker/intrinsic_calibration_gui.sh b/docker/intrinsic_calibration_gui.sh new file mode 100755 index 00000000..384711a7 --- /dev/null +++ b/docker/intrinsic_calibration_gui.sh @@ -0,0 +1,3 @@ +#!/bin/bash +source /opt/industrial_calibration/install/setup.bash +./opt/industrial_calibration/install/industrial_calibration/bin/industrial_calibration_camera_intrinsic_calibration_app \ No newline at end of file