polyledger/connect

Install error in client

Closed this issue · 10 comments

In client:

> polyledger@1.0.0 dev /usr/src/client
> webpack-dev-server --inline --progress --host 0.0.0.0 --config build/webpack.dev.conf.js

sh: 1: webpack-dev-server: not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! polyledger@1.0.0 dev: `webpack-dev-server --inline --progress --host 0.0.0.0 --config build/webpack.dev.conf.js`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the polyledger@1.0.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2018-03-11T04_43_04_128Z-debug.log

> polyledger@1.0.0 dev /usr/src/client
> webpack-dev-server --inline --progress --host 0.0.0.0 --config build/webpack.dev.conf.js

sh: 1: webpack-dev-server: not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! polyledger@1.0.0 dev: `webpack-dev-server --inline --progress --host 0.0.0.0 --config build/webpack.dev.conf.js`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the polyledger@1.0.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2018-03-11T04_46_56_925Z-debug.log

Then I did $ docker-compose -p client build and $ docker-compose up again and it worked this time.

I'm not sure why/WTF happened.

Looking at the doc/examples, I understand that may be expected (i.e. we need to rebuild).

In this make, maybe the install process is not to run docker-compose up first, but to run the npm install first, then docker-compose rebuild then docker-compose up.

Thoughts?

I think (= I did a docker-compose down, did that and it worked) the actual steps are

$ docker-compose run client npm install
$ docker-compose build
$ docker-compose run server bash -c 'python manage.py makemigrations && python manage.py migrate'
$ docker-compose up

If you think that's alright I can update the wiki page.

How about instead of running the up and build commands in sequence with an error, trying docker compose up --build? Adding the flag should install the NPM modules before starting the container.

I haven't tested this from a fresh install, but this is what I've typically done after making changes to a Dockerfile.

Ok, I'll give it a try, thanks

I just tried running docker-compose up --build after deleting node_modules and it didn't install or copy over node_modules to the docker host.

Output from the build:

Step 2/8 : RUN mkdir -p /usr/src/client
 ---> Using cache
 ---> 44e5175b9787
Step 3/8 : WORKDIR /usr/src/client
 ---> Using cache
 ---> 1e5c66ed6d77
Step 4/8 : COPY package.json /usr/src/client/
 ---> Using cache
 ---> 960b9a72bba5
Step 5/8 : RUN npm install
 ---> Using cache
 ---> 2d85a5dee95c
Step 6/8 : COPY . /usr/src/client/
 ---> e622431e8267
Step 7/8 : EXPOSE 8080
 ---> Running in 57023cd38296
Removing intermediate container 57023cd38296
 ---> d2eb433c031e
Step 8/8 : CMD ["npm", "run", "dev"]
 ---> Running in 85b89ea9b15f

Output from starting client container:

client           | npm ERR! file sh
client           | npm ERR! code ELIFECYCLE
client           | npm ERR! errno ENOENT
client           | npm ERR! syscall spawn
client           | npm ERR! polyledger@1.0.0 dev: `webpack-dev-server --inline --progress --host 0.0.0.0 --config build/webpack.dev.conf.js`
client           | npm ERR! spawn ENOENT
client           | npm ERR!
client           | npm ERR! Failed at the polyledger@1.0.0 dev script.
client           | npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
client           | npm WARN Local package.json exists, but node_modules missing, did you mean to install?
client           |
client           | npm ERR! A complete log of this run can be found in:
client           | npm ERR!     /root/.npm/_logs/2018-03-16T23_33_04_605Z-debug.log

I am not sure if this was an issue related to Docker trying to use the node_modules cache. It may have failed to copy due to the cache. If so, then perhaps the command with the build flag works.

I ran docker-compose build --no-cache && docker-compose up but it still errored. 😦

So, it seems that the dependencies in client/ need to be pre-installed before starting Docker Compose. For some reason, running the npm install command in the Dockerfile doesn't work.

We can either just (1) add that piece of information to the quickstart guide or (2) combine it into one command:

$ cd client && npm i && cd .. && docker-compose up --build

This will be fixed with df26afc after merging #20

@Dagnan do you think this has been fixed?