I have docker multistage build, for example:
FROM golang:1.7.3
WORKDIR /go/src/github.com/alexellis/href-counter/
RUN go get -d -v golang.org/x/net/html
COPY app.go .
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app .
FROM alpine:latest
RUN apk --no-cache add ca-certificates
WORKDIR /root/
COPY --from=0 /go/src/github.com/alexellis/href-counter/app .
CMD ["./app"]
Than I have cloudbuild.yml:
steps:
- name: 'gcr.io/cloud-builders/docker'
args: ['pull', 'gcr.io/$PROJECT_ID/app:$BRANCH_NAME']
- name: 'gcr.io/cloud-builders/docker'
args: ['pull', 'gcr.io/$PROJECT_ID/app:latest']
- name: 'gcr.io/cloud-builders/docker'
args: [
'build',
'--cache-from', 'gcr.io/$PROJECT_ID/app:latest',
'--cache-from', 'gcr.io/$PROJECT_ID/app:$BRANCH_NAME',
'--build-arg', 'COMMIT_HASH=$COMMIT_SHA',
'-t', 'gcr.io/$PROJECT_ID/app:$COMMIT_SHA',
'-f', 'config/dockerfiles/app.dockerfile',
'.'
]
- name: 'gcr.io/cloud-builders/docker'
args: ["tag", "gcr.io/$PROJECT_ID/app:$COMMIT_SHA", "gcr.io/$PROJECT_ID/app:$BRANCH_NAME"]
- name: 'gcr.io/cloud-builders/docker'
args: ["tag", "gcr.io/$PROJECT_ID/app:$COMMIT_SHA", "gcr.io/$PROJECT_ID/app:latest"]
images: [
'gcr.io/$PROJECT_ID/app:$COMMIT_SHA',
'gcr.io/$PROJECT_ID/app:$BRANCH_NAME',
'gcr.io/$PROJECT_ID/app:latest'
]
Now I want to cache not only the resulting image but also the builder step. For example, in go I have /vendor which I construct using dep, and would like to cache those dependencies. How would I acchieve that the easiest with google cloud platform? I think my question is mostly docker specific, but still.