Skip to content

Commit

Permalink
Merge pull request #3053 from robotology/docker_support
Browse files Browse the repository at this point in the history
Added experimental docker image in CI and documentation
  • Loading branch information
randaz81 authored Nov 23, 2023
2 parents a29c6b2 + ca601fe commit 76a6c45
Show file tree
Hide file tree
Showing 11 changed files with 248 additions and 6 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Docker build

on:
workflow_dispatch:
push:
branches:
- master

jobs:

docker:
name: 'Docker Image'
runs-on: ubuntu-22.04
steps:
- name: Build Docker Image
id: build_docker_image
run: |
cd docker
docker build -t yarp:ubuntu22.04 .
7 changes: 7 additions & 0 deletions doc/001_installation/0_installation.dox
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/**
\page yarp_installation Installation and setup

You can install Yarp on you device following the guide below:

\subpage download

\subpage dependencies
Expand All @@ -13,4 +15,9 @@

\subpage yarp_cluster


You can also try Yarp without installing it, using the official Docker image:

\subpage yarp_docker

*/
27 changes: 27 additions & 0 deletions doc/001_installation/7_docker.dox
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
\page yarp_docker Docker image for Yarp

You can find the official Yarp docker image here:

+ https://github.com/robotology/yarp/docker

You can build it using the command:

\verbatim
cd yarp/docker
docker build -t yarp:ubuntu22.04 .
\endverbatim

You can run the docker image using the command:

\verbatim
sudo docker run --rm -it --privileged --network host --pid host -e DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -v /etc/hosts:/etc/hosts -e QT_X11_NO_MITSHM=1 yarp:ubuntu22.04
\endverbatim

To use the graphics inside the docker images, remember to disable X permission with the following command:

\verbatim
sudo xhost +
\endverbatim

*/
4 changes: 4 additions & 0 deletions doc/release/master.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ Fixes
New Features
------------

### Docker

Added new experimental docker image for Ubuntu22.04 http://github.com/robotology/yarp/docker

### GUIs

#### yarpaudiocontrolgui
Expand Down
162 changes: 162 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
FROM ubuntu:22.04
LABEL maintainer="Marco Randazzo"

# Non-interactive installation mode
ENV DEBIAN_FRONTEND=noninteractive
ENV DOCKER_UPDATED_ON=23_11_2023

