From b0a1bd6d10e2664e9525375bfb220ddb93f05641 Mon Sep 17 00:00:00 2001 From: Adam Sadek <33073174+AdamSadek@users.noreply.github.com> Date: Sun, 14 Jan 2024 11:33:47 +0000 Subject: [PATCH 1/4] Initial docker image setup --- Dockerfile | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..38ad0517 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,46 @@ +FROM ubuntu:20.04 +ENV DEBIAN_FRONTEND noninteractive + +# Creating a direcotyr for +WORKDIR /docker_ros_ws + +# Copy necessary files to the Docker image +COPY . /docker_ros_ws + +# Update the package list and install necessary dependencies +RUN apt-get update && apt-get install -y \ + curl \ + gnupg2 \ + lsb-release \ + python3 \ + python3-pip \ + python3-numpy \ + python3-scipy \ + python3-matplotlib \ + opencv-python \ + libopencv-dev \ + python3-rpi.gpio \ + i2c-tools \ + libi2c-dev \ + libgpiod-dev \ + pigpio \ + libpigpiod-dev \ + openssh-server \ + avahi-daemon \ + net-tools + +RUN rm -rf /var/lib/apt/lists/* + +# Add ROS 2 apt repository +RUN curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | gpg --dearmor -o /usr/share/keyrings/ros-archive-keyring.gpg && \ + echo "deb [signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(lsb_release -cs) main" > /etc/apt/sources.list.d/ros2.list + +# Install ROS 2 Foxy +RUN apt-get update && apt-get install -y \ + ros-foxy-desktop \ + && rm -rf /var/lib/apt/lists/* + +# Set up ROS 2 environment +RUN echo "source /opt/ros/foxy/setup.bash" >> /root/.bashrc + +CMD ["/bin/bash"] From a8e0f6ac43cc0848b86a918cf9bef5049bda2213 Mon Sep 17 00:00:00 2001 From: Adam Sadek <33073174+AdamSadek@users.noreply.github.com> Date: Sun, 14 Jan 2024 11:34:47 +0000 Subject: [PATCH 2/4] Refinements --- Dockerfile | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 38ad0517..c4b78c8b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,13 @@ FROM ubuntu:20.04 ENV DEBIAN_FRONTEND noninteractive -# Creating a direcotyr for +# Creating a directory for workspace in the image WORKDIR /docker_ros_ws -# Copy necessary files to the Docker image +# Copy all files (for now), to the Docker image COPY . /docker_ros_ws -# Update the package list and install necessary dependencies +# Update the package list and install necessary dependencies for Ros RUN apt-get update && apt-get install -y \ curl \ gnupg2 \ @@ -27,20 +27,20 @@ RUN apt-get update && apt-get install -y \ libpigpiod-dev \ openssh-server \ avahi-daemon \ - net-tools - -RUN rm -rf /var/lib/apt/lists/* + net-tools \ + && rm -rf /var/lib/apt/lists/* -# Add ROS 2 apt repository +# Adding ROS2 apt repository - from documentation RUN curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | gpg --dearmor -o /usr/share/keyrings/ros-archive-keyring.gpg && \ echo "deb [signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(lsb_release -cs) main" > /etc/apt/sources.list.d/ros2.list -# Install ROS 2 Foxy +# Install ROS2 Foxy - from documentation RUN apt-get update && apt-get install -y \ ros-foxy-desktop \ && rm -rf /var/lib/apt/lists/* -# Set up ROS 2 environment +# Set up ROS2 environment - from documentation RUN echo "source /opt/ros/foxy/setup.bash" >> /root/.bashrc +# Shell entrypoint CMD ["/bin/bash"] From 36341524063ec63ff2f8c9471168443ff6775d14 Mon Sep 17 00:00:00 2001 From: Adam Sadek <33073174+AdamSadek@users.noreply.github.com> Date: Sun, 14 Jan 2024 19:04:20 +0000 Subject: [PATCH 3/4] Fixed and tested some problems with installing packages --- Dockerfile | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/Dockerfile b/Dockerfile index c4b78c8b..c85bebd5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,43 +1,46 @@ FROM ubuntu:20.04 ENV DEBIAN_FRONTEND noninteractive -# Creating a directory for workspace in the image +# Creating a directory for the workspace in the image WORKDIR /docker_ros_ws # Copy all files (for now), to the Docker image COPY . /docker_ros_ws -# Update the package list and install necessary dependencies for Ros +# Update the package list and install necessary dependencies for ROS2 RUN apt-get update && apt-get install -y \ curl \ gnupg2 \ lsb-release \ + software-properties-common \ python3 \ python3-pip \ python3-numpy \ python3-scipy \ python3-matplotlib \ - opencv-python \ + python3-argcomplete \ libopencv-dev \ - python3-rpi.gpio \ i2c-tools \ libi2c-dev \ - libgpiod-dev \ - pigpio \ - libpigpiod-dev \ openssh-server \ avahi-daemon \ - net-tools \ - && rm -rf /var/lib/apt/lists/* + net-tools -# Adding ROS2 apt repository - from documentation -RUN curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | gpg --dearmor -o /usr/share/keyrings/ros-archive-keyring.gpg && \ - echo "deb [signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(lsb_release -cs) main" > /etc/apt/sources.list.d/ros2.list +RUN add-apt-repository universe -# Install ROS2 Foxy - from documentation +# Adding ROS2 apt repository - from documentation RUN apt-get update && apt-get install -y \ - ros-foxy-desktop \ - && rm -rf /var/lib/apt/lists/* + curl + +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 + +# After adding the repo, we can install ROS2 Foxy +RUN apt update && apt upgrade && apt install ros-foxy-desktop ros-dev-tools python3-argcomplete -y + +# Cleanup the list of packages we wanted to install. Using find to avoid using * in case there's none. +RUN find /var/lib/apt/lists -mindepth 1 -delete # Set up ROS2 environment - from documentation RUN echo "source /opt/ros/foxy/setup.bash" >> /root/.bashrc From c0e71f8b2cfa9456aaef5bd64a7dc0566aa50cdd Mon Sep 17 00:00:00 2001 From: adamsadek Date: Mon, 22 Jan 2024 17:00:54 +0000 Subject: [PATCH 4/4] Docker installation script on linux --- linux_docker_install.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 linux_docker_install.sh diff --git a/linux_docker_install.sh b/linux_docker_install.sh new file mode 100644 index 00000000..7791ecd3 --- /dev/null +++ b/linux_docker_install.sh @@ -0,0 +1,15 @@ +#!/bin/bash +# Add Docker's official GPG key: +sudo apt-get update +sudo apt-get install ca-certificates curl gnupg +sudo install -m 0755 -d /etc/apt/keyrings +curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg +sudo chmod a+r /etc/apt/keyrings/docker.gpg + +# Add the repository to Apt sources: +echo \ + "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \ + $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ + sudo tee /etc/apt/sources.list.d/docker.list > /dev/null +sudo apt-get update +sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin \ No newline at end of file