forked from SteveMacenski/navigation2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
102 lines (87 loc) · 2.66 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# This dockerfile can be configured via --build-arg
# Build context must be the /navigation2 root folder for COPY.
# Example build command:
# export UNDERLAY_MIXINS="debug ccache"
# export OVERLAY_MIXINS="debug ccache coverage"
# docker build -t nav2:latest \
# --build-arg UNDERLAY_MIXINS \
# --build-arg OVERLAY_MIXINS ./
ARG FROM_IMAGE=osrf/ros2:nightly
# multi-stage for caching
FROM $FROM_IMAGE AS cache
# clone underlay source
ENV UNDERLAY_WS /opt/underlay_ws
RUN mkdir -p $UNDERLAY_WS/src
WORKDIR $UNDERLAY_WS
COPY ./tools/ros2_dependencies.repos ./
RUN vcs import src < ros2_dependencies.repos
# copy overlay source
ENV OVERLAY_WS /opt/overlay_ws
RUN mkdir -p $OVERLAY_WS/src
WORKDIR $OVERLAY_WS
COPY ./ src/navigation2
# copy manifests for caching
WORKDIR /opt
RUN find ./ -name "package.xml" | \
xargs cp --parents -t /tmp && \
find ./ -name "COLCON_IGNORE" | \
xargs cp --parents -t /tmp
# multi-stage for building
FROM $FROM_IMAGE AS build
# install CI dependencies
RUN apt-get update && apt-get install -q -y \
ccache \
lcov \
&& rm -rf /var/lib/apt/lists/*
# copy underlay manifests
ENV UNDERLAY_WS /opt/underlay_ws
COPY --from=cache /tmp/underlay_ws $UNDERLAY_WS
WORKDIR $UNDERLAY_WS
# install underlay dependencies
RUN . /opt/ros/$ROS_DISTRO/setup.sh && \
apt-get update && rosdep install -q -y \
--from-paths src \
--ignore-src \
&& rm -rf /var/lib/apt/lists/*
# copy underlay source
COPY --from=cache $UNDERLAY_WS ./
# build underlay source
ARG UNDERLAY_MIXINS="release ccache"
ARG FAIL_ON_BUILD_FAILURE=True
RUN . /opt/ros/$ROS_DISTRO/setup.sh && \
colcon build \
--symlink-install \
--mixin \
$UNDERLAY_MIXINS \
--event-handlers console_direct+ \
|| touch build_failed && \
if [ -f build_failed ] && [ -n "$FAIL_ON_BUILD_FAILURE" ]; then \
exit 1; \
fi
# copy overlay manifests
ENV OVERLAY_WS /opt/overlay_ws
COPY --from=cache /tmp/overlay_ws $OVERLAY_WS
WORKDIR $OVERLAY_WS
# install overlay dependencies
RUN . $UNDERLAY_WS/install/setup.sh && \
apt-get update && rosdep install -q -y \
--from-paths src \
--ignore-src \
&& rm -rf /var/lib/apt/lists/*
# copy overlay source
COPY --from=cache $OVERLAY_WS ./
# build overlay source
ARG OVERLAY_MIXINS="release ccache"
RUN . $UNDERLAY_WS/install/setup.sh && \
colcon build \
--symlink-install \
--mixin \
$OVERLAY_MIXINS \
|| touch build_failed && \
if [ -f build_failed ] && [ -n "$FAIL_ON_BUILD_FAILURE" ]; then \
exit 1; \
fi
# source overlay from entrypoint
RUN sed --in-place \
's|^source .*|source "$OVERLAY_WS/install/setup.bash"|' \
/ros_entrypoint.sh