2

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 <docker@digitallyseamless.com>

# 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 <docker@digitallyseamless.com>
 ---> 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
  • 2,189
  • 7
  • 40
  • 60

1 Answers1

7

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.

Moema
  • 863
  • 4
  • 10
  • I 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 Oct 04 '17 at 08:33
  • Thanks @Meoma, after installing globally and locally I am able to run gulp tasks from Dockerfile – Rahul Oct 04 '17 at 10:45