我在使用 Google Cloud Build 时遇到问题。我无法通过 cloudbuild.yaml 将密钥传递给 docker
谷歌构建文件.yaml:
- name: 'gcr.io/cloud-builders/gcloud'
args:
- kms
- decrypt
- --ciphertext-file=A.enc
- --plaintext-file=/root/.ssh/id_rsa
- --location=global
- --keyring=keyringxxx
- --key=keyxxx
volumes:
- name: 'ssh'
path: /root/.ssh
- name: 'gcr.io/cloud-builders/docker'
args: [
'build', '.',
'-t', 'gcr.io/$PROJECT_ID/xxx:latest',
'--build-arg', 'READ_KEY=`cat /root/.ssh/id_rsa`'
]
volumes:
- name: 'ssh'
文件:
FROM golang:1.11 AS builder
ARG READ_KEY
RUN mkdir -p ~/.ssh && \
echo "$READ_KEY" > ~/.ssh/id_rsa && \
chmod 0600 ~/.ssh/id_rsa && \
ssh-keyscan github.com >> /root/.ssh/known_hosts && \
git config --global url.ssh://git@github.com/XXXX.insteadOf https://github.com/XXXX
......
上面的代码失败了。cat不起作用。
尚方宝剑之说
海绵宝宝撒
繁华开满天机
相关分类