im trying to use Drone ci for automaticaly deploy my app on Google cloud Compute Engine. Im tried in a lot of ways, but i cant deploy anything.
I have the test and publish stages running fine, i can push autimaticaly my code to my google container registry, drone build the image and push it.
I auth to my compute engine instance, i'm stuck trying to get the machine connected to the google container registry, but I can not manage to run the built images. This is the last step that I lack, and I can not do it.
This is my .drone-ci.yml file with the steps:
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"
it throw this error (is the last error):
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'
i tried in other ways, but i never auth successfully to google container registry. How can i do auth the docker deamon from the instance?