Docker mulitstage build jenkins

0 votes

I’m using multistage build in docker. I’m using Jenkins to build the image in my CI process. I’m able to build the image completely fine on my local. But when I’m trying to build it, its showing me an error:

Step 1/11 : FROM node:8.1.4-alpine as builder
Error parsing reference: "node:8.1.4-alpine as builder" is not a valid repository/tag: invalid reference format

All my single builds work perfectly fine, I think its something to do with the multistage build.

Here’s my docker file:

### STAGE 1: Build ###
# We label our stage as ‘builder’
FROM node:8.1.4-alpine as builder
COPY package.json ./
## Storing node modules on a separate layer will prevent unnecessary npm installs at each build
RUN npm i && mkdir /ng-app && cp -R ./node_modules ./ng-app
WORKDIR /ng-app
COPY . .
## Build the angular app in production mode and store the artifacts in dist folder
RUN $(npm bin)/ng build --prod
### STAGE 2: Setup ###
FROM nginx:1.13.3-alpine
## Copy our default nginx config
COPY nginx/default.conf /etc/nginx/conf.d/
## Remove default nginx website
RUN rm -rf /usr/share/nginx/html/*
## From ‘builder’ stage copy over the artifacts in dist folder to default nginx public folder
COPY --from=builder /ng-app/dist /usr/share/nginx/html
CMD ["nginx", "-g", "daemon off;"]
I'm using the the following jenkins version: `jenkins/jenkins:2.95``

Any help would be appreciated.

Aug 8, 2018 in Jenkins by Hannah
• 14,080 points
272 views

1 answer to this question.

0 votes

Make a few changes in your dockerfile

Basically just using the stage 2 and building the production version manually beforehand.

### STAGE 2: Setup ###
FROM nginx:1.13.3-alpine
## Copy our default nginx config
COPY nginx/default.conf /etc/nginx/conf.d/
## Remove default nginx website
RUN rm -rf /usr/share/nginx/html/*
## From ‘builder’ stage copy over the artifacts in dist folder to default nginx public folder
COPY --from=builder /ng-app/dist /usr/share/nginx/html
CMD ["nginx", "-g", "daemon off;"]
answered Aug 8, 2018 by Kalgi
• 37,320 points

Related Questions In Jenkins

0 votes
1 answer

Why is it displaying Jenkins build failure for Android app

I think you should try this. Try Uninstalling ...READ MORE

answered Apr 12, 2018 in Jenkins by shubham
• 6,870 points
198 views
+2 votes
5 answers
0 votes
1 answer

Jenkins: Build Pipeline Plugin Scheduled Trigger

This can be done by setting the ...READ MORE

answered Jul 10, 2018 in Jenkins by Sophie may
• 9,430 points
232 views
0 votes
1 answer

Jenkins Pipeline: Build using parameters

This error occurs because you havent passed ...READ MORE

answered Jul 10, 2018 in Jenkins by Sophie may
• 9,430 points
1,162 views
0 votes
1 answer
0 votes
1 answer
0 votes
2 answers

Jenkins - identify if build is tagged

Set refspec to: +refs/tags/*:refs/remotes/origin/tags/* branch specifier: ** Under build triggers check ...READ MORE

answered Oct 25, 2018 in Jenkins by kailash
39 views
0 votes
1 answer

Jenkins - simply robocopy in Jenkins finishes marks build with failure

robocopy returns a bit map This is the ...READ MORE

answered Aug 6, 2018 in Jenkins by Kalgi
• 37,320 points
288 views