Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Docker files for GUI application #278

Merged
merged 3 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Docker

on:
push:
branches:
- master
- dev
pull_request:
release:
types:
- released

jobs:
ci:
name: ${{ matrix.os }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
os: [focal, jammy, noble]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
PUSH_DOCKER_IMAGE: ${{ github.ref == 'refs/heads/master' || github.event_name == 'release' }}
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract Docker meta-information
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
flavor: |
latest=false
prefix=
suffix=
tags: |
type=ref,event=branch,prefix=${{ matrix.os }}-
type=ref,event=pr,prefix=${{ matrix.os }}-
type=semver,pattern={{major}}.{{minor}},prefix=${{ matrix.os }}-

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: docker/Dockerfile
build-args: |
TAG=${{ matrix.os }}
push: ${{ env.PUSH_DOCKER_IMAGE }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
44 changes: 44 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
ARG TAG=jammy
FROM ubuntu:${TAG}

SHELL ["/bin/bash", "-c"]

ENV DEBIAN_FRONTEND noninteractive

USER root

# Install
RUN apt update \
&& apt upgrade -y \
&& apt install -y cmake curl git python3

# Add ROS2 sources to install ROS infrastructure tools
RUN curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg \
&& 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

# Install and configure ROS infrastructure tools
RUN apt update \
&& apt install -y python3-vcstool python3-colcon-common-extensions python3-rosdep \
&& rosdep init \
&& rosdep update

# Bind mount the source directory so as not to unnecessarily copy source code into the docker image
ARG WORKSPACE_DIR=/opt/noether
RUN --mount=type=bind,target=${WORKSPACE_DIR}/src/noether \
apt update -y -qq \
&& vcs import ${WORKSPACE_DIR}/src < ${WORKSPACE_DIR}/src/noether/dependencies.repos --shallow \
&& rosdep install \
--from-paths ${WORKSPACE_DIR}/src \
-iry \
--skip-keys libvtk

# Build the repository
# Bind mount the source directory so as not to unnecessarily copy source code into the docker image
RUN --mount=type=bind,target=${WORKSPACE_DIR}/src/noether \
cd ${WORKSPACE_DIR} \
&& colcon build --cmake-args \
&& rm -rf build log

# Set the entrypoint to source the workspace
COPY docker/entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
12 changes: 12 additions & 0 deletions docker/docker-compose.override.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Uncomment for use with GPU
# services:
# noether:
# environment:
# NVIDIA_DRIVER_CAPABILITIES: all
# deploy:
# resources:
# reservations:
# devices:
# - driver: nvidia
# count: 1
# capabilities: [gpu]
21 changes: 21 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
services:
noether:
build:
context: ..
dockerfile: docker/Dockerfile
args:
TAG: jammy
environment:
DISPLAY: $DISPLAY
XAUTHORITY: $XAUTHORITY
LD_LIBRARY_PATH_ADDITIONS: /usr/lib/jvm/java-11-openjdk-amd64/lib:/usr/lib/jvm/java-11-openjdk-amd64/lib/server
container_name: noether
image: ghcr.io/ros-industrial/noether:jammy
stdin_open: true
tty: true
network_mode: host
privileged: false
user: ${CURRENT_UID} # CURRENT_UID=$(id -u):$(id -g)
volumes:
- /tmp/.X11-unix:/tmp/.X11-unix
# - <path>/<to>/<meshes>:/meshes # Mount a local directory with meshes to /meshes in the docker container
4 changes: 4 additions & 0 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#! /bin/bash
source /opt/noether/install/setup.bash
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$LD_LIBRARY_PATH_ADDITIONS
./opt/noether/install/noether_gui/bin/noether_gui_app