mapbox / node-or-tools

Node.js bindings for or-tools vehicle routing problems
MIT License
147 stars 48 forks source link

Using Dockerfile #46

Closed hopewise closed 6 years ago

hopewise commented 6 years ago

I've tried to build the Dockerfile as a step to deploy a testing app to AWS EC2, but I got this error:

Error: /usr/local/src/app/lib/binding/node_or_tools.node: invalid ELF header
    at Error (native)
    at Object.Module._extensions..node (module.js:434:18)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/usr/local/src/app/lib/index.js:1:18)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/usr/local/src/app/test/tsp.js:2:15)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
Error: /usr/local/src/app/lib/binding/node_or_tools.node: invalid ELF header
    at Error (native)
    at Object.Module._extensions..node (module.js:434:18)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/usr/local/src/app/lib/index.js:1:18)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/usr/local/src/app/test/vrp.js:2:15)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
test/tsp.js
  1) test/tsp.js
test/vrp.js
  2) test/vrp.js

  0 passing (726.356ms)
  2 failing

  1) test/tsp.js test/tsp.js:
     test/tsp.js

  2) test/vrp.js test/vrp.js:
     test/vrp.js

npm ERR! Test failed.  See above for more details.
The command '/bin/sh -c apt-get update &&     apt-get install -y curl python make g++ &&         (curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.1/install.sh | bash) &&  export NVM_DIR="$HOME/.nvm" &&     . ${NVM_DIR}/nvm.sh &&     nvm install 4.8 &&     nvm use 4.8 &&         npm install --unsafe-perm &&     npm test &&         apt-get clean &&     rm -rf /var/lib/apt/lists/*' returned a non-zero code: 1

Also, I tried to run bash in a container of the resulted image:

docker run -it --rm 31f486c07bf6 /bin/bash

but it seems that npm/node are not installed? :

root@35c9b4eca133:/usr/local/src/app# npm
bash: npm: command not found
root@35c9b4eca133:/usr/local/src/app# node index
bash: node: command not found
root@35c9b4eca133:/usr/local/src/app# cd examples
bash: cd: examples: No such file or directory
root@35c9b4eca133:/usr/local/src/app# node index
bash: node: command not found
daniel-j-h commented 6 years ago

Hm the Dockerfile is a relic from earlier times when there was no pre-built binary packages for node-or-tools. We now let Travis compile and then publish pre-built packages via node-pre-gyp and npm.

The invalid ELF header message indicates something is wrong with the binary we download. Check

file /usr/local/src/app/lib/binding/node_or_tools.node

You could also try building from source by adding --build-from-source to the npm install command.

hopewise commented 6 years ago

Thanks, but what's the easiest way to deploy the app to AWS? can you please add some steps to do so in the readme file?

daniel-j-h commented 6 years ago

Project-specific Dockerfile (Ubuntu 16.04 LTS base image) and then installing node-or-tools via npm.

Either compile from source or use the pre-built binaries through npm.

Deploying to AWS is outside the scope of this project.

hopewise commented 6 years ago

Thanks, I will try with Ubuntu 16.04 LTS