-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdockerfile
78 lines (62 loc) · 2.83 KB
/
dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# Use ARG for flexibility to choose ROS2 distribution
# Choose between Humble or Iron
ARG FROM_IMAGE=ros:humble
ARG INCLUDE_YOLO=false
FROM $FROM_IMAGE
# Set the workspace path as an argument
ARG OVERLAY_WS=/opt/ros/OpenPodCar_V2
# Specify the Gazebo version to install (fortress, garden, harmonic)
ARG GZ_VERSION=fortress
# Update and install necessary tools, including Gz dependencies
RUN apt-get update && apt-get install -y \
lsb-release wget gnupg curl \
&& rm -rf /var/lib/apt/lists/*
# Install Gazebo using OSRF's repository
RUN wget https://packages.osrfoundation.org/gazebo.gpg -O /usr/share/keyrings/pkgs-osrf-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/pkgs-osrf-archive-keyring.gpg] \
http://packages.osrfoundation.org/gazebo/ubuntu-stable $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/gazebo-stable.list > /dev/null \
&& apt-get update \
&& apt-get install -y "gz-${GZ_VERSION}" \
&& rm -rf /var/lib/apt/lists/*
# Install additional ROS dependencies and useful utilities
RUN apt-get update && apt-get install -y \
ros-${ROS_DISTRO}-teleop-twist-keyboard \
ros-${ROS_DISTRO}-desktop \
emacs htop byobu python3-pip less \
ros-${ROS_DISTRO}-realsense2-* \
&& rm -rf /var/lib/apt/lists/*
# Install specific setuptools version for colcon
RUN pip install --default-timeout=100 setuptools==58.2.0
# Set the working directory to the custom ROS workspace
WORKDIR $OVERLAY_WS/src
# Clone your ROS2 workspace (from your GitHub repo)
# RUN git clone https://github.com/Rak-r/OpenPodCar_V2.git .
COPY src/ .
# IF want to use YOLOV8 and Game theory inside docker env, comment out above and uncomment below
# Conditionally copy yolov8_ros2_OpenPodCarV2 and Game_Theory
# Conditionally copy yolov8_ros2_OpenPodCarV2 and Game_Theory
COPY Game_Theory /OpenPodCar_V2/Game_Theory
COPY yolov8_ros2_OpenPodCarV2 /OpenPodCar_V2/yolov8_ros2_OpenPodCarV2
# Use a conditional build argument to control copying
RUN if [ "$INCLUDE_YOLOV8" != "true" ]; then \
rm -rf /OpenPodCar_V2/Game_Theory /OpenPodCar_V2/yolov8_ros2_OpenPodCarV2; \
fi
# Move up to the workspace directory and install dependencies using rosdep
WORKDIR $OVERLAY_WS
RUN . /opt/ros/$ROS_DISTRO/setup.sh && \
apt-get update && rosdep install -y \
--from-paths src \
--ignore-src \
&& rm -rf /var/lib/apt/lists/*
# Build the workspace using colcon
RUN . /opt/ros/$ROS_DISTRO/setup.sh && \
colcon build --symlink-install
# Ensure the ROS environment is properly sourced in the entrypoint
ENV OVERLAY_WS=$OVERLAY_WS
RUN sed --in-place --expression \
'$isource "$OVERLAY_WS/install/setup.bash"' \
/ros_entrypoint.sh
# Set the default entrypoint to source the ROS environment
ENTRYPOINT ["/ros_entrypoint.sh"]
# Default command to keep the container running
CMD ["/bin/bash"]