From 9b60032cbfe08d3c2e0ee8a0e1237388ba13c096 Mon Sep 17 00:00:00 2001 From: Evan Palmer Date: Wed, 11 Oct 2023 22:43:28 -0700 Subject: [PATCH] Cleaned up Dockerfile and added new user entrypoints --- .devcontainer/nvidia/devcontainer.json | 2 +- .docker/Dockerfile | 284 +++++++++---------------- .docker/compose/nouveau-compose.yaml | 22 ++ .docker/compose/nvidia-compose.yaml | 30 +++ .docker/entrypoints/dev.sh | 7 - .docker/entrypoints/sim.sh | 10 +- .dockerignore | 1 + .github/ISSUE_TEMPLATE/config.yml | 2 +- .github/workflows/ci.yaml | 2 +- .github/workflows/docker.yaml | 122 +++++++++++ 10 files changed, 283 insertions(+), 199 deletions(-) create mode 100644 .docker/compose/nouveau-compose.yaml create mode 100644 .docker/compose/nvidia-compose.yaml delete mode 100644 .docker/entrypoints/dev.sh diff --git a/.devcontainer/nvidia/devcontainer.json b/.devcontainer/nvidia/devcontainer.json index ced677ce..3fafb347 100644 --- a/.devcontainer/nvidia/devcontainer.json +++ b/.devcontainer/nvidia/devcontainer.json @@ -6,7 +6,7 @@ "WORKSPACE": "${containerWorkspaceFolder}", "ROS_DISTRO": "rolling" }, - "target": "develop-nvidia" + "target": "desktop-nvidia" }, "remoteUser": "blue", "runArgs": [ diff --git a/.docker/Dockerfile b/.docker/Dockerfile index e5e59147..69768568 100644 --- a/.docker/Dockerfile +++ b/.docker/Dockerfile @@ -1,24 +1,16 @@ -############################################## -# ci: Install core dependencies needed for CI -############################################## ARG ROS_DISTRO=rolling FROM ros:$ROS_DISTRO-ros-base as ci -LABEL maintainer="Evan Palmer" -LABEL maintainer-email="evanp922@gmail.com" - ENV DEBIAN_FRONTEND=noninteractive -WORKDIR /root/ws_blue +WORKDIR /root/ws_blue COPY . src/blue -# Install apt packages +# Install apt packages needed for CI RUN apt-get -q update \ && apt-get -q -y upgrade \ && apt-get -q install --no-install-recommends -y \ git \ - wget \ - curl \ sudo \ clang \ clang-format-14 \ @@ -31,25 +23,6 @@ RUN apt-get -q update \ && apt-get clean -y \ && rm -rf /var/lib/apt/lists/* -# Install the Python requirements that aren't available as rosdeps -RUN python3 -m pip install -r $(pwd)/src/blue/requirements-build.txt - -# Install gstreamer -RUN apt-get -q update \ - && apt-get -q -y upgrade \ - && apt-get -q install --no-install-recommends -y \ - python3-gi \ - gstreamer1.0-tools \ - gir1.2-gstreamer-1.0 \ - gir1.2-gst-plugins-base-1.0 \ - gstreamer1.0-plugins-good \ - gstreamer1.0-plugins-ugly \ - gstreamer1.0-plugins-bad \ - gstreamer1.0-libav \ - && apt-get autoremove -y \ - && apt-get clean -y \ - && rm -rf /var/lib/apt/lists/* - # Install all ROS dependencies RUN apt-get -q update \ && apt-get -q -y upgrade \ @@ -60,6 +33,8 @@ RUN apt-get -q update \ && apt-get clean -y \ && rm -rf /var/lib/apt/lists/* +FROM ci as robot + # Configure a new non-root user ARG USERNAME=blue ARG USER_UID=1000 @@ -69,51 +44,95 @@ RUN groupadd --gid $USER_GID $USERNAME \ && useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \ && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \ && chmod 0440 /etc/sudoers.d/$USERNAME \ + && usermod -a -G dialout $USERNAME \ && echo "source /usr/share/bash-completion/completions/git" >> /home/$USERNAME/.bashrc -# Switch to the non-root user to install MAVROS dependencies +ENV DEBIAN_FRONTEND=noninteractive + +# Switch to the non-root user for the rest of the installation. +# We do this to avoid any conflicts with user permissions USER $USERNAME ENV USER=$USERNAME +# Install some core apt packages +RUN sudo apt-get -q update \ + && sudo apt-get -q -y upgrade \ + && sudo apt-get -q install --no-install-recommends -y \ + lsb-release \ + wget \ + gnupg \ + && sudo apt-get autoremove -y \ + && sudo apt-get clean -y \ + && sudo rm -rf /var/lib/apt/lists/* + # Install MAVROS dependencies WORKDIR /home/$USERNAME RUN wget https://raw.githubusercontent.com/mavlink/mavros/ros2/mavros/scripts/install_geographiclib_datasets.sh \ && chmod +x install_geographiclib_datasets.sh \ && sudo ./install_geographiclib_datasets.sh -# Switch back to root user -USER root -ENV USER=root +# Copy the project over to image +ENV USER_WORKSPACE=/home/$USERNAME/ws_blue +WORKDIR $USER_WORKSPACE +COPY --chown=$USER_UID:$USER_GID . src/blue -################################################################# -# sim: install Gazebo and the tools needed for Gazebo simulation -################################################################# -FROM ci as sim +# Install the Python requirements that aren't available as rosdeps +RUN python3 -m pip install -r $(pwd)/src/blue/requirements-build.txt + +# Install gstreamer +RUN sudo apt-get -q update \ + && sudo apt-get -q -y upgrade \ + && sudo apt-get -q install --no-install-recommends -y \ + python3-gi \ + gstreamer1.0-tools \ + gir1.2-gstreamer-1.0 \ + gir1.2-gst-plugins-base-1.0 \ + gstreamer1.0-plugins-good \ + gstreamer1.0-plugins-ugly \ + gstreamer1.0-plugins-bad \ + gstreamer1.0-libav \ + && sudo apt-get autoremove -y \ + && sudo apt-get clean -y \ + && sudo rm -rf /var/lib/apt/lists/* + +# Install all ROS dependencies +RUN sudo apt-get -q update \ + && sudo apt-get -q -y upgrade \ + && rosdep update \ + && rosdep install -y --from-paths src --ignore-src --rosdistro ${ROS_DISTRO} \ + && sudo apt-get autoremove -y \ + && sudo apt-get clean -y \ + && sudo rm -rf /var/lib/apt/lists/* + +# Setup the environment variables +RUN echo "source ${USER_WORKSPACE}/install/setup.bash" >> /home/$USERNAME/.bashrc \ + && echo "source /opt/ros/${ROS_DISTRO}/setup.bash" >> /home/$USERNAME/.bashr + +FROM robot as desktop + +ENV DEBIAN_FRONTEND=noninteractive +ENV GZ_VERSION=garden # Install Gazebo Garden: https://gazebosim.org/docs/garden/install_ubuntu -RUN wget https://packages.osrfoundation.org/gazebo.gpg -O /usr/share/keyrings/pkgs-osrf-archive-keyring.gpg -RUN echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/pkgs-osrf-archive-keyring.gpg] http://packages.osrfoundation.org/gazebo/ubuntu-stable $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/gazebo-stable.list > /dev/null -RUN apt-get update \ - && apt-get -y --quiet --no-install-recommends install \ +RUN sudo wget https://packages.osrfoundation.org/gazebo.gpg -O /usr/share/keyrings/pkgs-osrf-archive-keyring.gpg \ + && echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/pkgs-osrf-archive-keyring.gpg] http://packages.osrfoundation.org/gazebo/ubuntu-stable $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/gazebo-stable.list > /dev/null \ + && sudo apt-get update \ + && sudo apt-get -y --quiet --no-install-recommends install \ gz-garden \ - && apt-get autoremove -y \ - && apt-get clean -y \ - && rm -rf /var/lib/apt/lists/* + && sudo apt-get autoremove -y \ + && sudo apt-get clean -y \ + && sudo rm -rf /var/lib/apt/lists/* # Install ArduPilot and ardupilot_gazebo dependencies -RUN apt-get -q update \ - && apt-get -q -y upgrade \ - && apt-get -q install --no-install-recommends -y \ +RUN sudo apt-get -q update \ + && sudo apt-get -q -y upgrade \ + && sudo apt-get -q install --no-install-recommends -y \ python3-wxgtk4.0 \ rapidjson-dev \ xterm \ - && apt-get autoremove -y \ - && apt-get clean -y \ - && rm -rf /var/lib/apt/lists/* - -# Switch to the non-root user to install ArduSub -USER $USERNAME -ENV USER=$USERNAME + && sudo apt-get autoremove -y \ + && sudo apt-get clean -y \ + && sudo rm -rf /var/lib/apt/lists/* # Clone ArduSub # ArduSub is installed for simulation purposes ONLY @@ -144,152 +163,43 @@ RUN [ "/bin/bash" , "-c" , " \ && cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo \ && make -j4" ] -# Switch back to the root user -USER root -ENV USER=root - -# Extend the ros_entrypoint to source the simulation environment -COPY .docker/entrypoints/sim.sh / -RUN sed -i '/source "\/opt\/ros\/$ROS_DISTRO\/setup\.bash" --/a source /sim.sh' /ros_entrypoint.sh - -################################################## -# deps: Install all external project dependencies -################################################## -FROM sim as deps - -ENV GZ_VERSION=garden -ENV USER_WORKSPACE=/home/$USERNAME/ws_blue/install -ENV DEBIAN_FRONTEND=noninteractive -WORKDIR $USER_WORKSPACE/.. - -COPY blue.repos src/ - -RUN apt-get -q update \ - && apt-get -q -y upgrade \ - && vcs import src < src/blue.repos \ - && rosdep update \ - && rosdep install -y --from-paths src --ignore-src --rosdistro ${ROS_DISTRO} --as-root=apt:false --skip-keys="gz-transport12 gz-sim7 gz-math7 gz-msgs9 gz-plugin2" \ - && apt-get autoremove -y \ - && apt-get clean -y \ - && rm -rf /var/lib/apt/lists/* - -RUN . "/opt/ros/${ROS_DISTRO}/setup.sh" \ - && colcon build \ - # Update /ros_entrypoint.sh to source the workspace - && sed -i "s#/opt/ros/\$ROS_DISTRO/setup.bash#$USER_WORKSPACE/setup.sh#g" /ros_entrypoint.sh \ - && echo "source ${USER_WORKSPACE}/setup.sh" >> /home/$USERNAME/.bashrc - -#################################################### -# develop: Setup the image for development purposes -#################################################### -FROM deps as develop - -ENV GZ_VERSION=garden -ENV ROS_UNDERLAY /root/ws_blue/install -ENV DEBIAN_FRONTEND=noninteractive -WORKDIR $ROS_UNDERLAY/.. - -COPY . src/blue - -# Install debugging/linting Python packages -RUN python3 -m pip install -r $(pwd)/src/blue/requirements-dev.txt - -RUN apt-get -q update \ - && apt-get -q -y upgrade \ +# Install Gazebo +WORKDIR $USER_WORKSPACE +RUN sudo apt-get -q update \ + && sudo apt-get -q -y upgrade \ && vcs import src < src/blue/blue.repos \ && rosdep update \ - && rosdep install -y --from-paths src --ignore-src --rosdistro ${ROS_DISTRO} --as-root=apt:false --skip-keys="gz-transport12 gz-sim7 gz-math7 gz-msgs9" \ - && rm -rf src \ - && apt-get autoremove -y \ - && apt-get clean -y \ - && rm -rf /var/lib/apt/lists/* - -# Install development tools -RUN apt-get -q update \ - && apt-get -q -y upgrade \ - && apt-get -q install --no-install-recommends -y \ - iputils-ping \ - net-tools \ - gdb \ - nano \ - && apt-get autoremove -y \ - && apt-get clean -y \ - && rm -rf /var/lib/apt/lists/* - -COPY .docker/entrypoints/dev.sh / - -# WARNING: This is a temporary solution for disabling the setuputils installation warning -ENV PYTHONWARNINGS="ignore" - -ARG WORKSPACE -RUN echo "if [ -f ${WORKSPACE}/install/setup.bash ]; then source ${WORKSPACE}/install/setup.bash; fi" >> /home/$USERNAME/.bashrc \ - && echo "if [ -f /opt/ros/${ROS_DISTRO}/setup.bash ]; then source /opt/ros/${ROS_DISTRO}/setup.bash; fi" >> /home/$USERNAME/.bashrc \ - # Expose the environment variables to the non-root user - && echo "if [ -f /sim.sh ]; then source /sim.sh; fi" >> /home/$USERNAME/.bashrc \ - && echo "if [ -f /dev.sh ]; then source /dev.sh; fi" >> /home/$USERNAME/.bashrc + && rosdep install -y --from-paths src --ignore-src --rosdistro ${ROS_DISTRO} --skip-keys="gz-transport12 gz-sim7 gz-math7 gz-msgs9 gz-plugin2" \ + && sudo apt-get autoremove -y \ + && sudo apt-get clean -y \ + && sudo rm -rf /var/lib/apt/lists/* + +# For users that build this on a laptop or system with limited RAM, +# Modify the 'colcon build' line to be 'MAKEFLAGS="-j1 -l1" colcon build' +# This will limit the amount of RAM that colcon is allowed to use +RUN . "/opt/ros/${ROS_DISTRO}/setup.sh" \ + && colcon build +# Setup the simulation environment variables +RUN echo "source ${USER_WORKSPACE}/src/blue/.docker/entrypoints/sim.sh" >> /home/$USERNAME/.bashrc -###################################################################################### -# develop-nvidia: Setup the image for development purposes with NVIDIA driver support -###################################################################################### -FROM deps as develop-nvidia +FROM desktop as desktop-nvidia # Install NVIDIA software -RUN apt-get update \ - && apt-get install -y -qq --no-install-recommends \ +RUN sudo apt-get update \ + && sudo apt-get -q -y upgrade \ + && sudo apt-get install -y -qq --no-install-recommends \ libglvnd0 \ libgl1 \ libglx0 \ libegl1 \ libxext6 \ - libx11-6 + libx11-6 \ + && sudo apt-get autoremove -y \ + && sudo apt-get clean -y \ + && sudo rm -rf /var/lib/apt/lists/* # Env vars for the nvidia-container-runtime. ENV NVIDIA_VISIBLE_DEVICES all ENV NVIDIA_DRIVER_CAPABILITIES graphics,utility,compute ENV QT_X11_NO_MITSHM 1 - -ENV GZ_VERSION=garden -ENV ROS_UNDERLAY /root/ws_blue/install -ENV DEBIAN_FRONTEND=noninteractive -WORKDIR $ROS_UNDERLAY/.. - -COPY . src/blue - -# Install debugging/linting Python packages -RUN python3 -m pip install -r $(pwd)/src/blue/requirements-dev.txt - -RUN apt-get -q update \ - && apt-get -q -y upgrade \ - && vcs import src < src/blue/blue.repos \ - && rosdep update \ - && rosdep install -y --from-paths src --ignore-src --rosdistro ${ROS_DISTRO} --as-root=apt:false --skip-keys="gz-transport12 gz-sim7 gz-math7 gz-msgs9 gz-plugin2" \ - && rm -rf src \ - && apt-get autoremove -y \ - && apt-get clean -y \ - && rm -rf /var/lib/apt/lists/* - -# Install development tools -RUN apt-get -q update \ - && apt-get -q -y upgrade \ - && apt-get -q install --no-install-recommends -y \ - iputils-ping \ - net-tools \ - gdb \ - nano \ - htop \ - && apt-get autoremove -y \ - && apt-get clean -y \ - && rm -rf /var/lib/apt/lists/* - -COPY .docker/entrypoints/dev.sh / - -# WARNING: This is a temporary solution for disabling the setuputils installation warning -ENV PYTHONWARNINGS="ignore" - -ARG WORKSPACE -RUN echo "if [ -f ${WORKSPACE}/install/setup.bash ]; then source ${WORKSPACE}/install/setup.bash; fi" >> /home/$USERNAME/.bashrc \ - && echo "if [ -f /opt/ros/${ROS_DISTRO}/setup.bash ]; then source /opt/ros/${ROS_DISTRO}/setup.bash; fi" >> /home/$USERNAME/.bashrc \ - # Expose the environment variables to the non-root user - && echo "if [ -f /sim.sh ]; then source /sim.sh; fi" >> /home/$USERNAME/.bashrc \ - && echo "if [ -f /dev.sh ]; then source /dev.sh; fi" >> /home/$USERNAME/.bashrc diff --git a/.docker/compose/nouveau-compose.yaml b/.docker/compose/nouveau-compose.yaml new file mode 100644 index 00000000..19d2f46c --- /dev/null +++ b/.docker/compose/nouveau-compose.yaml @@ -0,0 +1,22 @@ +version: "3" +services: + blue: + image: blue + environment: + - DISPLAY=${DISPLAY} + - XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR} + - WAYLAND_DISPLAY=${WAYLAND_DISPLAY} # Can be commented out if not used + - PULSE_SERVER=${PULSE_SERVER} # Can be commented out if not used + network_mode: host + privileged: true + cap_add: + - SYS_PTRACE + security_opt: + - seccomp:unconfined + - apparmor:unconfined + volumes: + - /dev:/dev + - /run/user/1000:/run/user/1000 + command: /bin/bash + stdin_open: true + tty: true diff --git a/.docker/compose/nvidia-compose.yaml b/.docker/compose/nvidia-compose.yaml new file mode 100644 index 00000000..18899e9b --- /dev/null +++ b/.docker/compose/nvidia-compose.yaml @@ -0,0 +1,30 @@ +version: "3" +services: + blue: + image: blue + environment: + - DISPLAY=${DISPLAY} + - XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR} + - LIBGL_ALWAYS_SOFTWARE=1 + - QT_X11_NO_MITSHM=1 + # - WAYLAND_DISPLAY=${WAYLAND_DISPLAY} # Can be commented out if not used + # - PULSE_SERVER=${PULSE_SERVER} # Can be commented out if not used + network_mode: host + privileged: true + cap_add: + - SYS_PTRACE + security_opt: + - seccomp:unconfined + - apparmor:unconfined + deploy: + resources: + reservations: + devices: + - driver: nvidia + count: 1 + capabilities: [gpu] + volumes: + - /dev:/dev + - /tmp/.X11-unix:/tmp/.X11-unix + - /mnt/wslg:/mnt/wslg + command: tail -f /dev/null diff --git a/.docker/entrypoints/dev.sh b/.docker/entrypoints/dev.sh deleted file mode 100644 index 45d71167..00000000 --- a/.docker/entrypoints/dev.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash - -# Add blue models and worlds -export GZ_SIM_RESOURCE_PATH=/workspaces/blue/blue_description/gazebo/models:/workspaces/blue/blue_description/gazebo/worlds:$GZ_SIM_RESOURCE_PATH - -# Add blue meshes -export GZ_SIM_RESOURCE_PATH=/workspaces/blue/blue_description/meshes:$GZ_SIM_RESOURCE_PATH diff --git a/.docker/entrypoints/sim.sh b/.docker/entrypoints/sim.sh index c2fe9b80..85b3946b 100644 --- a/.docker/entrypoints/sim.sh +++ b/.docker/entrypoints/sim.sh @@ -9,8 +9,14 @@ export PATH=$HOME/ardupilot/Tools/autotest:$PATH # Add ardupilot_gazebo plugin export GZ_SIM_SYSTEM_PLUGIN_PATH=$HOME/ardupilot_gazebo/build:$GZ_SIM_SYSTEM_PLUGIN_PATH -# Optional: add ardupilot_gazebo models and worlds +# Add ardupilot_gazebo models and worlds export GZ_SIM_RESOURCE_PATH=$HOME/ardupilot_gazebo/models:$HOME/ardupilot_gazebo/worlds:$GZ_SIM_RESOURCE_PATH -# Build ros_gz on the humble branch for Gazebo Garden +# Add blue models and worlds +export GZ_SIM_RESOURCE_PATH=$HOME/ws_blue/src/blue/blue_description/gazebo/models:$HOME/ws_blue/src/blue/blue_description/gazebo/worlds:$GZ_SIM_RESOURCE_PATH + +# Add blue meshes +export GZ_SIM_RESOURCE_PATH=$HOME/ws_blue/src/blue/blue_description/meshes:$GZ_SIM_RESOURCE_PATH + +# Build ros_gz for Gazebo Garden export GZ_VERSION=garden diff --git a/.dockerignore b/.dockerignore index c59c0f0b..97eedc18 100644 --- a/.dockerignore +++ b/.dockerignore @@ -9,6 +9,7 @@ !blue_localization !blue_utils !blue_joy +!blue_description !blue.repos !.docker/entrypoints !requirements-build.txt diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index f3af57f3..3f1d9873 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,5 +1,5 @@ blank_issues_enabled: false contact_links: - - name: BlueROV2 Driver Community Support + - name: Blue Community Support url: https://github.com/Robotic-Decision-Making-Lab/blue/discussions about: Please check out our discussions channel for any questions related to the project! diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 79237e59..4e4c3bb7 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -41,7 +41,7 @@ jobs: - name: Run ROS Industrial CI uses: ros-industrial/industrial_ci@master env: - DOCKER_IMAGE: ghcr.io/Robotic-Decision-Making-Lab/blue:${{ matrix.env.IMAGE }} + DOCKER_IMAGE: ghcr.io/robotic-decision-making-lab/blue:${{ matrix.env.IMAGE }} CXXFLAGS: >- -Wall -Wextra -Wpedantic -Wwrite-strings -Wunreachable-code -Wpointer-arith -Wredundant-decls CC: ${{ env.CLANG_TIDY && 'clang' }} diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 3ce46aa3..5fff53d6 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -6,6 +6,7 @@ on: push: branches: - main + - 120-feature-cleanup-dockerfile pull_request: paths: - .docker/** @@ -56,3 +57,124 @@ jobs: tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} push: ${{ env.PUSH }} + robot: + strategy: + fail-fast: false + matrix: + ROS_DISTRO: [humble, iron, rolling] + runs-on: ubuntu-latest + permissions: + packages: write + contents: read + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Log into registry + if: env.PUSH == 'true' + uses: docker/login-action@v3.0.0 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract Docker metadata + if: env.PUSH == 'true' + id: meta + uses: docker/metadata-action@v4.6.0 + with: + images: ghcr.io/${{ github.repository }} + tags: | + type=raw,value=${{ matrix.ROS_DISTRO }}-${{ github.job }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5.0.0 + with: + context: . + file: .docker/Dockerfile + build-args: ROS_DISTRO=${{ matrix.ROS_DISTRO }} + target: ${{ github.job }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + push: ${{ env.PUSH }} + platforms: linux/amd64,linux/arm64 + desktop: + strategy: + fail-fast: false + matrix: + ROS_DISTRO: [humble, iron, rolling] + runs-on: ubuntu-latest + permissions: + packages: write + contents: read + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Log into registry + if: env.PUSH == 'true' + uses: docker/login-action@v3.0.0 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract Docker metadata + if: env.PUSH == 'true' + id: meta + uses: docker/metadata-action@v4.6.0 + with: + images: ghcr.io/${{ github.repository }} + tags: | + type=raw,value=${{ matrix.ROS_DISTRO }}-${{ github.job }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5.0.0 + with: + context: . + file: .docker/Dockerfile + build-args: ROS_DISTRO=${{ matrix.ROS_DISTRO }} + target: ${{ github.job }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + push: ${{ env.PUSH }} + desktop-nvidia: + strategy: + fail-fast: false + matrix: + ROS_DISTRO: [humble, iron, rolling] + runs-on: ubuntu-latest + permissions: + packages: write + contents: read + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Log into registry + if: env.PUSH == 'true' + uses: docker/login-action@v3.0.0 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract Docker metadata + if: env.PUSH == 'true' + id: meta + uses: docker/metadata-action@v4.6.0 + with: + images: ghcr.io/${{ github.repository }} + tags: | + type=raw,value=${{ matrix.ROS_DISTRO }}-${{ github.job }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5.0.0 + with: + context: . + file: .docker/Dockerfile + build-args: ROS_DISTRO=${{ matrix.ROS_DISTRO }} + target: ${{ github.job }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + push: ${{ env.PUSH }}