justadudewhohacks / opencv4nodejs

Nodejs bindings to OpenCV 3 and OpenCV 4
MIT License
4.95k stars 826 forks source link

Heroku CI build fails when adding opencv4nodejs, but normal app deploy build works #427

Open rodcul opened 6 years ago

rodcul commented 6 years ago

We are building an API on Heroku and have and we recently added opencv4nodejs and our Heroku CI build is now failing.

Works fine on development environment and also if we deploy using git push, but if we try to use Heroku CI build fails.

I've tried with and without the OPENCV4NODEJS_DISABLE_AUTOBUILD flag with no success. Also if I change the node/npm versions the deploy also seems to fail (unsure if it's related).

-----> Fetching starkast/cmake buildpack...
       buildpack downloaded
-----> Fetching https://github.com/onboardiq/heroku16-buildpack-opencv3.git buildpack...
       buildpack downloaded
-----> Fetching heroku/nodejs buildpack...
       buildpack downloaded
-----> CMake app detected
-----> Installing CMake version: 3.8.1
       Downloading binary distribution
       Verifying download
gpg: new configuration file `/app/.gnupg/gpg.conf' created
gpg: WARNING: options in `/app/.gnupg/gpg.conf' are not yet active during this run

...

-----> Creating environment variables.
cp: '/app/.heroku/cmake' and '/app/.heroku/cmake' are the same file
cp: '/app/.heroku/vendor' and '/app/.heroku/vendor' are the same file
cp: '/app/.profile.d/opencv.sh' and '/app/.profile.d/opencv.sh' are the same file
cp: '/app/.profile.d/sprettur.sh' and '/app/.profile.d/sprettur.sh' are the same file
-----> Node.js app detected
bash: /tmp/buildpacks/9bc901852117be66dc68068325767a3d2b8ee44665d854d905a7c1524cf353680e0850b0ce15a6f75047288aa1c0ddbec0154cab65cd63fa33e54f02a7b570b6/export: No such file or directory

-----> Creating runtime environment

       NPM_CONFIG_LOGLEVEL=error
       NPM_CONFIG_PRODUCTION=false
       NODE_VERBOSE=false
       NODE_ENV=test
       NODE_MODULES_CACHE=true

-----> Installing binaries
       engines.node (package.json):  8.11.4
       engines.npm (package.json):   5.6.0

       Resolving node version 8.11.4...
       Downloading and installing node 8.11.4...
       npm 5.6.0 already installed with node

-----> Building dependencies
       Installing node modules (package.json + package-lock)

       > opencv-build@0.0.15 install /app/node_modules/opencv-build
       > node ./install.js

       info install if you want to use an own OpenCV installation set OPENCV4NODEJS_DISABLE_AUTOBUILD
       info install library dir does not exist: /app/node_modules/opencv-build/opencv/build/lib
       info install running install script...
       ERR! Error: Command failed: cmake --version
       /bin/sh: 1: cmake: not found

       npm ERR! code ELIFECYCLE
       npm ERR! errno 1
       npm ERR! opencv-build@0.0.15 install: `node ./install.js`
       npm ERR! Exit status 1
       npm ERR! 
       npm ERR! Failed at the opencv-build@0.0.15 install script.
       npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

       npm ERR! A complete log of this run can be found in:
       npm ERR!     /tmp/npmcache.VAgJQ/_logs/2018-10-08T16_13_39_048Z-debug.log
-----> Build failed

Here is my app.json as per https://stackoverflow.com/a/51351494/5028937

{
  "name": "myappname",
  "scripts": {},
  "env": {
    "GOOGLE_MAPS_API_KEY": {
      "required": true
    },
    "DATABASE_URL": {
      "required": true
    },
    "OPENCV4NODEJS_DISABLE_AUTOBUILD": {
      "required": true,
      "value": 1
    },
    "OVERPASS_URL": {
      "required": true
    }
  },
  "formation": {
    "web": {
      "quantity": 1
    }
  },
  "stack": "heroku-16",

  "buildpacks": [{
    "url": "starkast/cmake"
  }, {
    "url": "https://github.com/onboardiq/heroku16-buildpack-opencv3.git"
  }, {
    "url": "heroku/nodejs"
  }]
}

I also posted this on Stack Overflow

justadudewhohacks commented 6 years ago

Seems like cmake is not noticed. To be honest I am not familar with heroku buildpacks.

Why not simply use docker?

rodcul commented 6 years ago

@justadudewhohacks thanks for the suggestion, I will take a look at that option. I am also trying to familiarise myself with the Heroku build process...

justadudewhohacks commented 6 years ago

Ok, just saying I am not familar with Heroku buildpacks. I usually simply deploy docker containers to heroku running an instance of opencv4nodejs. Docker images with prebuilt OpenCV can be pulled from here and you can also have a look at the docker build scripts, to build a docker image with the latest opencv4nodejs version: opencv4nodejs-docker-images.

anatolysukhanov commented 6 years ago

@justadudewhohacks We finally made it work by removing the opencv buildpack from app.json and adding it via heroku buildpacks:add

cvocke commented 5 years ago

@anatolysukhanov @rodcul

I'm attempting to deploy to heroku using the same buildpacks along with minimal npm dependencies and my slug size is ~545MB which is over Heroku's limit. If you have any hints on how to keep the slug size down it would be greatly appreciated

cvocke commented 5 years ago

Ended up taking the docker route, thanks @justadudewhohacks

Still curious what I missed with the buildpack route though!