Skip to content

Commit

Permalink
Cache docker images
Browse files Browse the repository at this point in the history
  • Loading branch information
zenthangplus committed May 3, 2019
1 parent 4610a5c commit d06eea6
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,33 @@ php: 5.6
services:
- docker

env:
global:
- CACHE_DIR=$HOME/.cache/docker
- CACHE_FILE_PHP56=$CACHE_DIR/php5.6.tar.gz
- CACHE_FILE_PHP70=$CACHE_DIR/php7.0.tar.gz
- CACHE_FILE_PHP71=$CACHE_DIR/php7.1.tar.gz
- CACHE_FILE_PHP72=$CACHE_DIR/php7.2.tar.gz
- CACHE_FILE_PHP73=$CACHE_DIR/php7.3.tar.gz

cache:
directories:
- $CACHE_DIR

before_install:
- docker pull php:5.6
- docker pull php:7.0
- docker pull php:7.1
- docker pull php:7.2
- docker pull php:7.3
# Load images from cache directory
- if [ -f ${CACHE_FILE_PHP56} ]; then gunzip -c ${CACHE_FILE_PHP56} | docker load; fi
- if [ -f ${CACHE_FILE_PHP70} ]; then gunzip -c ${CACHE_FILE_PHP70} | docker load; fi
- if [ -f ${CACHE_FILE_PHP71} ]; then gunzip -c ${CACHE_FILE_PHP71} | docker load; fi
- if [ -f ${CACHE_FILE_PHP72} ]; then gunzip -c ${CACHE_FILE_PHP72} | docker load; fi
- if [ -f ${CACHE_FILE_PHP73} ]; then gunzip -c ${CACHE_FILE_PHP73} | docker load; fi
# Load and cache docker images into cache directory
- mkdir -p $CACHE_DIR
- if [ ! -f ${CACHE_FILE_PHP56} ]; then docker save php:5.6 | gzip > ${CACHE_FILE_PHP56}; fi
- if [ ! -f ${CACHE_FILE_PHP70} ]; then docker save php:7.0 | gzip > ${CACHE_FILE_PHP70}; fi
- if [ ! -f ${CACHE_FILE_PHP71} ]; then docker save php:7.1 | gzip > ${CACHE_FILE_PHP71}; fi
- if [ ! -f ${CACHE_FILE_PHP72} ]; then docker save php:7.2 | gzip > ${CACHE_FILE_PHP72}; fi
- if [ ! -f ${CACHE_FILE_PHP73} ]; then docker save php:7.3 | gzip > ${CACHE_FILE_PHP73}; fi

script:
- composer install
Expand Down

0 comments on commit d06eea6

Please sign in to comment.