I am setting up a Jenkins build pipeline for vue application. I have a simple Dockerfile to build&run VUE application as a container. When I am trying to build the application on my PC, docker build successfully finishes without an error.
However once the Jenkins build process is started, RUN npm install command of the Dockerfile returns an error while the build stage is in process.
I checked the server's swap space, the error is not related to that. Manually, I executed a npm install file for the package.json file on server.
Does anybody have an experience regarding to executing npm commands during Jenkins pipeline stage?
Here is the both Dockerfile & Jenkinsfile that I used
Dockerfile
# build stage
FROM node:lts-alpine as build-stage
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
# production stage
FROM nginx:stable-alpine as production-stage
COPY --from=build-stage /app/dist /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
Jenkinsfile
#!/usr/bin/env groovy
pipeline {
options {
timeout(time: 1, unit: 'HOURS')
}
agent none
stages {
stage('Pre process') {
agent any
steps {
script {
...
}
...
}
}
stage('Build') {
agent any
steps {
sh 'docker build -t frontend'
}
}
stage('Run') {
agent any
steps {
sh 'docker run ..... '
}
}
stage('Update') {
agent any
steps {
e..
}
}
stage('Test & Clean-up') {
....
}
} // stages
} // pipeline
Error message
Step 4/10 : RUN npm install
---> Running in 80e0beb9442a
> [email protected] install /app/node_modules/node-sass
> node scripts/install.js
Service 'frontend' failed to build: The command '/bin/sh -c npm install' returned a non-zero code: 1
script returned exit code 1