【发布时间】:2019-07-06 17:50:59
【问题描述】:
我正在尝试使用 Drone ci 在 Google 云计算引擎上自动部署我的应用程序。我尝试了很多方法,但我无法部署任何东西。
我的测试和发布阶段运行良好,我可以将我的代码自动推送到我的谷歌容器注册表,无人机构建映像并推送它。
我对我的计算引擎实例进行了身份验证,我试图让机器连接到谷歌容器注册表,但我无法设法运行构建的图像。这是我缺少的最后一步,我做不到。
这是我的 .drone-ci.yml 文件,包含以下步骤:
kind: pipeline
name: my-app
steps:
- name: test
image: node:11-alpine
commands:
- npm install
- npm run test
- name: publish
image: plugins/gcr
settings:
repo: project-id/my-app
dockerfile: Dockerfile
tags: latest
json_key:
from_secret: google_credentials
- name: deploy
image: google/cloud-sdk:alpine
environment:
google_credentials:
from_secret: google_credentials
commands:
- echo $google_credentials > /tmp/$CI_PIPELINE_ID.json
- gcloud auth activate-service-account --key-file /tmp/$CI_PIPELINE_ID.json
- gcloud compute ssh my-instance --zone my-zone --command "cat $google_credentials | sudo docker login -u _json_key --password-stdin https://gcr.io"
- gcloud compute ssh my-instance --zone us-east1-b --command "sudo docker run -d -p 80:3000 --restart always --env-file ./env.list gcr.io/project-id/my-app:latest"
它抛出这个错误(是最后一个错误):
cat: '{': No such file or directory
bash: line 1: type:: command not found
bash: line 2: project_id:: command not found
bash: line 3: private_key_id:: command not found
bash: line 4: private_key:: command not found
bash: line 5: client_email:: command not found
bash: line 6: client_id:: command not found
bash: line 7: auth_uri:: command not found
bash: line 8: token_uri:: command not found
bash: line 9: auth_provider_x509_cert_url:: command not found
bash: line 10: client_x509_cert_url:: command not found
bash: -c: line 11: syntax error near unexpected token `}'
bash: -c: line 11: `} | sudo docker login -u _json_key --password-stdin
https://gcr.io'
我尝试了其他方式,但我从未成功通过 google 容器注册表进行身份验证。 如何从实例中验证 docker 守护进程?
【问题讨论】:
标签: docker google-compute-engine gcloud drone.io