[英]Authenticate to private npm registry from Dockerfile in azure?
I have the below Dockerfile:我有以下 Dockerfile:
FROM node:alpine
WORKDIR ./usr/local/lib/node_modules/npm/
COPY .npmrc ./
COPY package.json ./
COPY package-lock.json ./
RUN npm ci
COPY . .
EXPOSE 3000
CMD ["npm", "run", "start-prod"]
This file is used in an azure pipeline like so:此文件在 azure 管道中使用,如下所示:
variables:
- name: NPMRC_LOCATION
value: $(Agent.TempDirectory)
- stage: BuildPublishDockerImage
displayName: Build and publish Docker image
dependsOn: Build
jobs:
- job: BuildPublishDockerImage
steps:
- checkout: self
- task: DownloadSecureFile@1
name: npmrc
inputs:
secureFile: .npmrc
- task: npmAuthenticate@0
inputs:
workingFile: $(NPMRC_LOCATION)/.npmrc
- task: Docker@2
displayName: Build a Docker image
inputs:
command: build
arguments: --no-cache
I know .npmrc
should be in that location (I run RUN ls
in the Dockerfile and its there).我知道
.npmrc
应该在那个位置(我在 Dockerfile 和那里运行RUN ls
)。
However when I run it I keep getting this error:但是,当我运行它时,我不断收到此错误:
failed to solve with frontend dockerfile.v0: failed to build LLB: failed to compute cache key: "/.npmrc" not found: not found
无法使用前端 dockerfile.v0 解决:构建 LLB 失败:计算缓存键失败:“/.npmrc”未找到:未找到
I just want to authenticate to a private npm registry.我只想对私有 npm 注册表进行身份验证。 I'm mystified by this.
我对此感到困惑。 Grateful for any help.
感谢您的帮助。
You can in Dockerfile set registry你可以在Dockerfile设置注册表
npm config set registry
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.