diff --git a/.github/workflows/_build-image.yaml b/.github/workflows/_build-image.yaml index 23832aa..80c2ebd 100644 --- a/.github/workflows/_build-image.yaml +++ b/.github/workflows/_build-image.yaml @@ -46,6 +46,9 @@ jobs: username: ${{ secrets.LCAS_REGISTRY_PUSHER }} password: ${{ secrets.LCAS_REGISTRY_TOKEN }} + - name: Pull base image + run: docker pull ${{ inputs.base_image }} + - name: Docker meta id: meta uses: docker/metadata-action@v5 @@ -79,4 +82,4 @@ jobs: labels: ${{ steps.meta.outputs.labels }} build-args: | BASE_IMAGE=${{ inputs.base_image }} - ROS_DISTRO=${{ inputs.ros_distro }} \ No newline at end of file + ROS_DISTRO=${{ inputs.ros_distro }} diff --git a/.github/workflows/docker-build-and-push.yaml b/.github/workflows/docker-build-and-push.yaml index f2c6942..407675f 100644 --- a/.github/workflows/docker-build-and-push.yaml +++ b/.github/workflows/docker-build-and-push.yaml @@ -37,7 +37,7 @@ jobs: with: base_image: nvidia/cuda:11.8.0-runtime-ubuntu22.04 push_image: ros_cuda - ros_distro: humble + ros_distro: humble dockerfile: cuda.dockerfile architectures: linux/amd64 secrets: inherit @@ -45,7 +45,7 @@ jobs: ros-cuda-jazzy: uses: ./.github/workflows/_build-image.yaml with: - base_image: nvidia/cuda:12.6.3-cudnn-devel-ubuntu24.04 + base_image: nvidia/cuda:12.9.1-runtime-ubuntu24.04 push_image: ros_cuda ros_distro: jazzy dockerfile: cuda.dockerfile diff --git a/base.dockerfile b/base.dockerfile index 9eda8c9..1e9ead5 100644 --- a/base.dockerfile +++ b/base.dockerfile @@ -10,16 +10,23 @@ ENV ROS_DISTRO=${ROS_DISTRO} ENV DEBIAN_FRONTEND=noninteractive -RUN apt-get update && apt-get upgrade -y && apt-get install -y \ +RUN apt-get update \ + && apt-get upgrade -y && \ + apt-get install -y --no-install-recommends \ build-essential \ + ca-certificates \ + gnupg \ cmake \ git \ curl \ wget \ unzip \ ros-${ROS_DISTRO}-ros-base \ - python3-colcon-common-extensions \ - && rm -rf /var/lib/apt/lists/* + ros-${ROS_DISTRO}-rmw-cyclonedds-cpp \ + python3-colcon-common-extensions && \ + rm -rf /var/lib/apt/lists/* + +ENV LANG=en_US.UTF-8 RUN . /opt/ros/${ROS_DISTRO}/setup.sh && rosdep update @@ -27,22 +34,30 @@ ARG USERNAME=ros ARG USER_UID=1001 ARG USER_GID=$USER_UID -# Create a non-root user +# Create a non-root user and add sudo support for the non-root user RUN groupadd --gid $USER_GID $USERNAME \ - && useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \ - # Add sudo support for the non-root user - && apt-get update \ - && apt-get install -y --no-install-recommends sudo \ - && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME\ - && chmod 0440 /etc/sudoers.d/$USERNAME \ - && rm -rf /var/lib/apt/lists/* + && useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \ + && apt-get update \ + && apt-get install -y --no-install-recommends sudo \ + && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME\ + && chmod 0440 /etc/sudoers.d/$USERNAME \ + && rm -rf /var/lib/apt/lists/* + +# Cyclone DDS Config +COPY cyclonedds.xml /etc/cyclonedds.xml # Configure bash profile RUN echo "if [ -f /etc/bash.bashrc ]; then source /etc/bash.bashrc; fi" >> /root/.bashrc && \ + echo "if [ -f /etc/bash.bashrc ]; then source /etc/bash.bashrc; fi" >> /home/${USERNAME}/.bashrc && \ echo 'PS1="${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ "' >> /etc/bash.bashrc && \ echo "source /opt/ros/${ROS_DISTRO}/setup.bash" >> /etc/bash.bashrc && \ echo "alias t='tmux'" >> /etc/bash.bashrc && \ - echo "alias cls='clear'" >> /etc/bash.bashrc + echo "alias cls='clear'" >> /etc/bash.bashrc && \ + chown ${USERNAME}:${USER_GID} /home/${USERNAME}/.bashrc + +ENV RMW_IMPLEMENTATION=rmw_cyclonedds_cpp +ENV CYCLONEDDS_URI=file:///etc/cyclonedds.xml +USER ${USERNAME} CMD ["bash", "-l"] diff --git a/cuda.dockerfile b/cuda.dockerfile index 3093ba2..0a4e2ec 100644 --- a/cuda.dockerfile +++ b/cuda.dockerfile @@ -11,26 +11,25 @@ ENV ROS_DISTRO=${ROS_DISTRO} ENV DEBIAN_FRONTEND=noninteractive -# Install language -RUN apt-get update ; \ - apt-get upgrade -y && \ - apt-get install -y --no-install-recommends \ +RUN apt-get update \ + && apt-get upgrade -y \ + && apt-get install -y --no-install-recommends \ locales \ curl \ + wget \ + ca-certificates \ gnupg2 \ lsb-release \ git \ nano \ python3-setuptools \ software-properties-common \ - wget \ tzdata \ && locale-gen en_US.UTF-8 \ && update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 \ && rm -rf /var/lib/apt/lists/* -ENV LANG=en_US.UTF-8 -RUN curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg +ENV LANG=en_US.UTF-8 # Prepare ROS2 RUN add-apt-repository universe \ @@ -40,8 +39,12 @@ RUN add-apt-repository universe \ RUN apt-get update && apt-get install -y --no-install-recommends \ ros-${ROS_DISTRO}-ros-base \ python3-rosdep \ + ros-${ROS_DISTRO}-rmw-cyclonedds-cpp \ && rm -rf /var/lib/apt/lists/* +# Cyclone DDS Config +COPY cyclonedds.xml /etc/cyclonedds.xml + RUN . /opt/ros/${ROS_DISTRO}/setup.sh && rosdep init && rosdep update # Setup VirtualGL @@ -65,11 +68,15 @@ RUN groupadd --gid $USER_GID $USERNAME \ # Configure bash profile RUN echo "if [ -f /etc/bash.bashrc ]; then source /etc/bash.bashrc; fi" >> /root/.bashrc && \ + echo "if [ -f /etc/bash.bashrc ]; then source /etc/bash.bashrc; fi" >> /home/${USERNAME}/.bashrc && \ + chown ${USERNAME}:${USERNAME} /home/${USERNAME}/.bashrc && \ echo 'PS1="${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ "' >> /etc/bash.bashrc && \ echo "source /opt/ros/${ROS_DISTRO}/setup.bash" >> /etc/bash.bashrc && \ echo "alias t='tmux'" >> /etc/bash.bashrc && \ echo "alias cls='clear'" >> /etc/bash.bashrc - + +ENV RMW_IMPLEMENTATION=rmw_cyclonedds_cpp +ENV CYCLONEDDS_URI=file:///etc/cyclonedds.xml ENV TVNC_VGL=1 ENV VGL_ISACTIVE=1 ENV VGL_FPS=25 @@ -80,5 +87,6 @@ ENV VGL_PROBEGLX=0 ENV LD_PRELOAD=/usr/lib/libdlfaker.so:/usr/lib/libvglfaker.so ENV SHELL=/bin/bash -CMD ["bash", "-l"] +USER ${USERNAME} +CMD ["bash", "-l"] diff --git a/cuda_desktop.dockerfile b/cuda_desktop.dockerfile index 9e36983..30e7907 100644 --- a/cuda_desktop.dockerfile +++ b/cuda_desktop.dockerfile @@ -1,8 +1,8 @@ -ARG BASE_IMAGE +ARG BASE_IMAGE=lcas.lincoln.ac.uk/ros_cuda:humble-main ########################################### FROM ${BASE_IMAGE} AS base -RUN apt-get update && apt-get install -y --no-install-recommends \ +RUN sudo apt-get update && sudo apt-get install -y --no-install-recommends \ ros-${ROS_DISTRO}-desktop \ - && rm -rf /var/lib/apt/lists/* + && sudo rm -rf /var/lib/apt/lists/* diff --git a/docker/cyclonedds.xml b/docker/cyclonedds.xml new file mode 100644 index 0000000..82132ff --- /dev/null +++ b/docker/cyclonedds.xml @@ -0,0 +1,10 @@ + + + + true + + + auto + + + \ No newline at end of file