Skip to content

Commit 63ff4c7

Browse files
committed
Update package cache before cloning source
to avoid running rosdep update for each source change as docker build --no-cache can still be used to force update
1 parent d16f462 commit 63ff4c7

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

ros/content.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,23 +51,23 @@ ARG OVERLAY_WS=/opt/ros/overlay_ws
5151
FROM $FROM_IMAGE AS cacher
5252
ARG OVERLAY_WS
5353

54+
# update package cache
55+
RUN cat <<EOF > /etc/apt/apt.conf.d/docker-clean
56+
APT::Install-Recommends "false";
57+
APT::Install-Suggests "false";
58+
EOF && apt-get update && \
59+
rosdep update --rosdistro $ROS_DISTRO
60+
5461
# clone overlay source
5562
WORKDIR $OVERLAY_WS/src
56-
RUN cat <<EOF | vcs import .
63+
RUN cat <<EOF | vcs import .
5764
repositories:
5865
ros2/demos:
5966
type: git
6067
url: https://github.com/ros2/demos.git
6168
version: ${ROS_DISTRO}
6269
EOF
6370

64-
# update package cache
65-
RUN cat <<EOF > /etc/apt/apt.conf.d/docker-clean
66-
APT::Install-Recommends "false";
67-
APT::Install-Suggests "false";
68-
EOF && apt-get update && \
69-
rosdep update --rosdistro $ROS_DISTRO
70-
7171
# derive build/exec dependencies
7272
RUN bash -e <<'EOF'
7373
declare -A types=(
@@ -131,7 +131,7 @@ RUN sed --in-place --expression \
131131
CMD ["ros2", "launch", "demo_nodes_cpp", "talker_listener_launch.py"]
132132
```
133133

134-
The example above uses consists of three sequential stages. The `cacher` stage first uses [`vcstool`](https://github.com/dirk-thomas/vcstool) to clone a demo repo into the workspace source directory, updates the apt lists and ROS index, and derives build and runtime dependencies sets using [`rosdep`](https://docs.ros.org/en/rolling/Tutorials/Intermediate/Rosdep.html). The `builder` stage apt installs the derived build dependencies, sources the ROS install underlay, and compiles the source via release mode using [`colcon`](https://docs.ros.org/en/rolling/Tutorials/Beginner-Client-Libraries/Colcon-Tutorial.html). Finally, `runner` stage apt installs only runtime dependencies, copies the compiled workspace artifacts, and sets up the environment to launch the demo. Note the example consists of several subtle optimizations:
134+
The example above uses consists of three sequential stages. The `cacher` stage first updates the apt lists and ROS index, uses [`vcstool`](https://github.com/dirk-thomas/vcstool) to clone a demo repo into the workspace source directory, and derives build and runtime dependencies sets using [`rosdep`](https://docs.ros.org/en/rolling/Tutorials/Intermediate/Rosdep.html). The `builder` stage apt installs the derived build dependencies, sources the ROS install underlay, and compiles the source via release mode using [`colcon`](https://docs.ros.org/en/rolling/Tutorials/Beginner-Client-Libraries/Colcon-Tutorial.html). Finally, `runner` stage apt installs only runtime dependencies, copies the compiled workspace artifacts, and sets up the environment to launch the demo. Note the example consists of several subtle optimizations:
135135

136136
- colcon
137137
- build cache if deps are unchanged

0 commit comments

Comments
 (0)