Improve Docker caching. (#139)

master
Damon Kohler 2016-10-23 18:16:12 +02:00 committed by GitHub
parent 20487028ed
commit 6dd217beab
4 changed files with 75 additions and 24 deletions

View File

@ -13,15 +13,49 @@
# limitations under the License.
FROM ros:indigo
# wstool needs the updated rosinstall file to clone the correct repos.
COPY cartographer_ros.rosinstall cartographer_ros/
COPY scripts/prepare_catkin_workspace.sh cartographer_ros/scripts/
# Remove the contents of the cartographer_ros repo and copy in the updated
# files as necessary.
RUN cartographer_ros/scripts/prepare_catkin_workspace.sh && \
rm -rf catkin_ws/src/cartographer_ros/*
# rosdep needs the updated package.xml files to install the correct debs.
COPY cartographer_ros/package.xml cartographer_ros/cartographer_ros/
COPY cartographer_ros_msgs/package.xml cartographer_ros/cartographer_ros_msgs/
COPY cartographer_rviz/package.xml cartographer_ros/cartographer_rviz/
COPY ceres_solver/package.xml cartographer_ros/ceres_solver/
COPY cartographer_ros/package.xml catkin_ws/src/cartographer_ros/cartographer_ros/
COPY cartographer_ros_msgs/package.xml catkin_ws/src/cartographer_ros/cartographer_ros_msgs/
COPY cartographer_rviz/package.xml catkin_ws/src/cartographer_ros/cartographer_rviz/
COPY ceres_solver/package.xml catkin_ws/src/cartographer_ros/ceres_solver/
COPY scripts/install_debs.sh cartographer_ros/scripts/
RUN cartographer_ros/scripts/install_debs.sh && rm -rf /var/lib/apt/lists/*
COPY . cartographer_ros
RUN cartographer_ros/scripts/install_cartographer_ros.sh && rm -rf catkin_ws
# Build, install, and test all packages individually to allow caching.
COPY scripts/install.sh cartographer_ros/scripts/
COPY ceres_solver catkin_ws/src/cartographer_ros/
RUN cartographer_ros/scripts/install.sh --pkg ceres_solver
# This file's content changes whenever master changes. See:
# http://stackoverflow.com/questions/36996046/how-to-prevent-dockerfile-caching-git-clone
ADD https://api.github.com/repos/googlecartographer/cartographer/git/refs/heads/master \
cartographer_ros/cartographer_version.json
RUN cartographer_ros/scripts/install.sh --pkg cartographer && \
cartographer_ros/scripts/install.sh --pkg cartographer --make-args test
COPY cartographer_ros_msgs catkin_ws/src/cartographer_ros/
RUN cartographer_ros/scripts/install.sh --pkg cartographer_ros_msgs \
--catkin-make-args run_tests
COPY cartographer_ros catkin_ws/src/cartographer_ros/
RUN cartographer_ros/scripts/install.sh --pkg cartographer_ros \
--catkin-make-args run_tests
COPY cartographer_rviz catkin_ws/src/cartographer_ros/
RUN cartographer_ros/scripts/install.sh --pkg cartographer_rviz \
--catkin-make-args run_tests
COPY scripts/ros_entrypoint.sh /
# A BTRFS bug may prevent us from cleaning up these directories.
# https://btrfs.wiki.kernel.org/index.php/Problem_FAQ#I_cannot_delete_an_empty_directory
RUN rm -rf cartographer_ros catkin_ws || true

View File

@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
# Copyright 2016 The Cartographer Authors
#
@ -21,10 +21,6 @@ set -o verbose
cd catkin_ws
# Use the local version of cartographer_ros to include local modifications.
rm -rf src/cartographer_ros
mv ../cartographer_ros src
# Build, install, and test.
#
# It's necessary to use the '--install' flag for every call to
@ -33,5 +29,4 @@ mv ../cartographer_ros src
# avoid any issues caused by using 'CMAKE_INSTALL_PREFIX' during the
# configuration phase of the build (e.g. cartographer/common/config.h.cmake).
export BUILD_FLAGS="--use-ninja --install-space /opt/cartographer_ros --install"
catkin_make_isolated ${BUILD_FLAGS} --catkin-make-args run_tests
catkin_make_isolated ${BUILD_FLAGS} --pkg cartographer --make-args test
catkin_make_isolated ${BUILD_FLAGS} $@

View File

@ -17,21 +17,14 @@
set -o errexit
set -o verbose
. /opt/ros/${ROS_DISTRO}/setup.sh
cd catkin_ws
# Install Ninja.
sudo apt-get update
sudo apt-get install -y ninja-build
. /opt/ros/${ROS_DISTRO}/setup.sh
# Create a new workspace in 'catkin_ws'.
mkdir catkin_ws
cd catkin_ws
wstool init src
# Merge the cartographer_ros.rosinstall file and fetch code for dependencies.
wstool merge -t src ../cartographer_ros/cartographer_ros.rosinstall
wstool update -t src
# Install rosdep dependencies.
rosdep update
rosdep install --from-paths src --ignore-src --rosdistro=${ROS_DISTRO} -y

View File

@ -0,0 +1,29 @@
#!/bin/sh
# Copyright 2016 The Cartographer Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -o errexit
set -o verbose
. /opt/ros/${ROS_DISTRO}/setup.sh
# Create a new workspace in 'catkin_ws'.
mkdir catkin_ws
cd catkin_ws
wstool init src
# Merge the cartographer_ros.rosinstall file and fetch code for dependencies.
wstool merge -t src ../cartographer_ros/cartographer_ros.rosinstall
wstool update -t src