@@ -47,17 +47,9 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
4747 /home/${USERNAME}/.ros && \
4848 chown -R $USER_UID:$USER_GID /home/${USERNAME} /opt/overlay_ws/
4949
50- # IMPORTANT: Optionally install Nvidia drivers for improved simulator performance with Nvidia GPUs.
51- # To do this you must
52- # 1. Uncomment the ENV and RUN entries below
53- # 2. Replace the 'nvidia-driver-555' apt package with the Nvidia driver version on your host, e.g. nvidia-driver-535, nvidia-driver-555. Use nvidia-smi on your host to determine the driver version.
54- # After rebuilding via `moveit_pro build` verify the drivers are active in your container by running `nvidia_smi` inside of `moveit_pro shell`.
55- # ENV DEBIAN_FRONTEND=noninteractive
56- # RUN apt update && apt install -y software-properties-common
57- # RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
58- # --mount=type=cache,target=/var/lib/apt,sharing=locked \
59- # add-apt-repository ppa:graphics-drivers/ppa && \
60- # apt update && apt upgrade -y && apt install -y nvidia-driver-555
50+ # Add user to dialout group to enable communication with serial USB devices (gripper, FTS, ...)
51+ # Add user to video group to enable communication with cameras
52+ RUN usermod -aG dialout,video ${USERNAME}
6153
6254# Install additional dependencies
6355# You can also add any necessary apt-get install, pip install, etc. commands at this point.
@@ -121,3 +113,129 @@ WORKDIR $USER_WS
121113
122114# Set up the user's .bashrc file and shell.
123115CMD ["/usr/bin/bash" ]
116+
117+ # #################################################
118+ # Starting from the specified MoveIt Pro release with CUDA GPU #
119+ # #################################################
120+ # The image tag is specified in the argument itself.
121+ # hadolint ignore=DL3006
122+ FROM ${MOVEIT_STUDIO_BASE_IMAGE} AS base-gpu
123+
124+ # Create a non-root user
125+ ARG USERNAME
126+ ARG USER_UID
127+ ARG USER_GID
128+
129+ # hadolint ignore=DL3008
130+ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
131+ --mount=type=cache,target=/var/lib/apt,sharing=locked \
132+ apt-get update && apt-get install wget -y -q --no-install-recommends && \
133+ wget --progress=dot:giga https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb && \
134+ dpkg -i cuda-keyring_1.1-1_all.deb && \
135+ apt-get update && \
136+ apt-get install -q -y --no-install-recommends \
137+ libcudnn9-cuda-12 \
138+ libcudnn9-dev-cuda-12 \
139+ libcublas-12-6 \
140+ cuda-cudart-12-6 \
141+ libcurand-12-6 \
142+ libcufft-12-6 \
143+ libnvinfer10 \
144+ libnvinfer-plugin10 \
145+ libnvonnxparsers10 \
146+ libtree
147+
148+ # Misleading name: onnxruntime_gpu is actually specifically the CUDA package. This is only shipped for x86-64
149+ RUN if [ "$(uname -m)" = "x86_64" ]; then pip3 install --no-cache-dir onnxruntime_gpu==1.19.0; fi
150+
151+ # Copy source code from the workspace's ROS 2 packages to a workspace inside the container
152+ ARG USER_WS=/home/${USERNAME}/user_ws
153+ ENV USER_WS=${USER_WS}
154+
155+ # Also mkdir with user permission directories which will be mounted later to avoid docker creating them as root
156+ WORKDIR $USER_WS
157+ # hadolint ignore=DL3008
158+ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
159+ --mount=type=cache,target=/var/lib/apt,sharing=locked \
160+ groupadd --gid $USER_GID ${USERNAME} && \
161+ useradd --uid $USER_UID --gid $USER_GID --shell /bin/bash --create-home ${USERNAME} && \
162+ apt-get update && \
163+ apt-get install -q -y --no-install-recommends sudo && \
164+ echo ${USERNAME} ALL=\( root\) NOPASSWD:ALL > /etc/sudoers.d/${USERNAME} && \
165+ chmod 0440 /etc/sudoers.d/${USERNAME} && \
166+ cp -r /etc/skel/. /home/${USERNAME} && \
167+ mkdir -p \
168+ /home/${USERNAME}/.ccache \
169+ /home/${USERNAME}/.config \
170+ /home/${USERNAME}/.ignition \
171+ /home/${USERNAME}/.colcon \
172+ /home/${USERNAME}/.ros && \
173+ chown -R $USER_UID:$USER_GID /home/${USERNAME} /opt/overlay_ws/
174+
175+ # Install additional dependencies
176+ # You can also add any necessary apt-get install, pip install, etc. commands at this point.
177+ # NOTE: The /opt/overlay_ws folder contains MoveIt Pro binary packages and the source file.
178+ # hadolint ignore=SC1091
179+ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
180+ --mount=type=cache,target=/var/lib/apt,sharing=locked \
181+ --mount=type=bind,target=${USER_WS}/,source=. \
182+ . /opt/overlay_ws/install/setup.sh && \
183+ apt-get update && \
184+ rosdep install -q -y \
185+ --from-paths src \
186+ --ignore-src
187+
188+ # Set up colcon defaults for the new user
189+ USER ${USERNAME}
190+ RUN colcon mixin add default \
191+ https://raw.githubusercontent.com/colcon/colcon-mixin-repository/master/index.yaml && \
192+ colcon mixin update && \
193+ colcon metadata add default \
194+ https://raw.githubusercontent.com/colcon/colcon-metadata-repository/master/index.yaml && \
195+ colcon metadata update
196+ COPY colcon-defaults.yaml /home/${USERNAME}/.colcon/defaults.yaml
197+
198+ # hadolint ignore=DL3002
199+ USER root
200+
201+ # Set up the user's .bashrc file and shell.
202+ CMD ["/usr/bin/bash" ]
203+
204+ # ##################################################################
205+ # Target for the developer build which does not compile any code. #
206+ # ##################################################################
207+ FROM base-gpu AS user-overlay-gpu-dev
208+
209+ ARG USERNAME
210+ ARG USER_WS=/home/${USERNAME}/user_ws
211+ ENV USER_WS=${USER_WS}
212+
213+ # Install any additional packages for development work
214+ # hadolint ignore=DL3008
215+ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
216+ --mount=type=cache,target=/var/lib/apt,sharing=locked \
217+ apt-get update && \
218+ apt-get install -y --no-install-recommends \
219+ less \
220+ gdb \
221+ nano
222+
223+ # Set up the user's .bashrc file and shell.
224+ CMD ["/usr/bin/bash" ]
225+
226+ # ########################################
227+ # Target for compiled, deployable image with GPU support #
228+ # ########################################
229+ FROM base-gpu AS user-overlay-gpu
230+
231+ ARG USERNAME
232+ ARG USER_WS=/home/${USERNAME}/user_ws
233+ ENV USER_WS=${USER_WS}
234+
235+ ENV LD_LIBRARY_PATH=/usr/local/lib/python3.10/dist-packages/onnxruntime/capi:/usr/lib/x86_64-linux-gnu:/usr/local/cuda-12.6/targets/x86_64-linux/lib:$LD_LIBRARY_PATH
236+
237+ # Compile the workspace
238+ WORKDIR $USER_WS
239+
240+ # Set up the user's .bashrc file and shell.
241+ CMD ["/usr/bin/bash" ]
0 commit comments