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
• 18,570 points
2,185 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
• 52,360 points

Related Questions In Jenkins

0 votes
2 answers
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
• 7,340 points
1,539 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 11, 2018 in Jenkins by Sophie may
• 10,610 points
4,414 views
+1 vote
1 answer
+2 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
1,089 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
• 52,360 points
3,210 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP