Tôi đang trong quá trình thiết lập việc triển khai Dịch vụ Node.js bằng Docker.Docker + Nodejs + Repo riêng tư + Module NPM riêng tư - Các sự cố truy cập
Dockerfile tôi đã ghép nối với nhau từ các ví dụ khác nhau từ khắp nơi trên mạng. Thư mục cho Dockerfile bao gồm:
- Dockerfile
- id_rsa
- start.sh
Đây là Dockerfile:
FROM ubuntu:13.10
# make sure apt is up to date
RUN apt-get update
# install npm, git, ssh, curl
RUN apt-get install -y npm git git-core ssh curl
RUN mkdir /nodejs && curl http://nodejs.org/dist/v0.10.31/node-v0.10.31-linux-x64.tar.gz | tar xvzf - -C /nodejs --strip-components=1
# Fixes empty home
ENV PATH $PATH:/nodejs/bin
ENV HOME /root
# SSH SETUP
RUN mkdir -p /root/.ssh
ADD id_rsa /root/.ssh/id_rsa
RUN chmod 700 /root/.ssh/id_rsa
RUN echo "IdentityFile /root/.ssh/id_rsa" >> /root/.ssh/ssh_config
RUN ssh-keyscan github.com >> /root/.ssh/known_hosts
ADD start.sh /tmp/
RUN chmod +x /tmp/start.sh
CMD ./tmp/start.sh
Sau khi thiết lập xong , start.sh chạy và tôi gặp sự cố với phụ thuộc NPM riêng tư mà dịch vụ Node.js riêng tư băng có. Đây là những gì start.sh được thực hiện:
cd /tmp
# try to remove the repo if it already exists
rm -rf MediaFX; true
git clone https://<username>:<password>@github.com/company/ExampleRepo.git
cd RepoName
node --version
ls
npm install
NODE_ENV=test DEBUG=* PORT=3000 node server.js
Trong package.json cho ExampleRepo, có một mô-đun riêng mà chúng tôi nhập khẩu như thế này:
"dependencies": {
"scribe": "git+ssh://[email protected]:Company/PrivateDep.git"
},
Khi NPM cài đặt được để repo này, nó xuất ra các nhật ký này:
npm ERR! git clone [email protected]:InboxAppCo/scribe.git Cloning into bare repository '/root/.npm/_git-remotes/git-github-com-InboxAppCo-scribe-git-abae334a'...
npm ERR! git clone [email protected]:InboxAppCo/scribe.git
npm ERR! git clone [email protected]:InboxAppCo/scribe.git Warning: Permanently added the RSA host key for IP address '192.30.252.130' to the list of known hosts.
npm ERR! git clone [email protected]:InboxAppCo/scribe.git Permission denied (publickey).
npm ERR! git clone [email protected]:InboxAppCo/scribe.git fatal: Could not read from remote repository.
npm ERR! git clone [email protected]:InboxAppCo/scribe.git
npm ERR! git clone [email protected]:InboxAppCo/scribe.git Please make sure you have the correct access rights
npm ERR! git clone [email protected]:InboxAppCo/scribe.git and the repository exists.
npm ERR! Error: `git "clone" "--mirror" "[email protected]:InboxAppCo/scribe.git" "/root/.npm/_git-remotes/git-github-com-InboxAppCo-scribe-git-abae334a"` failed with 128
npm ERR! at ChildProcess.cpclosed (/usr/share/npm/lib/utils/exec.js:59:20)
npm ERR! at ChildProcess.EventEmitter.emit (events.js:98:17)
npm ERR! at Process.ChildProcess._handle.onexit (child_process.js:789:12)
npm ERR! If you need help, you may report this log at:
npm ERR! <http://bugs.debian.org/npm>
npm ERR! or use
npm ERR! reportbug --attach /tmp/MediaFX/npm-debug.log npm
npm ERR! System Linux 3.16.4-tinycore64
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install"
npm ERR! cwd /tmp/MediaFX
npm ERR! node -v v0.10.15
npm ERR! npm -v 1.2.18
Tôi nghĩ rằng vì bản sao của dịch vụ Node riêng tư hoạt động tốt, bất kỳ phụ thuộc NPM riêng nào của nó sẽ cài đặt trơn tru.
Tôi khá tích cực rằng việc thiết lập SSH của tôi là không hoàn thiện (và nó không thể hiện bản thân trong khi git nhân bản repo cha mẹ riêng) vì tôi đã thêm tên người dùng và mật khẩu vào liên kết. Tuy nhiên, tôi không chắc chắn và sẽ đánh giá cao một số hướng dẫn về cách thực hiện điều này một cách chính xác.
Đối với một điều, bạn cần gói openssh và ca-certificate. Ngoài ra, hãy thử chạy thùng chứa của bạn tương tác và bước tất cả mọi thứ để tìm ra những thứ này. docker run -it/bin/bash –
user2105103