Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I "rehydrate" a docker build cache from a remote container repository?

TL;DR

I'm building an ASP.NET app using docker build; when I run the build on my local machine, it quickly executes because I'm making use of the Build cache.

Step 1/10 : FROM microsoft/aspnetcore-build:2.0.0 as identity-build
 ---> c5549d4c5716
Step 2/10 : ENV DOTNET_SKIP_FIRST_TIME_EXPERIENCE=true
 ---> Using cache
 ---> 060911817d8c
Step 3/10 : WORKDIR /publish
 ---> Using cache
 ---> 851e87c05c42

I'm trying to do the same on an AppVeyor CI, but because AppVeyor gives me a clean VM image for every build, there is no cache.

I've tried experimenting with pulling the build images from a private container repository, but this does not seem to "rehydrate the image cache", as a result, there are no cache hits.

Background

I've created an example GitHub repo, and an associated build in AppVeyor with which I'm experimenting.

I've tried to restore the build images from a private container repository, but this has not resulted in any cache hits.

I'm trying to achieve two objectives by using the docker build cache.

  1. Faster builds.
  2. Determine whether the code has changed and use this to decide whether a deployment is necessary.

First of all, I'm just trying to get the build cache rehydrated, and continue experimenting from there.

like image 756
James Skimming Avatar asked Jan 28 '23 07:01

James Skimming


1 Answers

It seems the combination of a good night's sleep and the act of trying to compose this question has helped my Google-fu, as I've now found the answer :-)

docker build can be instructed to use an image for its cache with the --cache-from parameter.

For example (taken from here)

docker pull myimage:v1.0
docker build --cache-from myimage:v1.0 -t myimage:v1.1 .
like image 172
James Skimming Avatar answered Jan 31 '23 09:01

James Skimming