Hi all,
I’ve just built a new drone server on Kubernetes, and is trying to build a docker image of a node application through drone pipeline.
I’ve written the build commands in Dockerfile, which works fine on my local device, as following:
FROM node:10.16.3
ADD . /app
WORKDIR /appRUN npm install
RUN npm run build // build the vue.js static files.RUN ls -al .
CMD [“node”, “server.js”]
With the following .drone.yml:
kind: pipeline
type: dockersteps:
- name: Publishimage: plugins/docker settings: repo: my_repo tags: ${DRONE_COMMIT_BRANCH}.${DRONE_COMMIT:7} username: from_secret: docker_username password: from_secret: docker_password
trigger:
branch:
- master
event:
- push
However, I get the following error during npm install step:
Step 4/11 : RUN npm install
124 —> Running in cb884caee071
125 npm ERR! code EAI_AGAIN
126 npm ERR! errno EAI_AGAIN
127 npm ERR! request to https://registry.npmjs.org/@sinonjs/text-encoding/-/text-encoding-0.7.1.tgz failed, reason: getaddrinfo EAI_AGAIN registry .npmjs.org registry.npmjs.org:443
128
129 npm ERR! A complete log of this run can be found in:
130 npm ERR! /root/.npm/_logs/2019-09-09T09_06_47_425Z-debug.log
131 The command ‘/bin/sh -c npm install’ returned a non-zero code: 1
132 time=“2019-09-09T09:23:27Z” level=fatal msg=“exit status 1”
But if I move the build commands to .drone.yml, with the same node image, npm install works fine. As the following:
kind: pipeline
type: docker
name: projectsteps:
- name: Install node modulesimage: node:10.16.3 commands: - npm install
- name: Build static web
image: node:10.16.3 commands: - npm run build
- name: Publish
image: plugins/docker settings: repo: my_repo tags: ${DRONE_COMMIT_BRANCH}.${DRONE_COMMIT:7} username: from_secret: docker_username password: from_secret: docker_password
trigger:
branch:
- master
event:- push
Here’s my drone configurations:
image: drone/drone:1.3.1
ports:
- 80:80
environments:
- DRONE_GITLAB_CLIENT_ID: my_client_id
- DRONE_GITLAB_CLIENT_SECRET: my_secret,
- DRONE_GITLAB_SERVER: my_gitlab_domain,
- DRONE_SERVER_HOST: my_drone_host,
- DRONE_SERVER_PROTO: “https”
volumes:
- /data:/data
- /var/run/docker.sock:/var/run/docker.sock
Why “npm install” works with drone pipeline command, but doesn’t work with command in Dockerfile on the exact same drone server, while they are using the same tag of image.