【发布时间】:2018-10-04 18:14:44
【问题描述】:
我有一个Dockerfile 用于构建将在 Google Compute Engine 上运行的映像。
Dockerfile 的一部分应提取 Google Cloud Source Repo 并将其添加到图像中。
使用 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
```
我不确定我在这里做错了什么?
我没有使用 cloudbuild.yaml 文件,但我认为 cloudbuilder 服务帐户能够提取存储库,因为它在 IAM 中具有编辑器访问权限。
我应该怎么做才能成功构建镜像?
更新:
如果您发现了这个问题,我可以通过以下两个步骤构建来添加 Google Cloud Source Repos:
- 构建
cloudbuild.yaml文件并包括以下步骤:
steps:
# Pull Search Console repo to include in the build.
- name: 'gcr.io/cloud-builders/gcloud'
args: ['source', 'repos', 'clone', 'xxx']
- 在
Dockerfile中,您可以将工作区中的存储库复制到新映像中:
FROM xxx:latest
# Copy the repo into Docker
copy xxx /xxx
你可以阅读更多关于creating a basic build configuration file here的信息。
【问题讨论】:
-
您定义的步骤不会创建 docker 映像,那么如何添加
FROM xxx:latest?
标签: google-compute-engine google-container-registry