1- # Set desired ROS distribution, this image currently only supports humble.
1+ # Set desired ROS distribution
22ARG ROS_DISTRO=humble
33
44# This layer grabs package manifests from the src directory for preserving rosdep installs.
@@ -18,8 +18,7 @@ FROM ros:${ROS_DISTRO} AS er4-dev
1818
1919SHELL ["/bin/bash" , "-o" , "pipefail" , "-c" ]
2020
21- # Overridable non root user information, this can be annoying for non humble ROS base images, which
22- # may already have a non-root user created.
21+ # Overridable non root user information.
2322ARG USER_UID=1000
2423ARG USER_GID=1000
2524ARG USERNAME=er4-user
@@ -53,7 +52,9 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
5352 xterm \
5453 wget
5554
56- # Add a non-root user with provided user details
55+ # Add a non-root user with provided user details. Some images have a default `ubuntu` user, so we remove it before adding the
56+ # new one.
57+ RUN userdel -r ubuntu 2>/dev/null || true
5758RUN groupadd -g ${USER_GID} ${USERNAME} \
5859 && useradd -l -u ${USER_UID} -g ${USER_GID} --create-home -m -s /bin/bash -G sudo,adm,dialout,dip,plugdev,video ${USERNAME} \
5960 && echo "${USERNAME} ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers && \
@@ -62,12 +63,35 @@ RUN groupadd -g ${USER_GID} ${USERNAME} \
6263 /home/${USERNAME}/.colcon \
6364 /home/${USERNAME}/.ros \
6465 /home/${USERNAME}/.bash \
65- ${ER4_WS}
66+ ${ER4_WS}/src \
67+ ${ER4_WS}/build \
68+ ${ER4_WS}/install \
69+ ${ER4_WS}/log && \
70+ chown -R ${USERNAME}:${USERNAME} /home/${USERNAME}
71+
72+ # Configure and install MuJoCo using the defaults for the MuJoCo drivers.
73+ # We use MuJoCo in many systems so we just install the drivers in the base workspace.
74+ # The install is CPU dependent, this works with `x86_64` and `arm64` chips, TBD on others.
75+ ARG MUJOCO_VERSION=3.4.0
76+ ENV MUJOCO_VERSION=${MUJOCO_VERSION}
77+ ENV MUJOCO_DIR="/opt/mujoco/mujoco-${MUJOCO_VERSION}"
78+ RUN mkdir -p ${MUJOCO_DIR} && \
79+ chown -R ${USERNAME}:${USERNAME} ${MUJOCO_DIR} && \
80+ CPU_ARCH=$(uname -m); \
81+ wget https://github.com/google-deepmind/mujoco/releases/download/${MUJOCO_VERSION}/mujoco-${MUJOCO_VERSION}-linux-${CPU_ARCH}.tar.gz && \
82+ tar -xzf "mujoco-${MUJOCO_VERSION}-linux-${CPU_ARCH}.tar.gz" -C $(dirname "${MUJOCO_DIR}" ) && \
83+ rm "mujoco-${MUJOCO_VERSION}-linux-${CPU_ARCH}.tar.gz"
84+
85+ # Install MuJoCo specific pip dependencies at the system level because it's an image
86+ ENV PIP_BREAK_SYSTEM_PACKAGES=1
87+ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
88+ --mount=type=cache,target=/var/lib/apt,sharing=locked \
89+ pip3 install mujoco obj2mjcf trimesh
6690
6791# Setup the install directory and copy the workspace to it.
6892# We could alternatively copy package manifests to preserve the layer cache if the build duration becomes too onerous.
93+ USER ${USERNAME}
6994WORKDIR ${ER4_WS}
70- RUN mkdir src build install log
7195
7296# Copy package manifests for installing rosdeps
7397COPY --chown=${USERNAME}:${USERNAME} --from=package-manifests /src/ ./src
@@ -77,16 +101,16 @@ COPY --chown=${USERNAME}:${USERNAME} --from=package-manifests /src/ ./src
77101# RUN sudo rosdep init && rosdep update --rosdistro ${ROS_DISTRO}
78102RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
79103 --mount=type=cache,target=/var/lib/apt,sharing=locked \
80- source /opt/ros/${ROS_DISTRO}/setup.bash && \
81- apt-get update && \
104+ sudo apt update && \
105+ . /opt/ros/${ROS_DISTRO}/setup.bash && \
82106 rosdep update && \
83107 rosdep install -iy --from-paths src
84108
85109# Install extra ROS deps
86110RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
87111 --mount=type=cache,target=/var/lib/apt,sharing=locked \
88- apt-get update && \
89- apt-get install -q -y \
112+ sudo apt-get update && \
113+ sudo apt-get install -q -y \
90114 ros-${ROS_DISTRO}-ros2controlcli \
91115 ros-${ROS_DISTRO}-rmw-cyclonedds-cpp \
92116 ros-${ROS_DISTRO}-rmw-fastrtps-cpp \
@@ -95,7 +119,7 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
95119# Configure and install MuJoCo using the defaults for the MuJoCo drivers.
96120# We use MuJoCo in many systems so we just install the drivers in the base workspace.
97121# The install is CPU dependent, this works with `x86_64` and `arm64` chips, TBD on others.
98- ARG MUJOCO_VERSION=3.3.4
122+ ARG MUJOCO_VERSION=3.4.0
99123ENV MUJOCO_VERSION=${MUJOCO_VERSION}
100124ENV MUJOCO_DIR="/opt/mujoco/mujoco-${MUJOCO_VERSION}"
101125RUN mkdir -p ${MUJOCO_DIR} && sudo chown -R ${USERNAME}:${USERNAME} ${MUJOCO_DIR}
@@ -107,18 +131,10 @@ RUN CPU_ARCH=$(uname -m); \
107131# Install MuJoCo specific pip dependencies
108132RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
109133 --mount=type=cache,target=/var/lib/apt,sharing=locked \
110- pip install mujoco obj2mjcf
111-
112- # There's no build for arm64 on linux, so just ignore failures here if that's the case
113- RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
114- --mount=type=cache,target=/var/lib/apt,sharing=locked \
115- pip install bpy==4.0.0 --extra-index-url https://download.blender.org/pypi/ || true
134+ pip install mujoco obj2mjcf trimesh pycollada
116135
117136# Copy in the remainder of the src directory
118- COPY src/ src/
119- RUN chown -R ${USERNAME}:${USERNAME} /home/${USERNAME}
120-
121- USER ${USERNAME}
137+ COPY --chown=${USERNAME}:${USERNAME} src/ src/
122138
123139# Setup colcon default mixins and add default settings
124140RUN colcon mixin add default \
@@ -133,16 +149,6 @@ RUN colcon metadata add default \
133149# the required path is available to the python module to load the library.
134150RUN pip3 install pyassimp==4.1.3
135151
136- # Install useful tooling
137- RUN pip3 install ipython
138-
139- # Fix rosdep permissions and ensure sudo while we're at it
140- RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
141- --mount=type=cache,target=/var/lib/apt,sharing=locked \
142- sudo apt update && \
143- . /opt/ros/${ROS_DISTRO}/setup.bash && \
144- rosdep update --rosdistro ${ROS_DISTRO}
145-
146152# copy in configs for different features
147153COPY --chown=${USERNAME}:${USERNAME} config/colcon-defaults.yaml /home/${USERNAME}/.colcon/defaults.yaml
148154COPY --chown=${USERNAME}:${USERNAME} config/terminator_config /home/${USERNAME}/.config/terminator/config
0 commit comments