Last active
November 13, 2020 04:26
-
-
Save hc2p/9e284cee3d585eefbc59454e44cc247a to your computer and use it in GitHub Desktop.
This is a prove of concept for leveraging the travis directory caching for speeding up docker builds. It works by configuring the docker deamon to use a folder under current user's (travis) control. That way you have the privileges to use the caching feature of travis ci.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo: false | |
services: | |
- docker | |
before_script: | |
- sudo service docker stop | |
- if [ "$(ls -A /home/travis/docker)" ]; then echo "/home/travis/docker already set"; else sudo mv /var/lib/docker /home/travis/docker; fi | |
- sudo bash -c "echo 'DOCKER_OPTS=\"-H tcp://127.0.0.1:2375 -H unix:///var/run/docker.sock -g /home/travis/docker\"' > /etc/default/docker" | |
- sudo service docker start | |
- docker build -f Dockerfile-testenv -t testenv . | |
script: | |
- docker run testenv | |
before_cache: | |
- sudo service docker stop | |
- sudo chown -R travis ~/docker | |
cache: | |
directories: | |
~/docker |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
docker save
and load from cache usingdocker load
.docker push
/pull
to/from hub.docker.com (after securely setting$DOCKER_PASSWORD
in travis)