@@ -4,59 +4,28 @@ FROM ros:${ROS_DISTRO} as mavros-msgs
4
4
ARG ROS_DISTRO
5
5
ENV ROS_DISTRO=${ROS_DISTRO}
6
6
7
- # Combine apt update, upgrade and cleaning up in one layer
8
- RUN apt update --fix-missing && \
9
- apt -y upgrade
10
-
11
7
SHELL ["/bin/bash" , "-c" ]
12
8
13
- WORKDIR /opt/colcon_ws/src/
14
-
15
9
# Install GeographicLib related dependencies
16
10
# Also add universe repository for ROS packages
17
11
# tcpdump for health checks
18
- RUN apt-get -y install software-properties-common wget curl tcpdump && \
12
+ RUN apt-get update && \
13
+ apt-get -y install software-properties-common wget curl tcpdump && \
19
14
add-apt-repository ppa:ubuntugis/ppa && \
20
15
add-apt-repository universe && \
21
16
apt-get update && \
22
- apt-get -y install gdal-bin libgdal-dev geographiclib-tools && \
23
- geographiclib-get-geoids egm96-5
24
-
25
- # Get mavros with gimbal protocol v2 plugin and build mavros_msgs only
26
- # mavros_msgs is needed by both downstream images so it is already built here
27
- # adds an additional custom patch to gps_input.cpp
28
- RUN source /opt/ros/${ROS_DISTRO}/setup.bash && \
29
- git clone --branch 2.8.0 https://github.com/mavlink/mavros.git && \
30
- rosdep update && \
31
- apt-get update && \
32
- rosdep install --from-paths . --ignore-src -y && \
33
- cd .. && \
34
- colcon build --packages-ignore mavros mavros_extras libmavconn && \
35
- sed -i 's/rclcpp::Time last_pos_time;/rclcpp::Time last_pos_time{0, 0, get_clock()->get_clock_type()};/' \
36
- src/mavros/mavros_extras/src/plugins/gps_input.cpp
17
+ apt-get -y install gdal-bin libgdal-dev geographiclib-tools ros-${ROS_DISTRO}-mavros && \
18
+ geographiclib-get-geoids egm96-5 && \
19
+ rm -rf /var/lib/apt/lists/* && \
20
+ apt-get clean
37
21
22
+ RUN mkdir -p /opt/colcon_ws/src
38
23
39
24
FROM mavros-msgs AS mavros
40
25
ARG ROS_DISTRO
41
26
42
27
WORKDIR /opt/colcon_ws/
43
28
44
- COPY mavros/filter_plugins.sh /opt/colcon_ws/src/mavros
45
-
46
- # Build mavros and mavros_extras gimbal protocol v2 (gimbal_control) plugin
47
- # We use the filter_plugins.sh script to disable unneeded plugins to significantly
48
- # speed up build time and use of memory.
49
- # mavros_msgs was built earlier so we ignore it here
50
- RUN source /opt/ros/${ROS_DISTRO}/setup.bash \
51
- && source install/setup.bash \
52
- && cd src/mavros \
53
- && ./filter_plugins.sh \
54
- && cd /opt/colcon_ws/ \
55
- && colcon build --packages-ignore mavros_msgs
56
-
57
- RUN rm -rf /var/lib/apt/lists/* && \
58
- apt clean
59
-
60
29
COPY mavros/entrypoint.sh /
61
30
62
31
RUN chmod 755 /entrypoint.sh
@@ -129,9 +98,10 @@ RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | b
129
98
130
99
COPY Makefile .pre-commit-config.yaml LICENSE.md README.md pyproject.toml /opt/colcon_ws/src/gisnav/
131
100
132
- # .git needed to make pre-commit and git describe work
133
- # TODO: solve this in a better way - we have an unnecessarily large git
134
- # history in the container
135
- COPY .git /opt/colcon_ws/src/gisnav/.git
101
+ # .git needed to make pre-commit and git describe work. We create a shallow
102
+ # copy of the repo to avoid carrying over all of commit history.
103
+ COPY .git /tmp/gisnav/.git
104
+ RUN git clone --depth 1 /tmp/gisnav/.git /opt/colcon_ws/src/gisnav/.git && \
105
+ rm -rf /tmp/gisnav/.git
136
106
137
107
ENTRYPOINT ["/entrypoint.sh" ]
0 commit comments