abaracedo
abaracedo

Reputation: 1454

Docker Compose gulp is not found in $PATH

I have just started learning docker-compose and I am using a nodejs image. I want to install gulp to create some tasks and have one of them working on the background.

When I run: docker-compose run --rm -d server gulp watch-less

I get this error: ERROR: oci runtime error: container_linux.go:247: starting container process caused "exec: \"gulp\": executable file not found in $PATH"

Here are my file:

# Dockerfile
FROM node:6.10.2

RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

COPY package.json /usr/src/app
RUN npm install --quiet

COPY . /usr/src/app

CMD ["npm", "start"]

# docker-compose.yml
version: "2"
services:
  server:
    build: .
    ports:
      - "5000:5000"
    volumes:
      - ./:/usr/src/app

I also have a .dockerignore to ignore the node_modules folder and the npm-debug.log

EDIT:

When I run docker-compose run --rm server npm install package-name I don't have any problem and the package is installed.

Upvotes: 0

Views: 2201

Answers (3)

jhorman
jhorman

Reputation: 466

I find that just referencing gulp via

./node_modules/.bin/gulp

instead of directly works fine. ./node_modules/.bin isn't in the path by default. Another option would be to add that dir to the PATH.

Upvotes: 0

abaracedo
abaracedo

Reputation: 1454

I have found a solution that works but maybe is not the best solution. I have created an script that runs a gulp task on the package.json and if I run:

docker-compose run --rm server npm run gulp_task it works and does what it has to do.

Upvotes: 0

Robert
Robert

Reputation: 36763

Try adding gulp install in Dockerfile:

# Dockerfile
FROM node:6.10.2

RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

RUN npm install -g gulp
COPY package.json /usr/src/app
RUN npm install --quiet

COPY . /usr/src/app

CMD ["npm", "start"]

Upvotes: 1

Related Questions