From 9c83c4fa00c5b201e2f862d04cb781ee50a104f4 Mon Sep 17 00:00:00 2001 From: RonaldsonBellande Date: Thu, 9 May 2024 23:46:52 -0400 Subject: [PATCH] latest pushes --- docker/Dockerfile.ros1 | 88 +++++++++++++++++++++++++++++++++++++ docker/Dockerfile.ros2 | 96 +++++++++++++++++++++++++++++++++++++++++ scripts/build_docker.sh | 12 ++++-- 3 files changed, 193 insertions(+), 3 deletions(-) create mode 100644 docker/Dockerfile.ros1 create mode 100644 docker/Dockerfile.ros2 diff --git a/docker/Dockerfile.ros1 b/docker/Dockerfile.ros1 new file mode 100644 index 0000000..8b1a10e --- /dev/null +++ b/docker/Dockerfile.ros1 @@ -0,0 +1,88 @@ +# Copyright (C) 2024 Bellande Robotics Sensors Research Innovation Center, Ronaldson Bellande +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +ARG ROS_ARCHITECTURE_VERSION=latest + +FROM ubuntu:20.04 as base_build +SHELL [ "/bin/bash" , "-c" ] + +ENV DEBIAN_FRONTEND noninteractive +ENV PYTHON_VERSION="3.8" + +ARG ROS_ARCHITECTURE_VERSION_GIT_BRANCH=main +ARG ROS_ARCHITECTURE_VERSION_GIT_COMMIT=HEAD + +ARG ROS_VERSION=noetic +ENV CATKIN_WS=/root/catkin_ws + +LABEL maintainer=ronaldsonbellande@gmail.com +LABEL author=ronaldsonbellande@gmail.com +LABEL ROS_architecture_github_branchtag=${ROS_ARCHITECTURE_VERSION_GIT_BRANCH} +LABEL ROS_architecture_github_commit=${ROS_ARCHITECTURE_VERSION_GIT_COMMIT} + +# Ubuntu setup +RUN apt-get update -y +RUN apt-get upgrade -y + +# Set the working directory inside the Docker image +WORKDIR / + +# Create a directory for the requirements +RUN mkdir -p /requirements + +# Copy specific files from the requirements directory to the "requirements" directory in the Docker image +COPY ../requirements/requirements.txt /requirements/requirements.txt +COPY ../requirements/system_requirements.txt /requirements/system_requirements.txt +COPY ../requirements/ros_requirements.txt /requirements/ros_requirements.txt +COPY ../requirements/ros_repository_requirements.txt /requirements/ros_repository_requirements.txt + +# Install dependencies for system +RUN apt-get update && apt-get install -y --no-install-recommends > ~/.bashrc +RUN source ~/.bashrc + +RUN cd $CATKIN_WS \ + && rosdep init \ + && rosdep update \ + && rosdep update --rosdistro ${ROS_VERSION} \ + && rosdep fix-permissions \ + && rosdep install -y --from-paths . --ignore-src --rosdistro ${ROS_VERSION} + +ENTRYPOINT ["/usr/local/bin/catkin_setup.sh"] +CMD ["bash"] diff --git a/docker/Dockerfile.ros2 b/docker/Dockerfile.ros2 new file mode 100644 index 0000000..8576e3d --- /dev/null +++ b/docker/Dockerfile.ros2 @@ -0,0 +1,96 @@ +# Copyright (C) 2024 Bellande Robotics Sensors Research Innovation Center, Ronaldson Bellande +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +ARG ROS_ARCHITECTURE_VERSION=latest + +FROM ubuntu:20.04 as base_build +SHELL [ "/bin/bash" , "-c" ] + +ENV DEBIAN_FRONTEND noninteractive +ENV PYTHON_VERSION="3.8" + +ARG ROS_ARCHITECTURE_VERSION_GIT_BRANCH=main +ARG ROS_ARCHITECTURE_VERSION_GIT_COMMIT=HEAD + +ARG ROS_VERSION=foxy +ENV CATKIN_WS=/root/catkin_ws + +LABEL maintainer=ronaldsonbellande@gmail.com +LABEL author=ronaldsonbellande@gmail.com +LABEL ROS_architecture_github_branchtag=${ROS_ARCHITECTURE_VERSION_GIT_BRANCH} +LABEL ROS_architecture_github_commit=${ROS_ARCHITECTURE_VERSION_GIT_COMMIT} + +# Ubuntu setup +RUN apt-get update -y +RUN apt-get upgrade -y + +# Set the working directory inside the Docker image +WORKDIR / + +# Copy all files from the parent directory to the Docker image root +COPY ../ ./ + +# Create a directory for the requirements +RUN mkdir -p /requirements + +# Copy specific files from the requirements directory to the "requirements" directory in the Docker image +COPY requirements/requirements.txt /requirements/requirements.txt +COPY requirements/system_requirements.txt /requirements/system_requirements.txt +COPY requirements/ros_requirements.txt /requirements/ros_requirements.txt +COPY requirements/ros_repository_requirements.txt /requirements/ros_repository_requirements.txt + +# Install dependencies for system +RUN apt-get update && apt-get install -y --no-install-recommends > ~/.bashrc +RUN source ~/.bashrc + +RUN cd $CATKIN_WS \ + && rosdep init \ + && rosdep update \ + && rosdep update --rosdistro ${ROS_VERSION} \ + && rosdep fix-permissions \ + && rosdep install -y --from-paths . --ignore-src --rosdistro ${ROS_VERSION} + +# Catkin Build +RUN catkin build + +# Source Catkin Setup +RUN source "$CATKIN_WS/devel/setup.bash" + +CMD ["bash"] diff --git a/scripts/build_docker.sh b/scripts/build_docker.sh index a0586bf..a56ad4c 100755 --- a/scripts/build_docker.sh +++ b/scripts/build_docker.sh @@ -15,14 +15,17 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +# Get the directory of the script +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + # Check user input if [ "$1" = "ros1" ]; then # Define the Dockerfile name and tag for ROS 1 - DOCKERFILE="../Dockerfile/Dockerfile.ros1" + DOCKERFILE="$DIR/../docker/Dockerfile.ros1" IMAGE_NAME="bellande_api_configs_packages_ros1" elif [ "$1" = "ros2" ]; then # Define the Dockerfile name and tag for ROS 2 - DOCKERFILE="../Dockerfile/Dockerfile.ros2" + DOCKERFILE="$DIR/../docker/Dockerfile.ros2" IMAGE_NAME="bellande_api_configs_packages_ros2" else echo "Invalid input. Please provide either 'ros1' or 'ros2'." @@ -31,8 +34,11 @@ fi TAG="latest" # Change this to the desired tag for your Docker image +# Navigate to the directory containing the Dockerfile +cd "$DIR/../docker" || exit + # Build the Docker image -docker build -t $IMAGE_NAME:$TAG -f $DOCKERFILE . +docker build -t $IMAGE_NAME:$TAG -f $DOCKERFILE "$DIR/../" # Check if the image was built successfully if [ $? -eq 0 ]; then