services:ros:build:context:.dockerfile:.devcontainer/Dockerfileuser:"user"volumes:-.:/workspace:cached-/tmp/.X11-unix:/tmp/.X11-unix:rw# - .gazebo:/home/user/.gazebo:cached -/dev/dri:/dev/dri# keep for OpenGL contextdeploy:resources:reservations:devices:-driver:nvidia# explicitly use NVIDIA runtimecount:allcapabilities:[gpu]hostname:rosextra_hosts:-"ros:127.0.0.1"network_mode:hoststdin_open:truetty:trueenvironment:-DISPLAY=${DISPLAY}-QT_X11_NO_MITSHM=1-NVIDIA_VISIBLE_DEVICES=all-NVIDIA_DRIVER_CAPABILITIES=all-__NV_PRIME_RENDER_OFFLOAD=1# Even though NVIDIA is not the primary GPU, allow this process to render on the NVIDIA GPU.”-__GLX_VENDOR_LIBRARY_NAME=nvidia# “Use the NVIDIA GLX implementation (libGLX_nvidia.so) instead of Mesa.”-XDG_RUNTIME_DIR=/tmp/runtime-userruntime:nvidia
FROMros2_rust_dev:latestARGUSERNAME=user
ARGUSER_UID=1000ARGUSER_GID=$USER_UID# Check if "ubuntu" user exists, delete it if it does, then create the desired userRUNifgetentpasswdubuntu>/dev/null2>&1;then\userdel-rubuntu&&\echo"Deleted existing ubuntu user";\fi&&\groupadd--gid$USER_GID$USERNAME&&\useradd-s/bin/bash--uid$USER_UID--gid$USER_GID-m$USERNAME&&\echo"Created new user $USERNAME"# Add sudo support for the non-root userRUNapt-getupdate&&apt-getinstall-ysudo\&&echo$USERNAMEALL=\(root\)NOPASSWD:ALL>/etc/sudoers.d/$USERNAME\&&chmod0440/etc/sudoers.d/$USERNAME\&&rm-rf/var/lib/apt/lists/*
# Set up autocompletion for userRUNapt-getupdate&&apt-getinstall-y--no-install-recommendsgit-corebash-completion\&&echo"if [ -f /opt/ros/${ROS_DISTRO}/setup.bash ]; then source /opt/ros/${ROS_DISTRO}/setup.bash; fi">>/home/$USERNAME/.bashrc\&&echo"if [ -f /usr/share/colcon_argcomplete/hook/colcon-argcomplete.bash ]; then source /usr/share/colcon_argcomplete/hook/colcon-argcomplete.bash; fi">>/home/$USERNAME/.bashrc\&&rm-rf/var/lib/apt/lists/*
# Install RustUSERuserRUNcurl--proto'=https'--tlsv1.2-sSfhttps://sh.rustup.rs|sh-s----default-toolchain1.85.0-y
ENVPATH=/home/user/.cargo/bin:$PATH