3 回答

TA貢獻1809條經(jīng)驗 獲得超8個贊
GCloud?Docker Builder使用ENTRYPOINT的 Exec 形式。您來自 cloudbuild.yaml 的參數(shù)沒有傳遞給 shell,因此您的參數(shù)cat
不會被執(zhí)行。
為什么不指示 KMSid_rsa
直接寫入/workspace
并完全取消卷ssh
?
- name: 'gcr.io/cloud-builders/gcloud'
? args:
? - kms
? - decrypt
? - --ciphertext-file=A.enc
? - --plaintext-file=/workspace/id_rsa
? - --location=global
? - --keyring=keyringxxx
? - --key=keyxxx
- name: 'gcr.io/cloud-builders/docker'
? args: [
? ? 'build', '.',
? ? '-t', 'gcr.io/$PROJECT_ID/xxx:latest'
? ]
Dockerfile 變?yōu)椋?/p>
FROM golang:1.11 AS builder
RUN mkdir -p ~/.ssh
COPY id_rsa ~/.ssh/
RUN ssh-keyscan github.com >> ~/.ssh/known_hosts && \
? ? chmod -R 0600 ~/.ssh/ && \
? ? git config --global url.ssh://git@github.com:.insteadOf https://github.com
不要忘記將它安裝.gitconfig到額外的構(gòu)建步驟中。我只是將它作為我的 CI 構(gòu)建腳本的一部分,而不是需要額外的volume.

TA貢獻1816條經(jīng)驗 獲得超4個贊
對于步驟有問題的任何人:
COPY id_rsa ~/.ssh/
在 docker build 中不持久的地方~/.ssh/id_rsa
,對我有用的解決方法是先將文件復(fù)制到 App 文件中的目錄,然后將其復(fù)制到最終目錄:
ADD id_rsa /app/id_rsa RUN cp /app/id_rsa ~/.ssh/id_rsa
我不確定為什么會這樣,但是好吧,給你。
- 3 回答
- 0 關(guān)注
- 206 瀏覽
添加回答
舉報