简体   繁体   English

从 Dockerfile 中的 BitBucket 安装 node_modules

[英]Install node_modules from BitBucket in Dockerfile

I have installed a node module from BitBucket.我已经从 BitBucket 安装了一个节点模块。 It is my package.json这是我的 package.json

"dependencies": {
    "some-module": "git+https://bitbucket.org/some-module.git"
}

However, when I build the Docker image with this Dockerfile,但是,当我使用此 Dockerfile 构建 Docker 映像时,

FROM node:14.4.0

WORKDIR /usr/src/app

COPY ./package*.json ./

RUN npm install

COPY ./ .

I am failed to build because I have not provided the git credentials when building the image.我无法构建,因为在构建映像时我没有提供 git 凭据。

I don't want to save my git credentials in the package.json file but save it in the server.我不想将 git 凭据保存在 package.json 文件中,而是将其保存在服务器中。 What type of credentials and how can I provide the credentials when building the image?什么类型的凭据以及如何在构建映像时提供凭据?

You may want to use ssh keys for this one, instead of the user credentials您可能希望为此使用 ssh 密钥,而不是用户凭据

More details here更多细节在这里

As altready mentioned you can use ssh url in your Package.json and configure the SSH keys on the environment where your Dockerfile is built. As altready mentioned you can use ssh url in your Package.json and configure the SSH keys on the environment where your Dockerfile is built.

Otherwise, you can also use a private package repository, such as Artifactory or Nexus , publish your library package on this repo, then install it via npm, configure npm to use your private repository instead of npm public. Otherwise, you can also use a private package repository, such as Artifactory or Nexus , publish your library package on this repo, then install it via npm, configure npm to use your private repository instead of npm public.

https://blog.sonatype.com/using-nexus-3-as-your-repository-part-2-npm-packages https://blog.sonatype.com/using-nexus-3-as-your-repository-part-2-npm-packages

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM