I have a Dockerfile
that I'm using to build an image that will run on Google Compute Engine.
Part of the Dockerfile
should pull a Google Cloud Source Repo and add it to the image.
I'm getting the error below when using Cloud Builder:
```
Step 6/6 : RUN gcloud source repos clone repoXXX --project=projectXXX
---> Running in xxx
[91mERROR: (gcloud.source.repos.clone) You do not currently have an active account selected.
Please run:
$ gcloud auth login
to obtain new credentials, or if you have already logged in with a different account:
$ gcloud config set account ACCOUNT
to select an already authenticated account to use.
The command '/bin/sh -c gcloud source repos clone repoXXX --
project=projectXXX' returned a non-zero code: 1
```
I'm not sure what I'm doing wrong here?
I'm not using a cloudbuild.yaml
file, but I assumed that the cloudbuilder service account would be able to pull the repo since it has Editor access in IAM.
What should I do to build the image successfully?
Update:
If you found this question, I was able to add the Google Cloud Source Repos by building following the two steps below:
cloudbuild.yaml
file and including the steps below:
steps:
# Pull Search Console repo to include in the build.
- name: 'gcr.io/cloud-builders/gcloud'
args: ['source', 'repos', 'clone', 'xxx']
Dockerfile
you can copy the repo from your workspace into your new image:
FROM xxx:latest
# Copy the repo into Docker
copy xxx /xxx
You can read more about creating a basic build configuration file here.
Add --network=cloudbuild
to your args
to allow the builder service account credentials to pass through to your Dockerfile steps.
steps:
- name: gcr.io/cloud-builders/docker
args: ['build', '-t', 'THE_IMAGE', '--network=cloudbuild', '.']