From 65b0ba65a9d2a0f6b3ad1ab96ee7a055c385f9f4 Mon Sep 17 00:00:00 2001 From: Fabien Spindler Date: Thu, 4 Jul 2024 08:05:19 +0200 Subject: [PATCH] Introduce Dockerfile for Ubuntu 24.04 Update others to build and install visp as normal user instead of root --- ChangeLog.txt | 5 +- ci/docker/ubuntu-18.04/Dockerfile | 126 +++++++++++------ ci/docker/ubuntu-20.04/Dockerfile | 130 ++++++++++++------ ci/docker/ubuntu-22.04/Dockerfile | 124 +++++++++++------ ci/docker/ubuntu-24.04/Dockerfile | 106 ++++++++++++++ .../docker/tutorial-install-docker.dox | 29 ++-- 6 files changed, 374 insertions(+), 146 deletions(-) create mode 100644 ci/docker/ubuntu-24.04/Dockerfile diff --git a/ChangeLog.txt b/ChangeLog.txt index 926f81569c..6d03fec402 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -25,7 +25,7 @@ ViSP 3.x.x (Version in development) - New features and improvements . Introduce Python bindings for most of ViSP modules and classes (see corresponding tutorial) . New specific documentation for Python bindings in https://visp-doc.inria.fr/doxygen/visp-python-daily/ - . Updated Dockerfile in ci/docker folder for Ubuntu 18.04, 20.04 and 22.04. Corresponding images are also available + . Updated Dockerfile in docker folder for Ubuntu 18.04, 20.04 and 22.04. Corresponding images are also available ready to use on DockerHub https://hub.docker.com/repository/docker/vispci/vispci/general . OpenCV 2.4.8 is the minimal supported version . Introduce applications in apps folder, a collection of useful tools that @@ -38,7 +38,8 @@ ViSP 3.x.x (Version in development) . New tutorials in tutorial/segmentation/color folder to show how to use HSV color segmentation to extract the corresponding point cloud . New scene renderer based on Panda3D. See inheritance diagram for vpPanda3DBaseRenderer class and corresponding - tutorial. + tutorial + . New docker image for Ubuntu 24.04 in docker folder - Applications . Migrate eye-to-hand tutorials in apps - Tutorials diff --git a/ci/docker/ubuntu-18.04/Dockerfile b/ci/docker/ubuntu-18.04/Dockerfile index 0e8c23a443..468a3cb008 100644 --- a/ci/docker/ubuntu-18.04/Dockerfile +++ b/ci/docker/ubuntu-18.04/Dockerfile @@ -1,50 +1,88 @@ FROM ubuntu:18.04 -MAINTAINER Fabien Spindler ARG DEBIAN_FRONTEND=noninteractive -ARG VISPCI_USER_UID=1001 -ARG DOCKER_GROUP_GID=130 +ARG USER_UID=1001 ENV TZ=Europe/Paris -# Update aptitude with new repo -RUN apt-get update +# Update aptitude with default packages +RUN apt-get update \ + && apt-get install -y \ + build-essential \ + cmake \ + cmake-curses-gui \ + curl \ + gedit \ + gdb \ + git \ + iputils-ping \ + locales \ + locate \ + lsb-release \ + mercurial \ + nano \ + net-tools \ + python3 \ + python3-dev \ + python3-pip \ + python3-dbg \ + python3-empy \ + python3-numpy \ + python3-pip \ + python3-psutil \ + python3-venv \ + software-properties-common \ + sudo \ + tzdata \ + vim \ + wget \ + && apt-get clean -# Install packages -RUN apt-get install -y \ - sudo \ - build-essential \ - cmake \ - git \ - net-tools \ - iputils-ping \ - # Recommended ViSP 3rd parties - libopencv-dev \ - libx11-dev \ - liblapack-dev \ - libeigen3-dev \ - libdc1394-22-dev \ - libv4l-dev \ - libzbar-dev \ - libpthread-stubs0-dev \ - # Other optional 3rd parties - libpcl-dev \ - libcoin80-dev \ - libjpeg-dev \ - libpng-dev \ - libogre-1.9-dev \ - libois-dev \ - libdmtx-dev \ - libgsl-dev +# Update aptitude with recommended ViSP 3rd parties +RUN apt-get update \ + && apt-get install -y \ + libdc1394-22-dev \ + libeigen3-dev \ + liblapack-dev \ + libopencv-dev \ + libv4l-dev \ + libx11-dev \ + libzbar-dev \ + && apt-get clean -RUN adduser --disabled-password --gecos "" --uid $VISPCI_USER_UID vispci \ - && groupadd docker --gid $DOCKER_GROUP_GID \ - && usermod -aG sudo vispci \ - && usermod -aG docker vispci \ - && echo "%sudo ALL=(ALL:ALL) NOPASSWD:ALL" > /etc/sudoers \ - && echo "Defaults env_keep += \"DEBIAN_FRONTEND\"" >> /etc/sudoers \ - && adduser vispci video +# Update aptitude with other optional ViSP 3rd parties +RUN apt-get update \ + && apt-get install -y \ + libpcl-dev \ + libcoin80-dev \ + libjpeg-dev \ + libpng-dev \ + libogre-1.9-dev \ + libois-dev \ + libdmtx-dev \ + libgsl-dev \ + && apt-get clean -ENV HOME=/home/vispci +# Set Locale +RUN locale-gen en_US en_US.UTF-8 && \ + update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 && \ + export LANG=en_US.UTF-8 + +ENV USERNAME vispci + +RUN useradd -U --uid $USER_UID -ms /bin/bash ${USERNAME} \ + && echo "${USERNAME}:${USERNAME}" | chpasswd \ + && adduser ${USERNAME} sudo \ + && echo "$USERNAME ALL=NOPASSWD: ALL" >> /etc/sudoers.d/${USERNAME} \ + && adduser ${USERNAME} video + +# Commands below are now run as normal user +USER ${USERNAME} + +# When running a container start in the home folder +WORKDIR /home/$USERNAME + +# Create visp workspace +ENV VISP_WS /home/$USERNAME/visp-ws # Install visp-images RUN mkdir -p ${HOME}/visp-ws \ @@ -54,16 +92,14 @@ RUN mkdir -p ${HOME}/visp-ws \ && echo "export VISP_INPUT_IMAGE_PATH=${HOME}/visp-ws/visp-images" >> ${HOME}/.bashrc # Get visp -RUN cd ${HOME}/visp-ws \ +RUN cd ${VISP_WS} \ && git clone https://github.com/lagadic/visp # Build visp -RUN cd ${HOME}/visp-ws \ +RUN cd ${VISP_WS} \ && mkdir visp-build \ && cd visp-build \ && cmake ../visp \ - && make -j4 - -USER vispci + && make -j$(nproc) -WORKDIR /home/vispci +CMD ["/bin/bash"] diff --git a/ci/docker/ubuntu-20.04/Dockerfile b/ci/docker/ubuntu-20.04/Dockerfile index d9de38da6f..3a20a67327 100644 --- a/ci/docker/ubuntu-20.04/Dockerfile +++ b/ci/docker/ubuntu-20.04/Dockerfile @@ -1,50 +1,92 @@ FROM ubuntu:20.04 -MAINTAINER Fabien Spindler ARG DEBIAN_FRONTEND=noninteractive -ARG VISPCI_USER_UID=1001 -ARG DOCKER_GROUP_GID=130 +ARG USER_UID=1001 ENV TZ=Europe/Paris -# Update aptitude with new repo -RUN apt-get update +# Update aptitude with default packages +RUN apt-get update \ + && apt-get install -y \ + build-essential \ + cmake \ + cmake-curses-gui \ + curl \ + gedit \ + gdb \ + git \ + iputils-ping \ + locales \ + locate \ + lsb-release \ + mercurial \ + nano \ + net-tools \ + python3 \ + python3-dev \ + python3-pip \ + python3-dbg \ + python3-empy \ + python3-numpy \ + python3-pip \ + python3-psutil \ + python3-venv \ + software-properties-common \ + sudo \ + tzdata \ + vim \ + wget \ + && apt-get clean -# Install packages -RUN apt-get install -y \ - sudo \ - build-essential \ - cmake \ - git \ - net-tools \ - iputils-ping \ - # Recommended ViSP 3rd parties - libopencv-dev \ - libx11-dev \ - liblapack-dev \ - libeigen3-dev \ - libdc1394-22-dev \ - libv4l-dev \ - libzbar-dev \ - libpthread-stubs0-dev \ - # Other optional 3rd parties - libpcl-dev \ - libcoin-dev \ - libjpeg-dev \ - libpng-dev \ - libogre-1.9-dev \ - libois-dev \ - libdmtx-dev \ - libgsl-dev +# Update aptitude with recommended ViSP 3rd parties +RUN apt-get update \ + && apt-get install -y \ + libdc1394-22-dev \ + libeigen3-dev \ + liblapack-dev \ + libopencv-dev \ + libv4l-dev \ + libx11-dev \ + libzbar-dev \ + nlohmann-json3-dev \ + && apt-get clean -RUN adduser --disabled-password --gecos "" --uid $VISPCI_USER_UID vispci \ - && groupadd docker --gid $DOCKER_GROUP_GID \ - && usermod -aG sudo vispci \ - && usermod -aG docker vispci \ - && echo "%sudo ALL=(ALL:ALL) NOPASSWD:ALL" > /etc/sudoers \ - && echo "Defaults env_keep += \"DEBIAN_FRONTEND\"" >> /etc/sudoers \ - && adduser vispci video +# Update aptitude with other optional ViSP 3rd parties +RUN apt-get update \ + && apt-get install -y \ + libcoin-dev \ + libdmtx-dev \ + libgsl-dev \ + libjpeg-dev \ + libogre-1.9-dev \ + libois-dev \ + libpcl-dev \ + libpng-dev \ + && apt-get clean -ENV HOME=/home/vispci +# Set Locale +RUN locale-gen en_US en_US.UTF-8 && \ + update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 && \ + export LANG=en_US.UTF-8 + +ENV USERNAME vispci + +RUN useradd -U --uid $USER_UID -ms /bin/bash ${USERNAME} \ + && echo "${USERNAME}:${USERNAME}" | chpasswd \ + && adduser ${USERNAME} sudo \ + && echo "$USERNAME ALL=NOPASSWD: ALL" >> /etc/sudoers.d/${USERNAME} \ + && adduser ${USERNAME} video + +# Commands below are now run as normal user +USER ${USERNAME} + +# When running a container start in the home folder +WORKDIR /home/$USERNAME + +# Some apps don't show controls without this +ENV QT_X11_NO_MITSHM 1 + +# Create visp workspace +ENV VISP_WS /home/$USERNAME/visp-ws # Install visp-images RUN mkdir -p ${HOME}/visp-ws \ @@ -54,16 +96,14 @@ RUN mkdir -p ${HOME}/visp-ws \ && echo "export VISP_INPUT_IMAGE_PATH=${HOME}/visp-ws/visp-images" >> ${HOME}/.bashrc # Get visp -RUN cd ${HOME}/visp-ws \ +RUN cd ${VISP_WS} \ && git clone https://github.com/lagadic/visp # Build visp -RUN cd ${HOME}/visp-ws \ +RUN cd ${VISP_WS} \ && mkdir visp-build \ && cd visp-build \ && cmake ../visp \ - && make -j4 - -USER vispci + && make -j$(nproc) -WORKDIR /home/vispci +CMD ["/bin/bash"] diff --git a/ci/docker/ubuntu-22.04/Dockerfile b/ci/docker/ubuntu-22.04/Dockerfile index dfe5a9da72..e0a12e87fd 100644 --- a/ci/docker/ubuntu-22.04/Dockerfile +++ b/ci/docker/ubuntu-22.04/Dockerfile @@ -1,49 +1,89 @@ FROM ubuntu:22.04 -MAINTAINER Fabien Spindler ARG DEBIAN_FRONTEND=noninteractive -ARG VISPCI_USER_UID=1001 -ARG DOCKER_GROUP_GID=121 +ARG USER_UID=1001 ENV TZ=Europe/Paris -# Update aptitude with new repo -RUN apt-get update +# Update aptitude with default packages +RUN apt-get update \ + && apt-get install -y \ + build-essential \ + cmake \ + cmake-curses-gui \ + curl \ + gedit \ + gdb \ + git \ + iputils-ping \ + locales \ + locate \ + lsb-release \ + mercurial \ + nano \ + net-tools \ + python3 \ + python3-dev \ + python3-pip \ + python3-dbg \ + python3-empy \ + python3-numpy \ + python3-pip \ + python3-psutil \ + python3-venv \ + software-properties-common \ + sudo \ + tzdata \ + vim \ + wget \ + && apt-get clean -# Install packages -RUN apt-get install -y \ - sudo \ - build-essential \ - cmake \ - git \ - net-tools \ - iputils-ping \ - # Recommended ViSP 3rd parties - libopencv-dev \ - libx11-dev \ - liblapack-dev \ - libeigen3-dev \ - libdc1394-dev \ - libv4l-dev \ - libzbar-dev \ - # Other optional 3rd parties - libpcl-dev \ - libcoin-dev \ - libjpeg-turbo8-dev \ - libpng-dev \ - libogre-1.9-dev \ - libois-dev \ - libdmtx-dev \ - libgsl-dev +# Update aptitude with recommended ViSP 3rd parties +RUN apt-get update \ + && apt-get install -y \ + libdc1394-dev \ + libeigen3-dev \ + liblapack-dev \ + libopencv-dev \ + libv4l-dev \ + libx11-dev \ + libzbar-dev \ + nlohmann-json3-dev \ + && apt-get clean -RUN adduser --disabled-password --gecos "" --uid $VISPCI_USER_UID vispci \ - && groupadd docker --gid $DOCKER_GROUP_GID \ - && usermod -aG sudo vispci \ - && usermod -aG docker vispci \ - && echo "%sudo ALL=(ALL:ALL) NOPASSWD:ALL" > /etc/sudoers \ - && echo "Defaults env_keep += \"DEBIAN_FRONTEND\"" >> /etc/sudoers \ - && adduser vispci video +# Update aptitude with other optional ViSP 3rd parties +RUN apt-get update \ + && apt-get install -y \ + libcoin-dev \ + libdmtx-dev \ + libgsl-dev \ + libjpeg-turbo8-dev \ + libpcl-dev \ + libpng-dev \ + libogre-1.9-dev \ + libois-dev \ + && apt-get clean -ENV HOME=/home/vispci +# Set Locale +RUN locale-gen en_US en_US.UTF-8 && \ + update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 && \ + export LANG=en_US.UTF-8 + +ENV USERNAME vispci + +RUN useradd -U --uid $USER_UID -ms /bin/bash ${USERNAME} \ + && echo "${USERNAME}:${USERNAME}" | chpasswd \ + && adduser ${USERNAME} sudo \ + && echo "$USERNAME ALL=NOPASSWD: ALL" >> /etc/sudoers.d/${USERNAME} \ + && adduser ${USERNAME} video + +# Commands below are now run as normal user +USER ${USERNAME} + +# When running a container start in the home folder +WORKDIR /home/$USERNAME + +# Some apps don't show controls without this +ENV QT_X11_NO_MITSHM 1 # Install visp-images RUN mkdir -p ${HOME}/visp-ws \ @@ -53,16 +93,14 @@ RUN mkdir -p ${HOME}/visp-ws \ && echo "export VISP_INPUT_IMAGE_PATH=${HOME}/visp-ws/visp-images" >> ${HOME}/.bashrc # Get visp -RUN cd ${HOME}/visp-ws \ +RUN cd ${VISP_WS} \ && git clone https://github.com/lagadic/visp # Build visp -RUN cd ${HOME}/visp-ws \ +RUN cd ${VISP_WS} \ && mkdir visp-build \ && cd visp-build \ && cmake ../visp \ && make -j$(nproc) -USER vispci - -WORKDIR /home/vispci +CMD ["/bin/bash"] diff --git a/ci/docker/ubuntu-24.04/Dockerfile b/ci/docker/ubuntu-24.04/Dockerfile new file mode 100644 index 0000000000..08b76e39db --- /dev/null +++ b/ci/docker/ubuntu-24.04/Dockerfile @@ -0,0 +1,106 @@ +FROM ubuntu:24.04 + +ARG DEBIAN_FRONTEND=noninteractive +ARG USER_UID=1001 +ENV TZ=Europe/Paris + +## Update aptitude with default packages +RUN apt-get update \ + && apt-get install -y \ + build-essential \ + cmake \ + cmake-curses-gui \ + curl \ + gedit \ + gdb \ + git \ + iputils-ping \ + locales \ + locate \ + lsb-release \ + mercurial \ + nano \ + net-tools \ + python3 \ + python3-dev \ + python3-pip \ + python3-dbg \ + python3-empy \ + python3-numpy \ + python3-pip \ + python3-psutil \ + python3-venv \ + software-properties-common \ + sudo \ + tzdata \ + vim \ + wget \ + && apt-get clean + +# Update aptitude with recommended ViSP 3rd parties +RUN apt-get update \ + && apt-get install -y \ + libdc1394-dev \ + libeigen3-dev \ + liblapack-dev \ + libopencv-dev \ + libv4l-dev \ + libx11-dev \ + libzbar-dev \ + nlohmann-json3-dev \ + && apt-get clean + +# Update aptitude with other optional ViSP 3rd parties +RUN apt-get update \ + && apt-get install -y \ + libcoin-dev \ + libdmtx-dev \ + libgsl-dev \ + libjpeg-turbo8-dev \ + libpng-dev \ + libogre-1.9-dev \ + libois-dev \ + libpcl-dev \ + && apt-get clean + +# Set Locale +RUN locale-gen en_US en_US.UTF-8 && \ + update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 && \ + export LANG=en_US.UTF-8 + +ENV USERNAME vispci + +RUN useradd -U --uid $USER_UID -ms /bin/bash ${USERNAME} \ + && echo "${USERNAME}:${USERNAME}" | chpasswd \ + && adduser ${USERNAME} sudo \ + && echo "$USERNAME ALL=NOPASSWD: ALL" >> /etc/sudoers.d/${USERNAME} \ + && adduser ${USERNAME} video + +# Commands below are now run as normal user +USER ${USERNAME} + +# When running a container start in the home folder +WORKDIR /home/$USERNAME + +# Some apps don't show controls without this +ENV QT_X11_NO_MITSHM 1 + +# Install visp-images +RUN mkdir -p ${HOME}/visp-ws \ + && cd ${HOME}/visp-ws \ + && git clone https://github.com/lagadic/visp-images.git \ + && echo "export VISP_WS=${HOME}/visp-ws" >> ${HOME}/.bashrc \ + && echo "export VISP_INPUT_IMAGE_PATH=${HOME}/visp-ws/visp-images" >> ${HOME}/.bashrc + +# Get visp +RUN cd ${HOME}/visp-ws \ + && git clone https://github.com/lagadic/visp + +# Build visp +RUN cd ${HOME}/visp-ws \ + && mkdir visp-build \ + && cd visp-build \ + && cmake ../visp \ + && make -j$(nproc) + +CMD ["/bin/bash"] diff --git a/doc/tutorial/docker/tutorial-install-docker.dox b/doc/tutorial/docker/tutorial-install-docker.dox index e7ced95c6f..0faf3f137f 100644 --- a/doc/tutorial/docker/tutorial-install-docker.dox +++ b/doc/tutorial/docker/tutorial-install-docker.dox @@ -77,10 +77,10 @@ In [Docker Hub](https://hub.docker.com/repository/docker/vispci/vispci), we prov images that can be used on an Ubuntu or macOS host with ViSP already built. Instead, there is also the possibility to build docker images from a `Dockerfile` following instruction given in \ref docker_visp_build section. -\subsection docker_visp_pull_ubuntu_18_04 Pull Ubuntu 18.04 image +\subsection docker_visp_pull_ubuntu_22_04 Pull Ubuntu 22.04 image \verbatim -$ docker pull vispci/vispci:ubuntu-18.04 +$ docker pull vispci/vispci:ubuntu-22.04 \endverbatim \subsection docker_visp_pull_ubuntu_20_04 Pull Ubuntu 20.04 image @@ -89,10 +89,10 @@ $ docker pull vispci/vispci:ubuntu-18.04 $ docker pull vispci/vispci:ubuntu-20.04 \endverbatim -\subsection docker_visp_pull_ubuntu_22_04 Pull Ubuntu 22.04 image +\subsection docker_visp_pull_ubuntu_18_04 Pull Ubuntu 18.04 image \verbatim -$ docker pull vispci/vispci:ubuntu-22.04 +$ docker pull vispci/vispci:ubuntu-18.04 \endverbatim \section docker_visp_build Build docker image from Dockerfile @@ -101,25 +101,32 @@ We suppose here that you cloned ViSP from github in your workspace. Change directory to access the `Dockerfile` and build the corresponding docker image -\subsection docker_visp_build_ubuntu_18_04 Build Ubuntu 18.04 image +\subsection docker_visp_build_ubuntu_24_04 Build Ubuntu 24.04 image \verbatim -$ cd $VISP_WS/visp/ci/docker/ubuntu-18.04 -$ docker build -t vispci/vispci:ubuntu-18.04 . +$ cd $VISP_WS/visp/docker/ubuntu-24.04 +$ docker build -t vispci/vispci:ubuntu-24.04 . +\endverbatim + +\subsection docker_visp_build_ubuntu_22_04 Build Ubuntu 22.04 image + +\verbatim +$ cd $VISP_WS/visp/docker/ubuntu-22.04 +$ docker build -t vispci/vispci:ubuntu-22.04 . \endverbatim \subsection docker_visp_build_ubuntu_20_04 Build Ubuntu 20.04 image \verbatim -$ cd $VISP_WS/visp/ci/docker/ubuntu-20.04 +$ cd $VISP_WS/visp/docker/ubuntu-20.04 $ docker build -t vispci/vispci:ubuntu-20.04 . \endverbatim -\subsection docker_visp_build_ubuntu_22_04 Build Ubuntu 22.04 image +\subsection docker_visp_build_ubuntu_18_04 Build Ubuntu 18.04 image \verbatim -$ cd $VISP_WS/visp/ci/docker/ubuntu-22.04 -$ docker build -t vispci/vispci:ubuntu-22.04 . +$ cd $VISP_WS/visp/docker/ubuntu-18.04 +$ docker build -t vispci/vispci:ubuntu-18.04 . \endverbatim \section docker_visp_start Start ViSP container