0

I have installed a node module from BitBucket. It is my package.json

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

However, when I build the Docker image with this Dockerfile,

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.

I don't want to save my git credentials in the package.json file but save it in the server. What type of credentials and how can I provide the credentials when building the image?

Ken Yip
  • 599
  • 1
  • 8
  • 17

2 Answers2

1

You may want to use ssh keys for this one, instead of the user credentials

More details here

kakabali
  • 3,824
  • 2
  • 29
  • 58
  • 1
    Finally found the solution. We need to generate the SSH keys and change `git+https` to `git+ssh` – Ken Yip May 06 '21 at 08:19
1

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.

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

Kira
  • 92
  • 3