|
| 1 | +# Base Image: https://hub.docker.com/_/ubuntu/tags?name=22.04 |
| 2 | +FROM ubuntu:22.04 AS amd64 |
| 3 | +# Base Image: https://hub.docker.com/_/ubuntu/tags?name=22.04 |
| 4 | +FROM ubuntu:22.04 AS arm64 |
| 5 | + |
| 6 | +# Use docker automatic platform args to select the base image. |
| 7 | +# It may be `arm64` or `amd64` depending on the platform. |
| 8 | +# Ref: https://docs.docker.com/reference/dockerfile/#automatic-platform-args-in-the-global-scope |
| 9 | +FROM $TARGETARCH |
| 10 | +ARG TARGETARCH |
| 11 | + |
| 12 | +# Keep downloaded packages for caching purposes |
| 13 | +# Ref: https://github.com/moby/buildkit/blob/master/frontend/dockerfile/docs/reference.md#example-cache-apt-packages |
| 14 | +RUN rm -f /etc/apt/apt.conf.d/docker-clean; echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache |
| 15 | + |
| 16 | +# Upgrade packages |
| 17 | +# Ref: https://pythonspeed.com/articles/security-updates-in-docker/ |
| 18 | +# Ref: https://github.com/moby/buildkit/blob/master/frontend/dockerfile/docs/reference.md#example-cache-apt-packages |
| 19 | +# Ref: https://github.com/moby/buildkit/issues/1673#issuecomment-1264502398 |
| 20 | +# Ref: https://github.com/moby/buildkit/issues/1673#issuecomment-1987107404 |
| 21 | +RUN --mount=type=cache,target=/var/cache/apt,sharing=private \ |
| 22 | + apt-get update && apt-get upgrade -y \ |
| 23 | + && rm -rf /var/lib/apt/lists/* |
| 24 | + |
| 25 | +# Install common tools |
| 26 | +RUN --mount=type=cache,target=/var/cache/apt,sharing=private \ |
| 27 | + apt-get update && apt-get install -y \ |
| 28 | + curl \ |
| 29 | + git \ |
| 30 | + git-lfs \ |
| 31 | + htop \ |
| 32 | + iputils-ping \ |
| 33 | + jq \ |
| 34 | + nano \ |
| 35 | + net-tools \ |
| 36 | + netcat-openbsd \ |
| 37 | + nmap \ |
| 38 | + p7zip-full \ |
| 39 | + tmux \ |
| 40 | + tree \ |
| 41 | + unzip \ |
| 42 | + vim \ |
| 43 | + wget \ |
| 44 | + zip \ |
| 45 | + && rm -rf /var/lib/apt/lists/* |
| 46 | + |
| 47 | +# Install Python pip |
| 48 | +RUN --mount=type=cache,target=/var/cache/apt,sharing=private \ |
| 49 | + apt-get update && apt-get install -y \ |
| 50 | + python3-pip \ |
| 51 | + && rm -rf /var/lib/apt/lists/* |
| 52 | + |
| 53 | +# ROS version configuration |
| 54 | +ARG ROS_DISTRO=humble |
| 55 | +ENV ROS_DISTRO=$ROS_DISTRO |
| 56 | +# Copy and run ROS installation script |
| 57 | +COPY modules/install_ros.sh /tmp/install_ros.sh |
| 58 | +RUN --mount=type=cache,target=/var/cache/apt,sharing=private \ |
| 59 | + /tmp/install_ros.sh && rm /tmp/install_ros.sh |
| 60 | +# Set the CycloneDDS configuration file |
| 61 | +ENV CYCLONEDDS_URI=/home/user/cyclonedds.xml |
| 62 | + |
| 63 | +# Setup the required capabilities for the container runtime |
| 64 | +# Ref: https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/docker-specialized.html#driver-capabilities |
| 65 | +ENV NVIDIA_VISIBLE_DEVICES=all |
| 66 | +ENV NVIDIA_DRIVER_CAPABILITIES=all |
| 67 | + |
| 68 | +# Install GUI debugging tools and configure Vulkan |
| 69 | +COPY modules/install_x11_opengl_vulkan.sh /tmp/install_x11_opengl_vulkan.sh |
| 70 | +RUN --mount=type=cache,target=/var/cache/apt,sharing=private \ |
| 71 | + /tmp/install_x11_opengl_vulkan.sh && rm /tmp/install_x11_opengl_vulkan.sh |
| 72 | + |
| 73 | +# Install CUDA Toolkit (not installed by default) |
| 74 | +ARG CUDA_TOOLKIT_VERSION="" |
| 75 | +# Copy and run CUDA Toolkit installation script |
| 76 | +COPY modules/install_cuda_toolkit.sh /tmp/install_cuda_toolkit.sh |
| 77 | +RUN --mount=type=cache,target=/var/cache/apt,sharing=private \ |
| 78 | + /tmp/install_cuda_toolkit.sh && rm /tmp/install_cuda_toolkit.sh |
| 79 | +# Ref: https://docs.nvidia.com/cuda/cuda-installation-guide-linux/#post-installation-actions |
| 80 | +ENV PATH="${PATH}:/usr/local/cuda-${CUDA_TOOLKIT_VERSION}/bin" |
| 81 | +ENV LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/usr/local/cuda-${CUDA_TOOLKIT_VERSION}/lib64" |
| 82 | + |
| 83 | +# Arguments for the default user |
| 84 | +ARG USERNAME=user |
| 85 | +ARG USER_UID=1000 |
| 86 | + |
| 87 | +# Install sudo and create a user with sudo privileges |
| 88 | +# Ref: https://stackoverflow.com/a/65434659 |
| 89 | +RUN --mount=type=cache,target=/var/cache/apt,sharing=private \ |
| 90 | + apt-get update && apt-get install -y sudo \ |
| 91 | + && useradd -m -s /bin/bash -u $USER_UID -G sudo $USERNAME \ |
| 92 | + && echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers \ |
| 93 | + && rm -rf /var/lib/apt/lists/* |
| 94 | + |
| 95 | +USER $USERNAME |
| 96 | + |
| 97 | +# Create user bin directories specified in `~/.profile` |
| 98 | +# Together with .bashrc, this allows invoking executables in the same shell after installing to either location |
| 99 | +RUN mkdir /home/$USERNAME/bin |
| 100 | +RUN mkdir -p /home/$USERNAME/.local/bin |
| 101 | + |
| 102 | +# Create cache directories with correct ownership to avoid permission issues after volume mount |
| 103 | +RUN mkdir -p /home/$USERNAME/.cache/pip |
| 104 | +# Create Gazebo cache directory with correct ownership to avoid permission issues after volume mount |
| 105 | +RUN mkdir /home/$USERNAME/.gazebo |
| 106 | + |
| 107 | +# Isaac Sim version configuration |
| 108 | +ARG ISAAC_SIM_VERSION=5.0.0 |
| 109 | +# Ref: https://isaac-sim.github.io/IsaacLab/v2.2.1/source/setup/installation/binaries_installation.html |
| 110 | +ENV ISAACSIM_PATH="/home/$USERNAME/isaacsim" |
| 111 | +# Copy and run Isaac Sim installation script |
| 112 | +COPY --chown=$USERNAME:$USERNAME \ |
| 113 | + modules/install_isaac_sim.sh /tmp/install_isaac_sim.sh |
| 114 | +RUN --mount=type=cache,target=/var/cache/apt,sharing=private \ |
| 115 | + --mount=type=cache,target=/home/$USERNAME/.cache/pip,sharing=private,uid=$USER_UID,gid=$USER_UID \ |
| 116 | + /tmp/install_isaac_sim.sh && rm /tmp/install_isaac_sim.sh |
| 117 | +# Set Isaac Sim environment variables |
| 118 | +# Ref: https://docs.omniverse.nvidia.com/isaacsim/latest/installation/install_python.html#running-isaac-sim |
| 119 | +# Ref: https://github.com/NVIDIA-Omniverse/IsaacSim-dockerfiles/blob/e3c09375c2d110b39c3fab3611352870aa3ce6ee/Dockerfile.2023.1.0-ubuntu22.04#L49-L53 |
| 120 | +ENV OMNI_USER=admin |
| 121 | +ENV OMNI_PASS=admin |
| 122 | +ENV OMNI_KIT_ACCEPT_EULA=YES |
| 123 | +# Ref: https://isaac-sim.github.io/IsaacLab/v2.2.1/source/setup/installation/binaries_installation.html |
| 124 | +ENV ISAACSIM_PYTHON_EXE="${ISAACSIM_PATH}/python.sh" |
| 125 | + |
| 126 | +# Set TERM to prevent Isaac Lab error during docker build: |
| 127 | +# 'ansi+tabs': unknown terminal type. |
| 128 | +ENV TERM=xterm-256color |
| 129 | +# Isaac Lab version configuration |
| 130 | +ARG ISAAC_LAB_VERSION=2.2.1 |
| 131 | +# Ref: https://isaac-sim.github.io/IsaacLab/v2.2.1/source/policy_deployment/00_hover/hover_policy.html |
| 132 | +ENV ISAACLAB_PATH="/home/$USERNAME/IsaacLab" |
| 133 | +COPY --chown=$USERNAME:$USERNAME \ |
| 134 | + modules/install_isaac_lab.sh /tmp/install_isaac_lab.sh |
| 135 | +RUN --mount=type=cache,target=/var/cache/apt,sharing=private \ |
| 136 | + --mount=type=cache,target=/home/$USERNAME/.cache/pip,sharing=private,uid=$USER_UID,gid=$USER_UID \ |
| 137 | + /tmp/install_isaac_lab.sh && rm /tmp/install_isaac_lab.sh |
| 138 | + |
| 139 | +# Isaac ROS version configuration |
| 140 | +ARG ISAAC_ROS="" |
| 141 | +ENV ISAAC_ROS_WS="/home/$USERNAME/workspaces/isaac_ros-dev/" |
| 142 | +# Copy and run Isaac ROS installation script |
| 143 | +COPY --chown=$USERNAME:$USERNAME \ |
| 144 | + modules/install_isaac_ros.sh /tmp/install_isaac_ros.sh |
| 145 | +RUN --mount=type=cache,target=/var/cache/apt,sharing=private \ |
| 146 | + /tmp/install_isaac_ros.sh && rm /tmp/install_isaac_ros.sh |
| 147 | +# Ref: https://nvidia-isaac-ros.github.io/getting_started/dev_env_setup.html |
| 148 | + |
| 149 | +# Install custom tools |
| 150 | +RUN --mount=type=cache,target=/var/cache/apt,sharing=private \ |
| 151 | + sudo apt-get update && sudo apt-get install -y \ |
| 152 | + git-extras \ |
| 153 | + && sudo rm -rf /var/lib/apt/lists/* |
| 154 | + |
| 155 | +# Cartographer configuration |
| 156 | +ARG CARTOGRAPHER="" |
| 157 | +COPY --chown=$USERNAME:$USERNAME \ |
| 158 | + modules/install_cartographer.sh /tmp/install_cartographer.sh |
| 159 | +RUN --mount=type=cache,target=/var/cache/apt,sharing=private \ |
| 160 | + /tmp/install_cartographer.sh && rm /tmp/install_cartographer.sh |
| 161 | + |
| 162 | +# rtabmap configuration |
| 163 | +ARG RTABMAP="" |
| 164 | +COPY --chown=$USERNAME:$USERNAME \ |
| 165 | + modules/install_rtabmap.sh /tmp/install_rtabmap.sh |
| 166 | +RUN --mount=type=cache,target=/var/cache/apt,sharing=private \ |
| 167 | + /tmp/install_rtabmap.sh && rm /tmp/install_rtabmap.sh |
| 168 | + |
| 169 | +# TODO: Add more commands here |
| 170 | +COPY --chown=$USERNAME:$USERNAME \ |
| 171 | + .bashrc /home/$USERNAME/.bashrc |
| 172 | +# TODO: Copy additional files here |
| 173 | +ENTRYPOINT [] |
| 174 | +CMD ["/bin/bash"] |
0 commit comments