在 GCB 中使用 Kaniko 的说明使用execkaniko 项目构建器的形式,如下所示:
- id: 'Build (with Kaniko Cache)'
name: 'gcr.io/kaniko-project/executor:latest'
args:
- --destination=$_GCR_HOSTNAME/$PROJECT_ID/$REPO_NAME:$SHORT_SHA
- --cache=true
- --cache-ttl=6h
Run Code Online (Sandbox Code Playgroud)
但我使用它来替换 docker 构建,其中我规避了exec使用形式,以便注入构建参数(来自 Secret Manager 的访问令牌),如此处和此处所述。
- id: 'Build'
name: gcr.io/cloud-builders/docker
entrypoint: 'bash'
args:
- '-c'
- |
docker build --cache-from $_GCR_HOSTNAME/$PROJECT_ID/$REPO_NAME:$SHORT_SHA --build-arg PERSONAL_ACCESS_TOKEN_GITHUB=$(cat decrypted-pat.txt) -t $_GCR_HOSTNAME/$PROJECT_ID/$REPO_NAME:$SHORT_SHA .
Run Code Online (Sandbox Code Playgroud)
我尝试定义一个bash入口点,但没有找到,所以我陷入困境。甚至可以运行非执行形式吗?
注意:可以访问容器内文件中的秘密,而不是通过构建参数,但这意味着更改我的开发人员的设置,让所有人都拥有该秘密文件,以便在本地构建他们的开发映像,我可以,但又实在不想做。
如何从我的 Google Cloud Build Pipeline访问我在Google Secret Manager 中定义的变量?
continuous-integration secret-key google-cloud-kms google-cloud-build google-secret-manager