From 4fbf4d8f180d1b39e782ae3b102a0e9c20e12913 Mon Sep 17 00:00:00 2001 From: vortex <--global> Date: Sun, 24 Sep 2023 19:14:35 +0200 Subject: [PATCH] Added arm64 cockerfile and changed names of both dockerfiles --- .github/workflows/docker-publish.yml | 67 ++++++++++++++++++++++++++++ Dockerfile.ros2 | 45 ++----------------- Dockerfile.ros2-cuda | 46 +++++++++++++++++++ 3 files changed, 116 insertions(+), 42 deletions(-) create mode 100644 .github/workflows/docker-publish.yml create mode 100644 Dockerfile.ros2-cuda diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml new file mode 100644 index 0000000..cabc085 --- /dev/null +++ b/.github/workflows/docker-publish.yml @@ -0,0 +1,67 @@ +name: Publish Docker image to ghcr + +on: + push: + branches: [ main ] + workflow_dispatch: + + pull_request: + types: [opened, reopened] + branches: [ main ] + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + architecture: + - amd64 + - arm64 + filename: + - ros2 + - ros2-cuda + + permissions: + contents: read + packages: write + + steps: + - name: Checkout own repository + uses: actions/checkout@v4 + + - name: Set up QEMU + if: matrix.architecture != 'amd64' + uses: docker/setup-qemu-action@v3 + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-${{ matrix.filename }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.${{ matrix.filename }} + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-${{ matrix.filename }}:${{ matrix.architecture }}-latest + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + platforms: linux/amd64,linux/arm64 diff --git a/Dockerfile.ros2 b/Dockerfile.ros2 index 1f4ed6e..fd81bc1 100644 --- a/Dockerfile.ros2 +++ b/Dockerfile.ros2 @@ -1,46 +1,7 @@ -FROM nvidia/cuda:12.2.0-base-ubuntu22.04 - -ENV TZ=Europe -RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone - -# Install necessary software for the installation of ROS2 -RUN apt-get update && apt-get install -y \ - locales \ - curl \ - gnupg2 \ - lsb-release \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/*rm - -# install packages -RUN apt-get update || true && apt-get install -q -y --no-install-recommends \ - bash-completion \ - dirmngr \ - gnupg2 \ - lsb-release \ - python3-pip \ - && rm -rf /var/lib/apt/lists/* - -# install ros2 humble base - -RUN apt-get update - -RUN apt install software-properties-common -y -RUN add-apt-repository universe - -RUN apt update && apt install curl -y -RUN curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg - -RUN echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | tee /etc/apt/sources.list.d/ros2.list > /dev/null - -RUN apt update && apt upgrade -y - -RUN apt install -y ros-humble-ros-base \ - python3-colcon-common-extensions \ - python3-rosdep \ - python3-argcomplete \ - && rm -rf /var/lib/apt/lists/*rm +FROM ros:humble # add sourcing to shell startup script RUN echo "source /opt/ros/humble/setup.bash" >> ~/.bashrc + +# diff --git a/Dockerfile.ros2-cuda b/Dockerfile.ros2-cuda new file mode 100644 index 0000000..1f4ed6e --- /dev/null +++ b/Dockerfile.ros2-cuda @@ -0,0 +1,46 @@ +FROM nvidia/cuda:12.2.0-base-ubuntu22.04 + +ENV TZ=Europe +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone + +# Install necessary software for the installation of ROS2 +RUN apt-get update && apt-get install -y \ + locales \ + curl \ + gnupg2 \ + lsb-release \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/*rm + +# install packages +RUN apt-get update || true && apt-get install -q -y --no-install-recommends \ + bash-completion \ + dirmngr \ + gnupg2 \ + lsb-release \ + python3-pip \ + && rm -rf /var/lib/apt/lists/* + +# install ros2 humble base + +RUN apt-get update + +RUN apt install software-properties-common -y +RUN add-apt-repository universe + +RUN apt update && apt install curl -y +RUN curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg + +RUN echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | tee /etc/apt/sources.list.d/ros2.list > /dev/null + +RUN apt update && apt upgrade -y + +RUN apt install -y ros-humble-ros-base \ + python3-colcon-common-extensions \ + python3-rosdep \ + python3-argcomplete \ + && rm -rf /var/lib/apt/lists/*rm + +# add sourcing to shell startup script + +RUN echo "source /opt/ros/humble/setup.bash" >> ~/.bashrc