Following this guide from the Node.js site to create a Docker image for a Node application, everything succeeds except when you have a private repository for a certain npm package, like the following package.json
snippet:
"dependencies": {
(...)
"um-certo-pacote": "git+ssh://[email protected]:/algum/diretorio/um-certo-pacote.git",
(...)
The server that has the repo stores the ssh key of the requesting computer to clone the packet. Locally everything works, but at the time of doing a build, it does not work because Docker does not have access to the ssh key.
$ docker build -t nbkhope/meu-aplicativo --add-host=algumlugar.com:123.45.67.89 .
I already searched in several places and tried to copy the file with the ssh public key, but this is not recommended due to security reasons. So what is the way to make this business work safely without exposing secrets?
Follow Dockerfile:
FROM node:6
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 8080
CMD ["npm", "start"]