Issue
Having a Jenkins Docker image, I would like to add the complete 'npm' environment to that image. So after building the Dockerfile I have an image with both Jenkins and the 'npm' environment.
The purpose is that a Jenkins job to run the shell command 'npm'. So 'npm' should be on the $PATH (in Ubuntu).
I have already a Dockerfile with a lot stuff in there like Jenkins and Maven.
A solution for node was described in this post. The important thing is, can I do something simular? Which folders should I copy to the Jenkins docker image?
FROM node as nodejs
FROM jenkins/jenkins
// All kinds of other stuff goes here
COPY --from=nodejs /usr/local/bin/node /usr/local/bin/node ???
Installing 'npm' automatically within a Jenkins Global tool is not my preferred solution.
Solution
Using multiple FROM
directives is not a feature, it's a bug. It's proposed to remove it and you should avoid using it
at all costs!
If you need npm in your jenkins, just install it there. It's based on openjdk
image anyway.
FROM jenkins/jenkins
RUN apt-get install -y curl \
&& curl -sL https://deb.nodesource.com/setup_9.x | bash - \
&& apt-get install -y nodejs \
&& curl -L https://www.npmjs.com/install.sh | sh
Answered By - Kevin Kopf
Answer Checked By - Candace Johnson (JavaFixing Volunteer)