Skip to content

Commit a2a7a8a

Browse files
committed
Simplify gisnav Dockerfile
1 parent 317f211 commit a2a7a8a

File tree

1 file changed

+13
-42
lines changed

1 file changed

+13
-42
lines changed

docker/gisnav/Dockerfile

Lines changed: 13 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
ARG ROS_VERSION
2-
FROM ros:${ROS_VERSION} AS builder
2+
FROM ros:${ROS_VERSION}
33

44
ARG ROS_VERSION
5+
ENV ROS_VERSION=${ROS_VERSION}
56

67
WORKDIR /opt/colcon_ws/src/
78

89
COPY . gisnav/
910

1011
RUN apt-get update --fix-missing && \
11-
apt-get -y dist-upgrade && \
12-
chmod +x gisnav/docker/gisnav/entrypoint.sh
12+
apt-get -y upgrade && \
13+
mv gisnav/docker/gisnav/entrypoint.sh / && \
14+
chmod +x /entrypoint.sh
1315

1416
# Install GISNav dependencies
1517
RUN cd gisnav/gisnav && \
@@ -28,57 +30,26 @@ RUN apt-get -y install software-properties-common python3-pip wget && \
2830
apt-get clean && \
2931
rm -rf /var/lib/apt/lists/*
3032

31-
# Custom ROS messages (px4_msgs and mavros mavlink gimbal protocl v2 support)
32-
# Edits px4_msgs CMakeLists.txt so that only SensorGps message is built
33-
# Also comments out the lines corresponding to the disabled mavros_msgs CMakeLists.txt
34-
35-
# List required mavros messages
36-
ENV ENABLED_MSGS="HilGPS GimbalDeviceAttitudeStatus GimbalManagerSetAttitude GimbalDeviceSetAttitude Altitude HomePosition HilGPS GPSINPUT"
37-
# All available mavros messages
38-
ENV ALL_MSGS="ADSBVehicle ActuatorControl Altitude AttitudeTarget CamIMUStamp CameraImageCaptured CellularStatus CommandCode CompanionProcessStatus DebugValue ESCInfo ESCInfoItem ESCStatus ESCStatusItem ESCTelemetry ESCTelemetryItem EstimatorStatus ExtendedState FileEntry GimbalDeviceAttitudeStatus GimbalDeviceInformation GimbalDeviceSetAttitude GimbalManagerInformation GimbalManagerSetAttitude GimbalManagerSetPitchyaw GimbalManagerStatus GPSINPUT GPSRAW GPSRTK GlobalPositionTarget HilActuatorControls HilControls HilGPS HilSensor HilStateQuaternion HomePosition LandingTarget LogData LogEntry MagnetometerReporter ManualControl Mavlink MountControl NavControllerOutput OnboardComputerStatus OpticalFlowRad OverrideRCIn Param ParamEvent ParamValue PlayTuneV2 PositionTarget RCIn RCOut RTCM RTKBaseline RadioStatus State StatusText TerrainReport Thrust TimesyncStatus Trajectory Tunnel VehicleInfo VfrHud Vibration Waypoint WaypointList WaypointReached WheelOdomStamped"
39-
4033
RUN git clone --branch release/1.14 https://github.com/px4/px4_msgs.git && \
4134
sed -i 's/\*\.msg/SensorGps.msg/g' px4_msgs/CMakeLists.txt && \
4235
git clone --branch gimbal-protocol-v2-plugin \
43-
https://github.com/adinkra-labs/mavros_feature_gimbal-protocol-v2-plugin.git mavros && \
44-
#sed -i 's/tf2_eigen.hpp/tf2_eigen.h/g' mavros/mavros_extras/src/plugins/gimbal_control.cpp && \
45-
for msg in $ALL_MSGS; do \
46-
if [[ $ENABLED_MSGS != *"$msg"* ]]; then \
47-
sed -i "s|msg/${msg}.msg|#&|g" mavros/mavros_msgs/CMakeLists.txt; \
48-
fi; \
49-
done
36+
https://github.com/adinkra-labs/mavros_feature_gimbal-protocol-v2-plugin.git mavros
5037

51-
# Find site-packages directory and assign its location to a build argument
52-
RUN PYTHON_SITE_PACKAGES=$(python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") && \
53-
echo "PYTHON_SITE_PACKAGES=$PYTHON_SITE_PACKAGES" > /tmp/python_site_packages.env
54-
55-
# end MAVROS extras and plugins
56-
# Build
38+
# Build gisnav, px4_msgs and mavros_msgs
5739
SHELL ["/bin/bash", "-c"]
5840
RUN source /opt/ros/${ROS_VERSION}/setup.bash && \
41+
apt-get -y update && \
42+
rosdep update && \
43+
rosdep install --from-paths . -y -r --ignore-src && \
5944
cd .. && \
6045
colcon build --packages-ignore mavros mavros_extras libmavconn
6146

62-
# multi-stage build - runtime stage
63-
FROM ros:${ROS_VERSION}
64-
65-
ARG ROS_VERSION
66-
ENV ROS_VERSION=${ROS_VERSION}
67-
68-
# Load PYTHON_SITE_PACKAGES environment variable from a file
69-
COPY --from=builder /tmp/python_site_packages.env /tmp/
70-
RUN export PYTHON_SITE_PACKAGES=$(cat /tmp/python_site_packages.env | cut -d'=' -f2)
71-
72-
COPY --from=builder /opt/colcon_ws/install /opt/colcon_ws/install
73-
COPY --from=builder /usr/share/GeographicLib /usr/share/GeographicLib
74-
COPY --from=builder /opt/colcon_ws/src/gisnav/docker/gisnav/entrypoint.sh /entrypoint.sh
75-
COPY --from=builder ${PYTHON_SITE_PACKAGES} ${PYTHON_SITE_PACKAGES}
76-
47+
# TODO: proper health check - check that public facing topics are publishing
7748
HEALTHCHECK --interval=10s --timeout=3s \
7849
CMD /bin/bash -c "source /opt/ros/${ROS_VERSION}/setup.bash && \
79-
ros2 node list | grep -q cv_node && \
50+
ros2 node list | grep -q pose_node && \
8051
ros2 node list | grep -q gis_node" || exit 1
8152

53+
8254
WORKDIR /opt/colcon_ws/src/gisnav
83-
SHELL ["/bin/bash", "-c"]
8455
ENTRYPOINT ["/entrypoint.sh"]

0 commit comments

Comments
 (0)