我正在尝试使用GCB部署我的项目,但遇到了一些麻烦。
代码:cloudbuild.yml
steps:
- name: 'ngocquyhoang/google-cloud-build:wordpress'
args: ['deploy']
env:
- 'BUILD_USER=$_USER'
- 'BUILD_HOST=$_HOST'
- 'BUILD_KEY=$_KEY'
- 'BUILD_PATH=$_PATH'
我的Dockerfile是构建ngocquyhoang/google-cloud-build:wordpress
映像:
FROM alpine:3.10.2
MAINTAINER Hoang Ngoc Quy <ngocquyhoang3112@gmail.com>
RUN apk update
RUN apk upgrade
RUN apk add --no-cache rsync
RUN apk add --no-cache openssh
COPY docker-entrypoint.sh /script/docker-entrypoint.sh
WORKDIR /app/deploy
ENTRYPOINT ["/bin/sh", "/script/docker-entrypoint.sh"]
CMD ["deploy"]
文件docker-entrypoint.sh
#!/bin/bash
mkdir -p /root/.ssh
ssh-keyscan -H "$BUILD_HOST" >> /root/.ssh/known_hosts
echo -e $BUILD_KEY >> /root/.ssh/id_rsa
chmod 400 /root/.ssh/id_rsa
rsync --progress -avzh --exclude='.git/' -e "ssh -i /root/.ssh/id_rsa" --rsync-path="sudo rsync" . $BUILD_USER@$BUILD_HOST:$BUILD_PATH
并生成日志:
starting build "918f3629-1f0d-4aa5-88d3-0b41881fd997"
FETCHSOURCE
Initialized empty Git repository in /workspace/.git/
From https://source.developers.google.com/p/web-business-ngocquyhoang/r/github_ngocquyhoang_ngocquyhoang.com
* branch 5334462fc8a04af254df5732a6a06c103aa3c355 -> FETCH_HEAD
HEAD is now at 5334462 Initalize Wordpress project
BUILD
Pulling image: ngocquyhoang/google-cloud-build:wordpress
wordpress: Pulling from ngocquyhoang/google-cloud-build
9d48c3bd43c5: Already exists
02b3c1508e63: Pulling fs layer
ef329cd56c87: Pulling fs layer
9038e45f84ab: Pulling fs layer
0cb09c508cdd: Pulling fs layer
65085a1c6b91: Pulling fs layer
f7b667cefe20: Pulling fs layer
0cb09c508cdd: Waiting
65085a1c6b91: Waiting
f7b667cefe20: Waiting
ef329cd56c87: Verifying Checksum
ef329cd56c87: Download complete
9038e45f84ab: Verifying Checksum
9038e45f84ab: Download complete
02b3c1508e63: Verifying Checksum
02b3c1508e63: Download complete
02b3c1508e63: Pull complete
0cb09c508cdd: Verifying Checksum
0cb09c508cdd: Download complete
f7b667cefe20: Verifying Checksum
f7b667cefe20: Download complete
65085a1c6b91: Download complete
ef329cd56c87: Pull complete
9038e45f84ab: Pull complete
0cb09c508cdd: Pull complete
65085a1c6b91: Pull complete
f7b667cefe20: Pull complete
Digest: sha256:0b766eb75b859a53af719f05ceaf4448063eaf7edc3cbc719401c11f7dad6ff2
Status: Downloaded newer image for ngocquyhoang/google-cloud-build:wordpress
docker.io/ngocquyhoang/google-cloud-build:wordpress
# 34.87.20.97:22 SSH-2.0-OpenSSH_7.6p1 Ubuntu-4ubuntu0.3
# 34.87.20.97:22 SSH-2.0-OpenSSH_7.6p1 Ubuntu-4ubuntu0.3
# 34.87.20.97:22 SSH-2.0-OpenSSH_7.6p1 Ubuntu-4ubuntu0.3
Load key "/root/.ssh/id_rsa": error in libcrypto
deploy@34.87.20.97: Permission denied (publickey).
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(226) [sender=3.1.3]
ERROR
ERROR: build step 0 "ngocquyhoang/google-cloud-build:wordpress" failed: exit status 12
请帮助我,谢谢!!!!