Docker build node app with a private repo as dependency

Hello there, I’m trying to create a container for my node + vue application. The problem is that as a dependency I have a private repository hosted on gitlab.
The installation process on my local environment is very simple: I added this line in my package.json:

"lib-css": "git+ssh://"

and then I simply run npm i, and I insert my gitlab password when npm asks me for it.

That process fails during my docker build because there is no password insertion. I tried to add my private key as well like this:

WORKDIR /usr/src/app

RUN mkdir -p /root/.ssh
COPY .secrets /root/.ssh/id_rsa
# RUN ssh-keyscan -p 9922 >> /root/.ssh/known_hosts
RUN chmod 700 /root/.ssh && chmod 600 /root/.ssh/*

# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package*.json ./

RUN npm install
# If you are building your code for production
# RUN npm install --only=production

# Bundle app source
COPY . .

CMD [ "npm", "run dev" ]

the file .secretscontain my private key associatod to the public key in gitlab.
The build still fails with the error:

npm ERR! Host key verification failed.
npm ERR! fatal: Could not read from remote repository.
npm ERR!
npm ERR! Please make sure you have the correct access rights
npm ERR! and the repository exists.
npm ERR!
npm ERR! exited with error code: 128

How can I solve this?

Hi. Did you get to solve this?

I may have been able to get past the " fatal: Could not read from remote repository." error by copying an SSH key to the image:

RUN mkdir -p /root/.ssh/ && \
    echo "$SSH_KEY" > /root/.ssh/id_rsa && \
    chmod -R 600 /root/.ssh/ && \
    ssh-keyscan -t rsa >> ~/.ssh/known_hosts

This was in connection with a bitbucket pipeline. But even with this I’m getting errors on the private repo:

Module not found: Error: Can’t resolve

I’m interested if anyone has found a way to build a node app with a private repo as dependency.