# Dockerfile npm install fails with private registry

**URL:** <https://drone.discourse.group/t/dockerfile-npm-install-fails-with-private-registry/11464>\
**Category:** Drone Support\
**Created:** [August 11, 2021, 8:33am UTC](https://drone.discourse.group/t/dockerfile-npm-install-fails-with-private-registry/11464 "2021-08-11T08:33:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![CrazyBene](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/crazybene/32/6448_2.png) [@CrazyBene](https://drone.discourse.group/u/CrazyBene)\
**Post date:** [August 11, 2021, 8:33am UTC](https://drone.discourse.group/t/dockerfile-npm-install-fails-with-private-registry/11464/1 "2021-08-11T08:33:55Z")

</div>

I have a problem when I want to build a docker image with the docker plugin. Everything works fine when I use it “normally”, but when I need to access a private npm registry from my Dockfile, I get an error.

I have a drone file, which just builds a docker image from a Dockerfile and uploads it into a private docker registry.  
This Dockerfile looks like this and is there to build a vue js app.

> FROM node:latest as build-stage  
> WORKDIR /app  
> COPY package\*.json ./  
> COPY .npmrc ./  
> RUN npm config set strict-ssl false  
> RUN npm install  
> COPY ./ .  
> RUN npm run build
> 
> FROM nginx:1.20 as production-stage  
> ENV TZ=“Europe/Berlin”  
> RUN mkdir /app  
> COPY --from=build-stage /app/dist /app  
> COPY nginx.conf /etc/nginx/nginx.conf
> 
> CMD [“nginx”, “-g”, “daemon off;”]

The problem now is that I need to use a custom npm registry to pull the node packages from.  
(thats why i use the .npmrc file)

But the donr ci pipeline fails with this message

 ![error2](https://canada1.discourse-cdn.com/flex003/uploads/testdrone/original/2X/a/a520674832abd617c79479ee6d3e92e05c1ec18d.png)

This is my drone pipeline:

> kind: pipeline  
> type: docker  
> name: deploy new view version
> 
> steps:
> 
> - name: build frontend  
> image: plugins/docker  
> settings:  
> username: USERNAME  
> password: PASSWORD  
> context: vue-app  
> dockerfile: vue-app/Dockerfile  
> repo: REPO/vue-app  
> registry: REPO  
> insecure: true

I seached everywhere for an answer, but the only thing I always read is: “set up a proxy”, but I have no idea to what value I need to set the proxy.

---

<div class="post-metadata">

**Author:** ![carboneater](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/carboneater/32/3147_2.png) [@carboneater](https://drone.discourse.group/u/carboneater)\
**Post date:** [August 18, 2021, 8:14pm UTC](https://drone.discourse.group/t/dockerfile-npm-install-fails-with-private-registry/11464/2 "2021-08-18T20:14:29Z")

</div>

Hi!

It may or may not be the answer you’re looking for, but I had a similar issue with my private registry (Verdaccio).

Turns out, I was running into firewall issues.

I never dug into the nitty-gritty of the issue, but adding a rule in the firewall so my build system’s public IP can access my private repository enabled me to build docker containers in my pipelines with a private registry.

Hope that helps!

---

<div class="post-metadata">

**Author:** ![CrazyBene](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/crazybene/32/6448_2.png) [@CrazyBene](https://drone.discourse.group/u/CrazyBene)\
**Post date:** [September 6, 2021, 8:37am UTC](https://drone.discourse.group/t/dockerfile-npm-install-fails-with-private-registry/11464/3 "2021-09-06T08:37:45Z")

</div>

Hey,  
that should not be the problem in my case.  
I can build the image on the pipeline if I dont do the build.stage inside the docker.

I can build the frontend in two seperate steps on the pipeline. Like this:

kind: pipeline  
type: docker  
name: deploy new view version

steps:

- name: build package  
image: node  
commands:  
- cd vue-app  
- npm config set strict-ssl false  
- npm install  
- npm run build
- name: build frontend  
image: plugins/docker  
settings:  
username: USERNAME  
password: PASSWORD  
context: vue-app  
dockerfile: vue-app/Dockerfile  
repo: REPO/vue-app  
registry: REPO  
insecure: true

But this is not a good solution in my opinion, because i am splitting up my dockerfile into two parts AND one part is also inside my drone file.  
It works, but i really dont like it.

But this shows to me, that i can build the image on the pipeline, but the docker plugin for the pipeline cannot access my private npm registry
