FROM phusion/passenger-ruby21:latest
RUN apt-get update
RUN apt-get install sl
WORKDIR /tmp
ADD Gemfile /tmp/
ADD Gemfile.lock /tmp/
RUN bundle install
What we are doing in circle.yml is very simple:
Pull image from Docker Hub that was pushed from previous builds
Build image from Dockerfile
Push the image back to Docker Hub for the subsequent builds
In short, we are using Docker Hub as our image cache store.
To see how caching works, you can compare this and this builds.
In the first build, docker build took about 3 mins and docker push took 2 mins, but both commands finish immediately in the second build thanks to cache.
How are we handling the fact that now you are pushing a latest image in your registry? You might use that registry also for CD, how do you make sure you are not going to deploy a potentially broken image? Also, how do you handle the fact that now multiple branches share the same cache? This could lead to invalidating the cache more often at best, or to undeterministic results in your builds at worst
@itajaja Sorry, my approach is a bit rough and doesn’t guarantee what you’ve mentioned. And yes, as @agrothberg mentioned, I think we should be able to do similar approach that CodeShip does.