How to speed up CI build times when using docker?

I currently use docker + travis CI to test/ deploy my app. This works great locally because I have data volumes for things like node_modules etc, and docker’s layers provide caching speeding up builds.

However, when I push the code to travis it has to rebuild and install everything from scratch and it takes forever! Travis doesn’t support caching docker layers atm. Is there some other way to speed up my builds, or another similar tool that allows docker layer caching?

  • How to reduce docker image size?
  • Docker nginx, which nginx setup is most efficient?
  • Mongodb official image errno:111 Connection refused when trying to create replicaset
  • Docker container cannot resolve hostnames
  • Node cli program not working in windows machine
  • HTTPS with Docker Containerised Spring Boot App is not working
  • Brand new Ubuntu 14.04.2 Docker container + Nginx: connection refused on port 80
  • How to use Nginx to connect to my app in Docker image?
  • How to use Docker with Vue.js?
  • Mount data volume, then create symbolic link at container creation in docker
  • Docker breaks autofs directory in V1.5, used to work in V1.3.3
  • docker docker0 and container broadcast addresses not set
  • One Solution collect form web for “How to speed up CI build times when using docker?”

    You might want to investigate how i3wm has solved a similar problem.

    The main developer has written on the design behind his Travis CI workflow. Quoting the relevant part:

    The basic idea is to build a Docker container based on Debian testing
    and then run all build/test commands inside that container. Our
    Dockerfile installs compilers, formatters and other development tools
    first, then installs all build dependencies for i3 based on the
    debian/control file, so that we don’t need to duplicate build
    dependencies for Travis and for Debian.

    This solves the immediate issue nicely, but comes at a significant
    cost: building a Docker container adds quite a bit of wall clock time
    to a Travis run, and we want to give our contributors quick feedback.
    The solution to long build times is caching: we can simply upload the
    Docker container to the Docker Hub and make subsequent builds use the
    cached version.

    We decided to cache the container for a month, or until inputs to the
    build environment (currently the Dockerfile and debian/control)
    change. Technically, this is implemented by a little shell script
    called ha.sh (get it? hash!) which prints the SHA-256 hash of the
    input files. This hash, appended to the current month, is what we use
    as tag for the Docker container, e.g. 2016-03-3d453fe1.

    See our .travis.yml for how to plug it all together.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.