From 2533e3b0d389b97f36bbf4b926d3f97cea95feea Mon Sep 17 00:00:00 2001 From: Fabian Jakobs Date: Mon, 8 Feb 2016 09:21:33 +0000 Subject: [PATCH] make sure to use the right ssh key for github --- b9/containers/newclient/Dockerfile | 1 + b9/lib/_npm.sh | 26 +++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/b9/containers/newclient/Dockerfile b/b9/containers/newclient/Dockerfile index 545623d6..a779c78b 100644 --- a/b9/containers/newclient/Dockerfile +++ b/b9/containers/newclient/Dockerfile @@ -40,6 +40,7 @@ RUN apt-get install -y haproxy RUN apt-get install -y git ADD files/ssh_config /home/ubuntu/.ssh/config +RUN chown -R ubuntu:ubuntu /home/ubuntu/.ssh USER ubuntu diff --git a/b9/lib/_npm.sh b/b9/lib/_npm.sh index cd16ce5e..565f23c8 100644 --- a/b9/lib/_npm.sh +++ b/b9/lib/_npm.sh @@ -1,8 +1,32 @@ + + _b9_npm() { local WORKDIR=$1 shift - docker run --rm -w /home/ubuntu/newclient -v $WORKDIR:/home/ubuntu/newclient -v $HOME/.ssh:/home/ubuntu/.ssh:ro --sig-proxy -a STDIN -a STDOUT -a STDERR $(_b9_get_newclient_image) npm "$@" + docker run \ + --rm \ + -w /home/ubuntu/newclient \ + -v $WORKDIR:/home/ubuntu/newclient \ + --sig-proxy -a STDIN -a STDOUT -a STDERR \ + $(_b9_get_newclient_image) bash -c " + echo \"$(_b9_npm_get_github_ssh)\" >> /home/ubuntu/.ssh/id_rsa_deploy + chmod 600 /home/ubuntu/.ssh/id_rsa_deploy + npm "$@" + " # pushd $WORKDIR # npm "$@" # popd +} + +_b9_npm_get_github_ssh() { + local FILE + for FILE in "$B9_GITHUB_SSH_FILE" ~/.ssh/id_rsa_c9robot ~/.ssh/id_rsa_deploy ~/.ssh/id_rsa; do + if [ -e "$FILE" ]; then + cat $FILE + return + fi + done + + echo "Can't find SSH key for Github" 1>&2 + exit 1 } \ No newline at end of file