I'm following the instructions at https://cloud.google.com/container-builder/docs/speeding-up-builds#using_a_cached_docker_image and I'm trying to setup docker builds that use the image cached from the previous build.
Here's what my cloudbuild.yml
looks like:
steps:
- name: 'gcr.io/cloud-builders/docker'
args: ['pull', 'gcr.io/$PROJECT_ID/$REPO_NAME:infra_docker']
- name: 'gcr.io/cloud-builders/docker'
args: ['build', '--cache-from', 'gcr.io/$PROJECT_ID/$REPO_NAME:infra_docker', '-t', 'gcr.io/$PROJECT_ID/$REPO_NAME:infra_docker', '.']
timeout: 120m
images: ['gcr.io/$PROJECT_ID/$REPO_NAME:infra_docker']
options:
machineType: 'N1_HIGHCPU_8'
Here's what my Dockerfile
starts with:
FROM ubuntu:14.04
SHELL ["/bin/bash", "-c"]
# lots of RUN commands after this
No matter what I try, the docker image pulled from the cache (as a result of the first step), is not used to speed up the actual docker build (second step). It always runs the entire 38 steps in my Dockerfile!
What am I doing wrong?
--cache-from
, I've shared what i've learned here, maybe it can help you to identify the issue: stackoverflow.com/a/56024061/149872 I dunno the specifics, but it sounds like the layers from the pulled image aren't the same anymore as the one you're trying to build (this could be for example if the parent image was updated). – Elias Dorneles