npm-cli-login
npm-cli-login copied to clipboard
Unable to authenticate with private registry inside docker container
Using node:10.16.3-alpine
image for docker container.
Package version: v0.1.1
After using:
RUN npm-cli-login -u ${NPM_REGISTRY_USERNAME} -p ${NPM_REGISTRY_PASSWORD} -e ${NPM_REGISTRY_EMAIL} -r ${NPM_REGISTRY} -s ${NPM_REGISTRY_SCOPE} --config-path ${NPM_CONFIG_FILE}
Config file exists & login succeeds. However on npm install
the authentication fails.
Here's the content of Dockerfile:
FROM node:10.16.3-alpine
# install dependencies
ARG NPM_REGISTRY_USERNAME
ARG NPM_REGISTRY_PASSWORD
ARG NPM_REGISTRY_EMAIL
ARG NPM_REGISTRY
ARG NPM_REGISTRY_SCOPE
ARG NPM_CONFIG_FILE=.npmrc
RUN mkdir /service
RUN mkdir /service/build
RUN npm install -g npm-cli-login
WORKDIR /service
RUN ls
RUN npm-cli-login -u ${NPM_REGISTRY_USERNAME} -p ${NPM_REGISTRY_PASSWORD} -e ${NPM_REGISTRY_EMAIL} -r ${NPM_REGISTRY} -s ${NPM_REGISTRY_SCOPE} --config-path ${NPM_CONFIG_FILE}
ADD package.json ./
RUN ls
RUN npm install
# copy app source to image _after_ npm install so that
# application code changes don't bust the docker cache of npm install step
ADD build /service/build
# CMD [ "npm", "run", "start" ]
Here all the args are valid & authentication succeed with status 201
.
Did you ever get any resolution to this?
I have the exact same issue.
Yes you need to put .npmrc file in docker service root. Check official npm docs.
On Thu 30 Jan, 2020, 11:28 AM Scot Mcphee, [email protected] wrote:
Did you ever get any resolution to this?
I have the exact same issue.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/postmanlabs/npm-cli-login/issues/47?email_source=notifications&email_token=AKUKAC4JSAV4Z6YSO4X2UBTRAJT77A5CNFSM4JPSSGFKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKJZANY#issuecomment-580096055, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKUKACZL4DZPRZJ5AKCY5HLRAJT77ANCNFSM4JPSSGFA .
@akash-rajput how to you set your tokem inside the npmrc file? I cannot get to resolve the env var.
@alexesca You can print in/copy inside the .npmrc file in docker https://docs.npmjs.com/docker-and-private-modules#update-the-dockerfile