Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I install package from private repository using docker

I am installing a package from my private repository. I am able to install it using: npm i -S git+https://oauth2:[email protected]/mygroup/acl-api.git

I am using docker container but while installation process I am getting an error:

npm ERR! path git
npm ERR! code ENOENT
npm ERR! errno ENOENT
npm ERR! syscall spawn git
npm ERR! enoent Error while executing:
npm ERR! enoent undefined ls-remote -h -t https://oauth2:[email protected]/mygroup/acl-api.git
npm ERR! enoent
npm ERR! enoent
npm ERR! enoent spawn git ENOENT
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

How can I solve it?

My docker file:

FROM node:alpine

COPY package.json package.json
COPY src src
COPY .babelrc .babelrc

RUN npm install  
RUN npm run gitlab-build

RUN ls
EXPOSE 8080
CMD ["npm", "run", "docker-start"]
like image 903
kehez Avatar asked Aug 02 '19 17:08

kehez


People also ask

How do I push a docker image to a private repository?

log into your docker hub account, and go to your global settings. There is a setting that allows you to set what your default visability is for the repositories that you push. By default it is set to public, but if you change it to private, all of your repositories that you push will be marked as private by default.

Can I install anything in Docker container?

To install packages in a docker container, the packages should be defined in the Dockerfile. If you want to install packages in the Container, use the RUN statement followed by exact download command . You can update the Dockerfile with latest list of packages at anytime and build again to create new image out of it.


1 Answers

You should add git and openssh-client and other packages if you want to the node:alpine to let npm pull the repository

FROM node:alpine

RUN apk add --update \
  python \
  python-dev \
  py-pip \
  build-base \
  git \
  openssh-client \
&& pip install virtualenv \
&& rm -rf /var/cache/apk/*

COPY package.json package.json
COPY src src
COPY .babelrc .babelrc

RUN npm install  
RUN npm run gitlab-build

RUN ls
EXPOSE 8080
CMD ["npm", "run", "docker-start"]
like image 190
agusgambina Avatar answered Oct 18 '22 22:10

agusgambina