Dockerfile npm install fails with private registry

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

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.

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!

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