【发布时间】:2020-02-14 10:58:21
【问题描述】:
我正在尝试 dockerize 一个项目,该项目使用我们 GitLab 服务器上的一些私有 npm 依赖项(url 类似于 10.1.1.150)。当我在 CMD 中运行 npm install 时,它运行良好,但在 Docker 中我收到以下错误:
npm ERR! Error while executing:
npm ERR! /usr/bin/git ls-remote -h -t https://10.1.1.150/WebDev/firstdependency.git
npm ERR!
npm ERR! remote: HTTP Basic: Access denied
npm ERR! fatal: Authentication failed for 'https://10.1.1.150/WebDev/firstdependency.git/'
npm ERR!
npm ERR! exited with error code: 128
我的 Dockerfile:
FROM node
ENV NODE_ENV production
WORKDIR /usr/src/app
COPY ["package.json", "package-lock.json*", "npm-shrinkwrap.json*", "./"]
RUN npm set strict-ssl false --global
RUN git init
RUN git config --global http.sslVerify false
RUN git config http.emptyAuth true
RUN npm install --production
RUN mv node_modules ../
COPY . .
CMD npm start
包含失败部分的 package.json 文件的一部分:
"repository": {
"type": "git",
"url": "https://10.1.1.150/WebDev/thisproject.git"
},
"dependencies": {
"@mycompany/firstdependency": "git+https://10.1.1.150/WebDevelopment/firstdependency.git",
"@mycompany/seconddependency": "git+https://10.1.1.150/WebDevelopment/seconddependency.git",
"@mycompany/thirddependency": "git+https://10.1.1.150/WebDevelopment/thirddependency.git"
我猜问题的核心是我无法在 Dockerfile 中传递我的凭据,因此它无法登录到我们的本地 repo。 操作系统:WIN10 npm:6.13.4 码头工人:19.03.2 如何解决此身份验证错误?
【问题讨论】:
标签: git docker authentication npm gitlab