Skip to content

Commit

Permalink
Enhance Docker build process and multi-platform support (#18)
Browse files Browse the repository at this point in the history
* syntax fixes

* fix: update nvidia.dockerfile to create a virtual environment in /opt/venv

* fix to make smaller:
disable VSCode and zrok installation in nvidia.dockerfile

* fix: streamline Docker build workflow by consolidating build jobs and adding multi-platform support

* fix: update Docker image description to include multiarch support

* fix: disable fail-fast in Docker build workflow for improved job execution

* update Dockerfile and workflows

for improved image building and multi-platform support, based on new desktop image

* fix: add descriptive names to Docker build jobs for clarity

* fix: enhance Docker build job names for better context and update image naming convention

* fix: use force option for symbolic links in Dockerfile to avoid errors
  • Loading branch information
marc-hanheide authored Jan 10, 2025
1 parent 11ad564 commit 43ecef3
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 377 deletions.
130 changes: 16 additions & 114 deletions .github/workflows/docker-build-opengl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,21 @@ on:
workflow_dispatch:

jobs:
build-amd64:
build:
name: Build ${{ matrix.push_tag }} OpenGL Desktop Images (${{ github.event_name }} by ${{ github.actor }})
runs-on:
- lcas
- cuda
strategy:
fail-fast: false
matrix:
include:
# - base_image: ubuntu:jammy
# ros_distro: humble
# push_tag: jammy-humble
# - base_image: nvidia/cuda:11.8.0-cudnn8-devel-ubuntu22.04
# ros_distro: humble
# push_tag: jammy-humble-cuda11.8-opengl
# - base_image: nvidia/cuda:12.1.1-cudnn8-devel-ubuntu22.04
# ros_distro: humble
# push_tag: jammy-humble-cuda12.1-opengl
- base_image: nvidia/cuda:12.2.2-cudnn8-devel-ubuntu22.04
- base_image: lcas.lincoln.ac.uk/lcas/docker_cuda_desktop:jammy-cuda12.2-1
ros_distro: humble
push_tag: jammy-humble-cuda12.2-opengl
push_tag: jammy-cuda12.2-humble

- base_image: nvidia/cuda:12.6.2-cudnn-devel-ubuntu22.04
ros_distro: humble
push_tag: jammy-humble-cuda12.6-opengl

- base_image: nvidia/cuda:12.6.3-cudnn-devel-ubuntu24.04
- base_image: lcas.lincoln.ac.uk/lcas/docker_cuda_desktop:noble-cuda12.6-1
ros_distro: rolling
push_tag: noble-rolling-cuda12.6-opengl
push_tag: noble-cuda12.6-rolling

steps:
- name: Node Js
Expand All @@ -49,96 +37,7 @@ jobs:
- uses: actions/checkout@v3
- name: What
run: echo "BRANCH=${GITHUB_REF##*/}" >> $GITHUB_ENV
- name: Docker Login LCAS
# You may pin to the exact commit or the version.
# uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
uses: docker/login-action@v3
with:
# Server address of Docker registry. If not set then will default to Docker Hub
registry: lcas.lincoln.ac.uk
# Username used to log against the Docker registry
username: ${{ secrets.LCAS_REGISTRY_PUSHER }}
# Password or personal access token used to log against the Docker registry
password: ${{ secrets.LCAS_REGISTRY_TOKEN }}

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
flavor: |
latest=false
labels: |
org.opencontainers.image.description=L-CAS ROS2 Docker Image with virtual X11 embedded (flavour: ${{ matrix.push_tag }})
org.opencontainers.image.authors=L-CAS Team
# list of Docker images to use as base name for tags
images: |
lcas.lincoln.ac.uk/lcas/ros
# generate Docker tags based on the following events/attributes
tags: |
type=raw,value=${{ matrix.push_tag }}-staging
type=raw,enable=${{ github.event_name != 'pull_request' }},value=${{ matrix.push_tag }}
type=raw,enable=${{ github.event_name != 'pull_request' }},value=${{ matrix.push_tag }}-amd64
type=ref,enable=${{ github.event_name != 'pull_request' }},event=branch,prefix=${{ matrix.push_tag }}-
type=semver,pattern={{version}},prefix=${{ matrix.push_tag }}-
type=semver,pattern={{major}}.{{minor}},prefix=${{ matrix.push_tag }}-
type=semver,pattern={{major}},prefix=${{ matrix.push_tag }}-

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build Docker Image
uses: docker/build-push-action@v6
with:
context: .
file: ./nvidia.dockerfile
platforms: linux/amd64
push: true
load: true
cache-from: type=registry,ref=lcas.lincoln.ac.uk/cache/lcas/ros:${{ matrix.push_tag }}
cache-to: type=registry,ref=lcas.lincoln.ac.uk/cache/lcas/ros:${{ matrix.push_tag }},mode=max
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
BASE_IMAGE=${{ matrix.base_image }}
BRANCH=${{ env.BRANCH }}
ROS_DISTRO=${{ matrix.ros_distro }}
build-arm64:
runs-on:
- lcas-runc
- runc
strategy:
matrix:
include:
# - base_image: ubuntu:jammy
# ros_distro: humble
# push_tag: jammy-humble-arm64
# - base_image: nvidia/cuda:11.8.0-cudnn8-devel-ubuntu22.04
# ros_distro: humble
# push_tag: jammy-humble-cuda11.8-opengl-arm64
# - base_image: nvidia/cuda:12.1.1-cudnn8-devel-ubuntu22.04
# ros_distro: humble
# push_tag: jammy-humble-cuda12.1-opengl-arm64
- base_image: nvidia/cuda:12.2.2-cudnn8-devel-ubuntu22.04
ros_distro: humble
push_tag: jammy-humble-cuda12.2-opengl-arm64

- base_image: nvidia/cuda:12.6.2-cudnn-devel-ubuntu22.04
ros_distro: humble
push_tag: jammy-humble-cuda12.6-opengl-arm64

- base_image: nvidia/cuda:12.6.3-cudnn-devel-ubuntu24.04
ros_distro: rolling
push_tag: noble-rolling-cuda12.6-opengl-arm64

steps:
- name: Node Js
uses: actions/setup-node@v4
with:
node-version: "^16.13.0 || >=18.0.0"
- uses: actions/checkout@v3
- name: What
run: echo "BRANCH=${GITHUB_REF##*/}" >> $GITHUB_ENV
- name: Docker Login LCAS
# You may pin to the exact commit or the version.
# uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
Expand All @@ -151,18 +50,22 @@ jobs:
# Password or personal access token used to log against the Docker registry
password: ${{ secrets.LCAS_REGISTRY_TOKEN }}

- name: "image name from repo name"
id: docker_image_name
run: echo "docker_image=${{ github.repository }}" | tr '[:upper:]' '[:lower:]' |sed 's/[^0-9,a-z,A-Z,=,_,\/]/-/g' >>${GITHUB_OUTPUT}

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
flavor: |
latest=false
labels: |
org.opencontainers.image.description=L-CAS ROS2 Docker Image with virtual X11 embedded (flavour: ${{ matrix.push_tag }})
org.opencontainers.image.description=L-CAS ROS2 Docker Image with virtual X11 embedded (flavour: ${{ matrix.push_tag }}, multiarch)
org.opencontainers.image.authors=L-CAS Team
# list of Docker images to use as base name for tags
images: |
lcas.lincoln.ac.uk/lcas/ros
lcas.lincoln.ac.uk/${{ steps.docker_image_name.outputs.docker_image }}
# generate Docker tags based on the following events/attributes
tags: |
type=raw,value=${{ matrix.push_tag }}-staging
Expand All @@ -180,11 +83,10 @@ jobs:
with:
context: .
file: ./nvidia.dockerfile
platforms: linux/arm64
cache-from: type=registry,ref=lcas.lincoln.ac.uk/cache/lcas/ros:${{ matrix.push_tag }}
cache-to: type=registry,ref=lcas.lincoln.ac.uk/cache/lcas/ros:${{ matrix.push_tag }},mode=max
platforms: linux/amd64,linux/arm64
push: true
load: true
cache-from: type=registry,ref=lcas.lincoln.ac.uk/cache/${{ steps.docker_image_name.outputs.docker_image }}:${{ matrix.push_tag }}
cache-to: type=registry,ref=lcas.lincoln.ac.uk/cache/${{ steps.docker_image_name.outputs.docker_image }}:${{ matrix.push_tag }},mode=max
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
Expand Down
40 changes: 36 additions & 4 deletions .github/workflows/docker-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ on:

jobs:
build:
name: Build ${{ matrix.tag }} base image (${{ github.event_name }} by ${{ github.actor }})
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -27,8 +28,8 @@ jobs:
- uses: actions/checkout@v3
- name: What
run: echo "BRANCH=${GITHUB_REF##*/}" >> $GITHUB_ENV

- name: Docker Login LCAS
if: ${{ github.event_name != 'pull_request' }}
# You may pin to the exact commit or the version.
# uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
uses: docker/login-action@v3
Expand All @@ -48,14 +49,45 @@ jobs:
# Password or personal access token used to log against the Docker registry
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: "image name from repo name"
id: docker_image_name
run: echo "docker_image=${{ github.repository }}" | tr '[:upper:]' '[:lower:]' |sed 's/[^0-9,a-z,A-Z,=,_,\/]/-/g' >>${GITHUB_OUTPUT}

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
flavor: |
latest=false
labels: |
org.opencontainers.image.description=L-CAS ROS2 Docker Image (flavour: ${{ matrix.tag }}, multiarch)
org.opencontainers.image.authors=L-CAS Team
# list of Docker images to use as base name for tags
images: |
lcas.lincoln.ac.uk/${{ steps.docker_image_name.outputs.docker_image }}
# generate Docker tags based on the following events/attributes
tags: |
type=raw,value=${{ matrix.tag }}-staging
type=raw,enable=${{ github.event_name != 'pull_request' }},value=${{ matrix.tag }}
type=ref,enable=${{ github.event_name != 'pull_request' }},event=branch,prefix=${{ matrix.tag }}-
type=semver,pattern={{version}},prefix=${{ matrix.tag }}-
type=semver,pattern={{major}}.{{minor}},prefix=${{ matrix.tag }}-
type=semver,pattern={{major}},prefix=${{ matrix.tag }}-
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build Docker Image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
platforms: linux/amd64
push: ${{ github.event_name != 'pull_request' }}
tags: lcas.lincoln.ac.uk/lcas/ros:${{ matrix.tag }}
platforms: linux/amd64,linux/arm64
push: true
cache-from: type=registry,ref=lcas.lincoln.ac.uk/cache/${{ steps.docker_image_name.outputs.docker_image }}:${{ matrix.tag }}
cache-to: type=registry,ref=lcas.lincoln.ac.uk/cache/${{ steps.docker_image_name.outputs.docker_image }}:${{ matrix.tag }},mode=max
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
BASE_IMAGE=ros:${{ matrix.tag }}
BRANCH=${{ env.BRANCH }}
4 changes: 1 addition & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ARG BASE_IMAGE=ros:humble-ros-base-jammy

FROM ${BASE_IMAGE} as installer
FROM ${BASE_IMAGE}

ENV DEBIAN_FRONTEND=noninteractive

Expand All @@ -16,5 +16,3 @@ RUN curl -o /etc/ros/rosdep/sources.list.d/20-default.list https://raw.githubuse
curl -o /etc/ros/rosdep/sources.list.d/50-lcas.list https://raw.githubusercontent.com/LCAS/rosdistro/master/rosdep/sources.list.d/50-lcas.list

ENV ROSDISTRO_INDEX_URL=https://raw.github.com/LCAS/rosdistro/master/index-v4.yaml

RUN mkdir -p ~/.config/rosdistro && echo "index_url: https://raw.github.com/LCAS/rosdistro/master/index-v4.yaml" > ~/.config/rosdistro/config.yaml
Loading

0 comments on commit 43ecef3

Please sign in to comment.