# Install essentials
RUN apt-get update && apt-get install -y apt-utils \
software-properties-common \
sudo \
psmisc \
lsb-release \
protobuf-compiler \
libatlas-base-dev \
tmux \
nano \
geany \
vim \
wget \
curl \
build-essential \
git gitk \
cmake \
cmake-curses-gui \
autoconf \
xserver-xorg-video-dummy \
xserver-xorg-legacy \
net-tools \
terminator \
apt-transport-https \
ca-certificates \
gnupg \
locales \
python3-setuptools \
python3-pip \
iproute2 \
python3-tornado \
lsof \
iftop \
iputils-ping \
gdb \
bash-completion \
btop \
mlocate
&& rm -rf /var/lib/apt/lists/*

RUN pip3 install numpy bpytop

RUN sed -i 's/allowed_users=console/allowed_users=anybody/' /etc/X11/Xwrapper.config
COPY ./common/xorg.conf /etc/X11/xorg.conf

# Install yarp dependencies
RUN apt-get install -y libace-dev \
libsqlite3-dev \
libtinyxml-dev \
libedit-dev \
qtbase5-dev \
qtdeclarative5-dev \
qtmultimedia5-dev \
libqt5opengl5-dev \
libqcustomplot-dev \
libopencv-dev \
libeigen3-dev \
libgraphviz-dev \
libpng-dev \
libv4l-dev \
libavcodec-dev \
libavdevice-dev \
libavformat-dev \
libavutil-dev \
portaudio19-dev \
libsdl1.2-dev \
libopenni2-dev \
libftdi-dev \
libi2c-dev \
libjpeg-dev \
libpcl-dev \
libsoxr-dev \
libgstreamer1.0-dev \
libgstreamer-plugins-base1.0-dev

# Install SWIG and bindings dependencies
RUN apt-get install -qq -y swig \
mono-mcs \
liblua5.3-dev \
lua5.3 \
tcl-dev \
tk-dev \
python3-dev \
liboctave-dev \
ruby-dev \
ruby \
perl

# Create user: user1
USER root
RUN useradd -l -u 33334 -G sudo -md /home/user1 -s /bin/bash -p user1 user1 && \
# passwordless sudo for users in the 'sudo' group
sed -i.bkp -e 's/%sudo\s\+ALL=(ALL\(:ALL\)\?)\s\+ALL/%sudo ALL=NOPASSWD:ALL/g' /etc/sudoers

# Set ENV
USER user1
RUN mkdir /home/user1/robotology
ENV robotology_install_user user1
ENV user1_home /home/$robotology_install_user
ENV robotology_install_folder $user1_home/robotology

# Build ycm
USER $robotology_install_user
WORKDIR $robotology_install_folder
RUN git clone https://github.com/robotology/ycm.git -b master
RUN cd ycm && mkdir build && cd build && \
cmake .. \
-DCMAKE_BUILD_TYPE=Release && \
make -j11
ENV YCM_DIR=/home/user1/robotology/ycm/build

# Build YARP
USER $robotology_install_user
WORKDIR $robotology_install_folder
RUN git clone https://github.com/robotology/yarp.git -b master
RUN cd yarp && mkdir build && cd build && \
cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DYARP_COMPILE_libYARP_math=ON \
-DYARP_COMPILE_GUIS=ON \
-DYARP_COMPILE_DEVICE_PLUGINS=ON \
-DYARP_COMPILE_ALL_FAKE_DEVICES=ON \
-DENABLE_yarpcar_mjpeg=ON \
-DENABLE_yarpcar_segmentationimage=ON \
-DENABLE_yarpcar_portmonitor=ON \
-DENABLE_yarppm_bottle_compression_zlib=ON \
-DENABLE_yarppm_depthimage_compression_zlib=ON \
-DENABLE_yarppm_image_compression_ffmpeg=ON \
-DENABLE_yarppm_depthimage_to_mono=ON \
-DENABLE_yarppm_depthimage_to_rgb=ON && \
make -j11
ENV YARP_ROOT=$robotology_install_folder/yarp
ENV YARP_DIR=$robotology_install_folder/yarp/build

# YARP bindings
USER $robotology_install_user
WORKDIR $robotology_install_folder
RUN cd yarp && cd bindings && mkdir build && cd build && cmake .. -DCREATE_PYTHON=ON && make -j11

# Install YARP completion
RUN sudo ln -s /usr/local/share/bash-completion/completions/yarp /usr/share/bash-completion/completions

# Set environmental variables
USER $robotology_install_user
RUN echo "PS1='\[\e]0;\u \w\a\]\[\033[01;32m\]\u\[\033[00m\] \[\033[01;34m\]\w\[\033[00m\] \$ '" >> /home/$robotology_install_user/.bashrc
ENV PATH=$PATH:$YARP_DIR/bin
ENV DISPLAY=:1
ENV YARP_DATA_DIRS=$YARP_DIR/share/yarp
ENV LD_LIBRARY_PATH=$robotology_install_folder/yarp/build/lib/yarp/
ENV YARP_COLORED_OUTPUT=1
ENV QT_X11_NO_MITSHM=1
ENV PYTHONPATH=$PYTHONPATH:/home/user1/robotology/yarp/bindings/build/lib/python3/

# Manage yarp port
EXPOSE 10000/tcp 10000/udp
23 changes: 23 additions & 0 deletions docker/common/xorg.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Section "Monitor"
Identifier "Monitor0"
HorizSync 28.0-80.0
VertRefresh 48.0-75.0
# https://arachnoid.com/modelines/
# 1920x1080 @ 60.00 Hz (GTF) hsync: 67.08 kHz; pclk: 172.80 MHz
Modeline "1920x1080_60.00" 172.80 1920 2040 2248 2576 1080 1081 1084 1118 -HSync +Vsync
EndSection
Section "Device"
Identifier "Card0"
Driver "dummy"
VideoRam 256000
EndSection
Section "Screen"
DefaultDepth 24
Identifier "Screen0"
Device "Card0"
Monitor "Monitor0"
SubSection "Display"
Depth 24
Modes "1920x1080_60.00"
EndSubSection
EndSection
2 changes: 1 addition & 1 deletion src/devices/fakeBattery/fakeBattery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ void FakeBattery::updateStatus()
battery_status = yarp::dev::IBattery::Battery_status::BATTERY_CRITICAL_WARNING;
}
} else if (battery_current > -0.1) {
battery_status = yarp::dev::IBattery::Battery_status::BATTERY_OK_STANBY;
battery_status = yarp::dev::IBattery::Battery_status::BATTERY_OK_STANDBY;
} else {
battery_status = yarp::dev::IBattery::Battery_status::BATTERY_OK_IN_CHARGE;
}
Expand Down
2 changes: 1 addition & 1 deletion src/devices/laserFromDepth/laserFromDepth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ bool LaserFromDepth::open(yarp::os::Searchable& config)
{
Property subConfig;
m_info = "LaserFromDepth device";
m_device_status = DEVICE_OK_STANBY;
m_device_status = DEVICE_OK_STANDBY;

#ifdef LASER_DEBUG
yCDebug(LASER_FROM_DEPTH) << "%s\n", config.toString().c_str();
Expand Down
2 changes: 1 addition & 1 deletion src/devices/laserHokuyo/laserHokuyo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ bool laserHokuyo::open(yarp::os::Searchable& config)
{
internal_status = HOKUYO_STATUS_NOT_READY;
info = "Hokuyo Laser";
device_status = DEVICE_OK_STANBY;
device_status = DEVICE_OK_STANDBY;

yCTrace(LASERHOKUYO, "%s", config.toString().c_str());

Expand Down
2 changes: 1 addition & 1 deletion src/devices/laserHokuyo/laserHokuyo.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class laserHokuyo : public PeriodicThread, public yarp::dev::IRangefinder2D, pub
error_codes(0),
internal_status(0),
info(""),
device_status(Device_status::DEVICE_OK_STANBY),
device_status(Device_status::DEVICE_OK_STANDBY),
laser_mode(Laser_mode_type::FAKE_MODE)
{}

Expand Down
4 changes: 2 additions & 2 deletions src/devices/upowerBattery/upowerBattery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ bool UpowerBattery::getBatteryCharge(double& charge)

bool UpowerBattery::getBatteryStatus(Battery_status& status)
{
status = yarp::dev::IBattery::BATTERY_OK_STANBY;
status = yarp::dev::IBattery::BATTERY_OK_STANDBY;
auto st = m_interface->property("State").toUInt();
auto wl = m_interface->property("WarningLevel").toUInt();

Expand Down Expand Up @@ -106,7 +106,7 @@ bool UpowerBattery::getBatteryStatus(Battery_status& status)
status = yarp::dev::IBattery::BATTERY_CRITICAL_WARNING;
break;
case 4 /* Fully charged */:
status = yarp::dev::IBattery::BATTERY_OK_STANBY;
status = yarp::dev::IBattery::BATTERY_OK_STANDBY;
break;
case 0 /* Unknown */: [[fallthrough]];
default:
Expand Down

0 comments on commit 76a6c45

Please sign in to comment.