Reputation: 97
I got my project in gitlab and push it to Google Cloud Plattform, to build, push and deploy. The first step building it, works fine and finished with:
Built and pushed image as gcr.io/my-project/backend
But always the second step is failing with this:
The push refers to repository [gcr.io/my-project/backend] An image does not exist locally with the tag: gcr.io/my-project/backend
My cloudbuild.yaml
# build the container image
- name: 'gcr.io/cloud-builders/mvn:3.5.0-jdk-8'
args: ['clean', 'install', 'jib:build', '-Dimage=gcr.io/$PROJECT_ID/backend']
# push the container image
- name: 'gcr.io/cloud-builders/docker'
args: [ 'push', 'gcr.io/$PROJECT_ID/backend:latest']
Upvotes: 1
Views: 3130
Reputation: 76799
You'd have to tag the image with the args
:
- name: gcr.io/cloud-builders/docker
id: 'backend'
args: [
'build',
'-t', 'gcr.io/$PROJECT_ID/backend:${SHORT_SHA}',
'-t', 'gcr.io/$PROJECT_ID/backend:latest',
...
]
An images
block also seems to be missing:
images:
- 'gcr.io/$PROJECT_ID/backend:${SHORT_SHA}'
- 'gcr.io/$PROJECT_ID/backend:latest'
With image-tagging set up, that error message should disappear.
And in order to configure Docker for the Google Container Registry:
gcloud auth configure-docker
See Storing images in Container Registry for reference.
Upvotes: 1