虽然我已经查看了多个stackoverflow的问题与答案,但是在使用Dockerfile来构建我的Node.js应用并包含私有库依赖时,我仍未能完全解决我的问题。以下是我的Dockerfile中相关的部分:
FROM node:8.7.0-alpine
RUN \
# install required packages
apk --no-cache add --virtual \
builds-deps \
build-base \
python \
git \
openssh-client
# git config
RUN git config --global user.name "*****"
RUN git config --global user.email "*****@*****.co"
# *******************
# install git ssh key
# *******************
# create ssh dir
RUN mkdir /root/.ssh
# Copy over private key from volume and set permissions
ADD bitbucket_rsa /root/.ssh/bitbucket_rsa
RUN chmod 600 /root/.ssh/bitbucket_rsa
# start agent
RUN eval $(ssh-agent)
# load key into agent
RUN echo ssh-add /root/.ssh/bitbucket_rsa
RUN echo -e "Host bitbucket.org\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config
...
这是从NPM抛出的内容:
npm ERR! Error while executing:
npm ERR! /usr/bin/git ls-remote -h -t ssh://git@bitbucket.org/someteamname/somereponame.git
npm ERR!
npm ERR! Warning: Permanently added 'bitbucket.org,XXX.XXX.XXX.XXX' (RSA) to the list of known hosts.
npm ERR! Permission denied (publickey).
npm ERR! fatal: Could not read from remote repository.
npm ERR!
npm ERR! Please make sure you have the correct access rights
npm ERR! and the repository exists.
npm ERR!
npm ERR! exited with error code: 128
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2017-10-27T01_12_06_116Z-debug.log
我这里漏掉了什么?非常感谢您的帮助!