Reputation: 218
I am unable to deploy a cloud function through google cloud build, receiving the error:
BUILD
Already have image (with digest): gcr.io/cloud-builders/docker
unable to prepare context: unable to evaluate symlinks in Dockerfile path: lstat /workspace/Dockerfile: no such file or directory
ERROR
ERROR: build step 0 "gcr.io/cloud-builders/docker" failed: exit status 1
My git repo structure is
myrepo/cloudbuild.yaml
myrepo/new-user/index.js
myrepo/new-user/package.json
And my cloudbuild.yaml is as follows
steps:
- name: 'gcr.io/cloud-builders/gcloud'
id: 'newUser'
args: ['functions',
'deploy',
'newUser',
'--source=./new-user/.',
'--trigger-event=providers/cloud.firestore/eventTypes/document.create',
'--trigger-resource=projects/myproject/databases/default/documents/userLocations/{user}',
'--runtime=nodejs8']
I thought for cloud functions, only the cloudbuild.yaml is required, which is why the Dockerfile error is confusing.
Running the following on the command line works fine.
gcloud functions deploy newUser --runtime=nodejs8 --trigger-event=providers/cloud.firestore/eventTypes/document.create --trigger-resource=projects/myproject/databases/default/documents/userLocations/{user} --source=./new-user/.
Thanks.
Upvotes: 1
Views: 2773
Reputation: 1174
As I just ran into this, the problem for me was linked to the fact that I was working in a monorepo and had to redefine the workspace location Cloud Build would use to find the Dockerfile by adding a dir
to my cloudbuild file.
My Cloud Build trigger was setup to look for a cloudbuild file that was located under: <root>/apps/<subfolder>/cloudbuild.yaml
The cloudbuild file was properly picked up by CloudBuild, the build would start but then errored as the Dockerfile was not found.
YAML example:
steps:
- name: 'gcr.io/cloud-builders/docker'
args: [ 'build', '-t', 'us-west2-docker.pkg.dev/$PROJECT_ID/quickstart-docker-repo/quickstart-image:tag1', '.' ]
dir: 'apps/<subfolder>'
images:
- 'us-west2-docker.pkg.dev/$PROJECT_ID/quickstart-docker-repo/quickstart-image:tag1'
Reference: Docs
Upvotes: 2
Reputation: 693
Your repository has no Dockerfile
, so you cannot use a non-existent Dockerfile
to build.
Since you are trying to make a serverless container that needs a Docker image as input.
Upvotes: 1