我们有一个使用sinopia托管的私有npm存储库,它具有基本的身份验证凭据。我们的应用程序使用私有仓库的npm软件包。我创建了身份验证令牌并进行了尝试,但是在RUN npm install utilities@0.1.9
行出现了错误:
npm ERR! code E403 npm ERR! 403 Forbidden: utilities@0.1.9 npm ERR! A complete log of this run can be found in: npm ERR! /root/.npm/_logs/2018-07-05T10_55_25_752Z-debug.log
我的Dockerfile
是:
FROM keymetrics/pm2:latest-alpine
RUN mkdir -p /app
WORKDIR /app
COPY package.json ./
COPY .npmrc ./
RUN npm config set registry http://private.repo/:_authToken=CqgPS5l++vjD0n6ynxrVNg==.
RUN npm install utilities@0.1.9
RUN apk update && apk add yarn python g++ make && rm -rf /var/cache/apk/*
RUN set NODE_ENV=production
RUN npm config set registry https://registry.npmjs.org/
RUN npm install
COPY . /app
RUN ls -al -R
EXPOSE 51967
CMD [ "pm2-runtime", "start", "pm2.json" ]
错误日志为:
11 verbose stack at tryCatcher (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/util.js:16:23) 11 verbose stack at Promise._settlePromiseFromHandler (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:512:31) 11 verbose stack at Promise._settlePromise (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:569:18) 11 verbose stack at Promise._settlePromise0 (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:614:10) 11 verbose stack at Promise._settlePromises (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:693:18) 11 verbose stack at Async._drainQueue (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:133:16) 11 verbose stack at Async._drainQueues (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:143:10) 11 verbose stack at Immediate.Async.drainQueues (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:17:14) 11 verbose stack at runCallback (timers.js:794:20) 11 verbose stack at tryOnImmediate (timers.js:752:5) 11 verbose stack at processImmediate [as _immediateCallback] (timers.js:729:5)
有人可以帮我吗?
答案 0 :(得分:4)
我猜包裹@Override
protected Map<String, DataPart> getByteData() throws AuthFailureError {
Map<String, DataPart> params = new HashMap<String, DataPart>();
params.put("imgs", new DataPart(id + ".jpg", getFileDataFromBitmap(selectImg[0]), "image/jpeg"));
params.put("imgs", new DataPart(id + ".jpg", getFileDataFromBitmap(selectImg[1]), "image/jpeg"));
params.put("imgs", new DataPart(id + ".jpg", getFileDataFromBitmap(selectImg[2]), "image/jpeg"));
return params;
}
是您的私人包裹?如果是这样,则似乎您的身份验证令牌未使用或由于某种原因无法访问该软件包。
您可以尝试编写utilities@0.1.9
文件,而不要使用配置集,这只是使用情况:
~/.npmrc
这将使您的docker用户随后针对定义的注册表使用该令牌进行身份验证。大多数情况下,这就是我们为npm设置身份验证令牌的方式。
另一方面,您可能希望考虑不一个接一个地使用多个RUN命令。这将导致为每个命令创建一个新的图像层,并且可能使容器的大小大大膨胀。尝试在命令末尾使用RUN echo -e "//private.repo/:_authToken=... > ~/.npmrc
,然后将下一个命令放在没有&& \
位的新行中。例如:
RUN
它应该具有可读性,但是最终图像应该更小并且可能更快地构建。