docker - 从 docker 容器访问私有存储库作为 npm 依赖项
问题描述
我正在尝试在构建过程中注入我的 ssh
docker build --ssh default=C:\Users\***\.ssh\id_rsa .
// package.json
"airbase-common": "git+ssh://git@bitbucket.org/******/airbase-common.git"
// error
npm ERR! Error while executing:
npm ERR! /usr/bin/git ls-remote -h -t ssh://git@bitbucket.org/******/airbase-common.git
npm ERR!
npm ERR! Host key verification failed.
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.
提前致谢
解决方案
我找到了解决方案:如果有人像我一样在 Windows 环境中构建他的图像,你应该将 .ssh 文件夹作为你的 Dockerfile 的邻居
// Dockerfile
FROM node:12.16 AS builder
WORKDIR /app
COPY ./package.json ./
RUN mkdir /root/.ssh/
COPY .ssh /root/.ssh
RUN chmod 700 /root/.ssh/
RUN chmod 644 /root/.ssh/id_rsa.pub
RUN chmod 600 /root/.ssh/id_rsa
VOLUME [ "/root/.ssh" ]
RUN npm install
.... etc
推荐阅读
- c# - 调用时计算值并推入模型
- ios - 当应用程序在后台时,当用户接受 CallKit 调用时如何更新 UI?
- python - 为具有共享 x 轴的子图添加唯一 xticks
- url - 我可以通过 URL ($_GET) 自动将 PhpMyAdmin 导出到文件吗?
- mysql - 无法添加或更新子行:外键约束失败 - 不知道这怎么可能?
- python - 如何使用 python-camelot 从同一目录中的多个 PDF 中提取数据?
- hibernate - Hibernate 如何确定代理对象的类型
- javascript - node js连续API调用未执行
- python - 在 pandas 中找到平均最大值和最小值并将输出附加到单个文件中
- python - 从 JSON 中读取值