78 lines
2.7 KiB
Docker
78 lines
2.7 KiB
Docker
# 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 <https://www.gnu.org/licenses/>.
|
|
|
|
ARG ROS_ARCHITECTURE_VERSION=latest
|
|
|
|
FROM ronaldsonbellande/bellande_robotic_environment_ros2:latest
|
|
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
|
|
|
|
ENV ROS_VERSION=foxy
|
|
ENV COLCON_WS=/opt/ros/overlay_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}
|
|
|
|
# Install necessary tools
|
|
RUN apt-get update && \
|
|
apt-get install -y python3-colcon-common-extensions python3-rosdep
|
|
|
|
# Initialize rosdep if not already initialized
|
|
RUN if [ ! -f /etc/ros/rosdep/sources.list.d/20-default.list ]; then \
|
|
rosdep init; \
|
|
fi && \
|
|
rosdep update --include-eol-distros || \
|
|
{ echo "Retrying rosdep update..."; sleep 5; rosdep update --include-eol-distros; }
|
|
|
|
# Create local colcon workspace
|
|
RUN mkdir -p $COLCON_WS/src
|
|
|
|
# Copy Every Package
|
|
COPY ../ ${COLCON_WS}/src
|
|
|
|
# Set the working directory for Colcon
|
|
WORKDIR $COLCON_WS
|
|
|
|
# Source ROS setup.bash
|
|
RUN echo "source /opt/ros/$ROS_VERSION/setup.bash" >> ~/.bashrc
|
|
RUN /bin/bash -c "source /opt/ros/$ROS_VERSION/setup.bash"
|
|
|
|
# Install dependencies using rosdep
|
|
RUN /bin/bash -c "source /opt/ros/$ROS_VERSION/setup.bash && \
|
|
cd $COLCON_WS && \
|
|
rosdep update && \
|
|
rosdep install -y --from-paths src --ignore-src --rosdistro $ROS_VERSION"
|
|
|
|
# Build the workspace using colcon
|
|
RUN /bin/bash -c "source /opt/ros/$ROS_VERSION/setup.bash && \
|
|
cd $COLCON_WS && \
|
|
colcon build --event-handlers console_cohesion+"
|
|
|
|
# Always source colcon_setup.sh when launching bash
|
|
COPY ../scripts/colcon_setup.sh /usr/local/bin/colcon_setup.sh
|
|
RUN echo "source /usr/local/bin/colcon_setup.sh" >> /root/.bashrc && \
|
|
chmod +x /usr/local/bin/colcon_setup.sh
|
|
|
|
# Run colcon setup script
|
|
RUN /usr/local/bin/colcon_setup.sh
|
|
CMD ["/bin/bash"]
|