Docker Community Forums

Share and learn in the Docker community.

DockerHub build environment variables Node.js NPM Private

Hello,
I have a Dockerfile that runs in DockerHub builds and I am unable to get the NPM_TOKEN build arg into the instance so NPM can use the token to authenticate to a private NPM repository. I get a 404 error from docker which tells me it isn’t authenticating. I can hardcode the token and it works as expected. The environment var is set in the build configuration screen. What am I missing? Thanks

FROM node:10.15.3-alpine as build
WORKDIR /build
ARG ARG_NPM_TOKEN
ENV NPM_TOKEN=$ARG_NPM_TOKEN
COPY .npmrc ./.npmrc
COPY npm-shrinkwrap.json npm-shrinkwrap.json
COPY package.json package.json
RUN npm set progress=false \
  && npm config set depth 0 \
  && npm ci --production --only=production --loglevel=error \
  && rm -f ./.npmrc
COPY newrelic.js newrelic.js
COPY app.js app.js

FROM node:10.15.3-alpine
WORKDIR /opt
ENTRYPOINT ["node", "app.js"]
COPY --from=build /build /opt