How to install gulp on dock with dock

I am using docker compose and this is my yaml file

web: dockerfile: Dockerfile-dev build: . command: gulp volumes: - .:/app ports: - '9001:9001' 

and here is my docker file

 FROM node:0.12.7 RUN npm install -g bower gulp ADD . /app WORKDIR /app RUN bower install --allow-root 

Then i ran

 docker-compose -f docker-compose-dev.yml build docker-compose -f docker-compose-dev.yml up 

But I get the following error:

 Recreating web_web_1... Attaching to web_web_1 web_1 | [07:39:08] Local gulp not found in /app web_1 | [07:39:08] Try running: npm install gulp web_web_1 exited with code 1 Gracefully stopping... (press Ctrl+C again to force)**strong text** 

I tried adding the RUN npm install gulp before and after WORKDIR /app to install it locally, but I get the same error

reference

+6
source share
2 answers

You need to run npm install gulp AFTER WORKDIR /app so that gulp is installed locally in node_modules/gulp . But you have already done this with the same mistake. This is because in docker-compose-dev.yml , you set the main directory as the /app volume inside the docker-compose-dev.yml container . Therefore, local changes in the / app directory are lost when the container starts.

You can remove volumes from docker-compose-dev.yml or run npm install gulp on the host machine.

+7
source

You can create startup.sh

 npm install bower gulp bower install --allow-root 

(or whatever you need to run when the container starts), then your Docker file should execute startup.sh

 ... CMD ["/startup.sh"] 

the script will be run AFTER the directory is installed using docker-compose.

I would also suggest installing node_modules on a temporary file system by declaring in the docker-compose.yml file:

 volumes: - .:/app - /app/node_modules 
0
source

All Articles