save_docker_cache.sh 1.1 KB

123456789101112131415161718192021222324252627282930
  1. #!/bin/bash
  2. # Copyright 2016 The Cartographer Authors
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. # Cache intermediate Docker layers. For a description of how this works, see:
  16. # https://giorgos.sealabs.net/docker-cache-on-travis-and-docker-112.html
  17. set -o errexit
  18. set -o verbose
  19. set -o pipefail
  20. if [[ ${TRAVIS_BRANCH} == "master" ]] &&
  21. [[ ${TRAVIS_PULL_REQUEST} == "false" ]]; then
  22. mkdir -p $(dirname ${DOCKER_CACHE_FILE})
  23. IMAGE_NAMES=$(docker history -q cartographer_ros:${ROS_RELEASE} | grep -v '<missing>')
  24. docker save ${IMAGE_NAMES} | gzip > ${DOCKER_CACHE_FILE}.new
  25. mv ${DOCKER_CACHE_FILE}.new ${DOCKER_CACHE_FILE}
  26. fi