how to run gulp task from dockerfile
You have to install gulp globally AND locally:
RUN npm install -g gulp
RUN npm install gulp
See this post for a discussion about the reason.
Related videos on Youtube
Rahul
I am Rahul Palake, a Web Developer. A PHP Ninja. I have a passion for Software Engineering and advancing the field. I help people make beautiful websites, functional applications and seamless user experiences. I also write random stuff about what I'm interested in. I love challenges and I'm always looking for opportunities to do awesome things. SOreadytohelp
Updated on June 04, 2022Comments
-
Rahul almost 2 years
I am trying to run gulp task from my Dockerfile. Here is my Dockerfile
# # Node.js w/ Bower & Grunt Dockerfile # # https://github.com/digitallyseamless/docker-nodejs-bower-grunt # # Pull base image. FROM library/node:4 MAINTAINER Digitally Seamless <[email protected]> # Install Bower & Grunt RUN npm install -g bower grunt-cli && \ echo '{ "allow_root": true }' > /root/.bowerrc RUN npm install gulp -y RUN gulp ng-config --env development # Define working directory. WORKDIR /data COPY . /data # Define default command. EXPOSE 7000 CMD ["bash"]
Please note in above Dockerfile I am trying to install gulp and run gulp task as follows:
RUN npm install gulp -y RUN gulp ng-config --env development
where ng-config is my gulp task defined in gulpfile.js file.
when I try to build image with above mentioned Dockerfile content I get error like gulp: not found
I am not sure if gulp is not getting installed properly or why it is not recognizing the gulp command. Can you guys please help?
EDIT:
If I try to install gulp globally, my build fails with following output.
Sending build context to Docker daemon 7.893MB Step 1/9 : FROM library/node:4 ---> 3fb5ca8fcd8e Step 2/9 : MAINTAINER Digitally Seamless <[email protected]> ---> Using cache ---> 242154cec3ce Step 3/9 : RUN npm install -g bower grunt-cli && echo '{ "allow_root": true }' > /root/.bowerrc ---> Using cache ---> b73fc7831a4a Step 4/9 : RUN npm install -g gulp -y ---> Using cache ---> b498e61bfb8e Step 5/9 : RUN gulp ng-config --env development ---> Running in 38d2e7f208cc [08:21:29] Local gulp not found in / [08:21:29] Try running: npm install gulp The command '/bin/sh -c gulp ng-config --env development' returned a non-zero code: 1
-
Rahul over 6 yearsI tried with global installation of gulp as well, still the docker build process fails. Please see the EDIT section in question posted. However when remove the gulp ng-confg command from dockerfile and create the docker image, the image is created, and I can run that image, and when I docker exec into the running container and again run the gulp ng-config --env command it gets executed successfully, might be gulp is getting installed from dockerfile, it is just that gulp command is not recognized for some reason in dockerfile
-
Rahul over 6 yearsThanks @Meoma, after installing globally and locally I am able to run gulp tasks from Dockerfile